Witnesses said four more people were killed when other shells struck nearby as people tried to escape.
About 1,600 civilians had sought refuge from the fighting inside the building, Gunness said.
"The Israeli army knew exactly our GPS co-ordinates and they would have known that hundreds of people had taken shelter there," he said.
"When you have a direct hit into the third floor of a UN school, there has to be an investigation to see if a war crime has been committed."
Ban Ki-moon, the UN secretary-general, said: "I condemn in the strongest terms this outrageous attack, which is the third time it's happened.
"Top israeli leaders have apologised and assured me two days ago that UN premises would be fully respected.
"I strongly demand a thorough investigation and punishment for those responsible," he told reporters in Beirut.
John Ging, the director of Unrwa, told Al Jazeera: "People today are alleging war crimes here in Gaza. Let's have it properly accounted for. Let's have the legal process which will establish exactly what has happened here.
'A failure for humanity'
"It is another failure for our humanity and it is exposing the impotence of our [the international community's] inability to protect civilians in conflict."
In Jabaliya refugee camp, Dr Ezzedine Abu al-Aish, a Palestinian doctor from al-Shifa hospital, lost his three daughters and one niece during an Israeli air attack as he was being interviewed on an Israeli television channel.
At least 10 people were also killed late on Friday after a tank shell slammed into their home during a funeral wake in Gaza City.
More than 1,200 Palestinians have been killed in Israel's offensive, including more than 400 children, according to UN and Palestinian medical sources.
At least 13 Israelis have also died in the same period, three of them civilians.
About five rockets were reported to have been fired from Gaza into southern Israel on Saturday.