blob: 00c30c217e00fa18c66b219aeb1020cee32298b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#include "UnityPrefix.h"
#include "SceneUnloading.h"
#include "SaveAndLoadHelper.h"
#include "GameObjectUtility.h"
#include "Runtime/BaseClasses/ManagerContext.h"
#include "Runtime/BaseClasses/ManagerContextLoading.h"
#include "Runtime/BaseClasses/GameManager.h"
#include "Runtime/Profiler/Profiler.h"
#include "Runtime/Profiler/TimeHelper.h"
#include "Runtime/Core/Callbacks/GlobalCallbacks.h"
PROFILER_INFORMATION (gUnloadScene, "UnloadScene", kProfilerLoading);
void SharkBeginRemoteProfiling ();
void SharkEndRemoteProfiling ();
void UnloadGameScene ()
{
ABSOLUTE_TIME begin = START_TIME;
// SharkBeginRemoteProfiling ();
PROFILER_AUTO(gUnloadScene, NULL)
InstanceIDArray objects;
CollectSceneGameObjects (objects);
Object* o;
// GameObjects first
for (InstanceIDArray::iterator i=objects.begin ();i != objects.end ();++i)
{
o = Object::IDToPointer (*i);
AssertIf (o && o->IsPersistent ());
GameObject* go = dynamic_pptr_cast<GameObject*> (o);
// Only Destroy root level GameObjects. The children will be destroyed
// as part of them. That way, we ensure that the hierarchy is walked correctly,
// and all objects in the hieararchy will be marked as deactivated when destruction happens.
if (go != NULL && go->GetComponent(Transform).GetParent() == NULL)
DestroyObjectHighLevel (o);
}
// normal objects whatever they might be after that
for (InstanceIDArray::iterator i=objects.begin ();i != objects.end ();++i)
{
o = Object::IDToPointer (*i);
AssertIf (o && o->IsPersistent ());
DestroyObjectHighLevel (o);
}
objects.clear ();
CollectLevelGameManagers (objects);
// Gamemanagers & Scene last
for (InstanceIDArray::iterator i=objects.begin ();i != objects.end ();++i)
{
o = Object::IDToPointer (*i);
AssertIf (o && o->IsPersistent ());
DestroyObjectHighLevel (o);
}
GlobalCallbacks::Get().didUnloadScene.Invoke();
ValidateNoSceneObjectsAreLoaded ();
printf_console("UnloadTime: %f ms\n", AbsoluteTimeToMilliseconds(ELAPSED_TIME(begin)));
// SharkEndRemoteProfiling ();
}
|