2020-10-28 20:52:40 +11:00
|
|
|
|
using System;
|
2020-11-03 20:59:13 +11:00
|
|
|
|
using UnityExplorer.Helpers;
|
|
|
|
|
using UnityExplorer.UI.Main;
|
2020-10-09 21:11:15 +11:00
|
|
|
|
using UnityEngine;
|
2020-10-10 20:19:56 +11:00
|
|
|
|
using UnityEngine.SceneManagement;
|
2020-10-09 21:11:15 +11:00
|
|
|
|
|
2020-11-03 20:59:13 +11:00
|
|
|
|
namespace UnityExplorer.Unstrip.Scenes
|
2020-10-09 21:11:15 +11:00
|
|
|
|
{
|
|
|
|
|
public class SceneUnstrip
|
|
|
|
|
{
|
2020-11-02 20:48:53 +11:00
|
|
|
|
#if MONO
|
2020-10-28 20:52:40 +11:00
|
|
|
|
public static GameObject[] GetRootGameObjects(Scene scene) => scene.GetRootGameObjects();
|
|
|
|
|
|
|
|
|
|
public static GameObject[] GetRootGameObjects(int handle)
|
|
|
|
|
{
|
2020-11-03 20:59:13 +11:00
|
|
|
|
Scene scene = default;
|
|
|
|
|
if (handle == SceneExplorer.DontDestroyHandle)
|
|
|
|
|
scene = SceneExplorer.DontDestroyObject.scene;
|
|
|
|
|
else
|
2020-10-28 20:52:40 +11:00
|
|
|
|
{
|
2020-11-03 20:59:13 +11:00
|
|
|
|
for (int i = 0; i < SceneManager.sceneCount; i++)
|
|
|
|
|
{
|
|
|
|
|
var iscene = SceneManager.GetSceneAt(i);
|
|
|
|
|
if (iscene.handle == handle)
|
|
|
|
|
scene = iscene;
|
|
|
|
|
}
|
2020-10-28 20:52:40 +11:00
|
|
|
|
}
|
2020-11-03 20:59:13 +11:00
|
|
|
|
|
|
|
|
|
if (scene != default && scene.handle != -1)
|
|
|
|
|
return scene.GetRootGameObjects();
|
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
return new GameObject[0];
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-10 20:19:56 +11:00
|
|
|
|
//Scene.GetRootGameObjects();
|
2020-11-02 20:48:53 +11:00
|
|
|
|
#endif
|
2020-10-16 19:40:01 +11:00
|
|
|
|
|
2020-10-28 20:52:40 +11:00
|
|
|
|
#if CPP
|
2020-10-16 19:40:01 +11:00
|
|
|
|
internal delegate void d_GetRootGameObjects(int handle, IntPtr list);
|
|
|
|
|
|
2020-10-27 00:54:08 +11:00
|
|
|
|
public static GameObject[] GetRootGameObjects(Scene scene) => GetRootGameObjects(scene.handle);
|
|
|
|
|
|
|
|
|
|
public static GameObject[] GetRootGameObjects(int handle)
|
2020-10-09 21:11:15 +11:00
|
|
|
|
{
|
2020-10-27 00:54:08 +11:00
|
|
|
|
if (handle == -1)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2020-10-27 00:54:08 +11:00
|
|
|
|
return new GameObject[0];
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
2020-10-27 00:54:08 +11:00
|
|
|
|
|
2020-10-28 06:39:26 +11:00
|
|
|
|
Il2CppSystem.Collections.Generic.List<GameObject> list = new Il2CppSystem.Collections.Generic.List<GameObject>(GetRootCount(handle));
|
2020-10-16 19:40:01 +11:00
|
|
|
|
|
2020-10-28 06:39:26 +11:00
|
|
|
|
d_GetRootGameObjects iCall = ICallHelper.GetICall<d_GetRootGameObjects>("UnityEngine.SceneManagement.Scene::GetRootGameObjectsInternal");
|
2020-10-09 21:11:15 +11:00
|
|
|
|
|
2020-10-27 00:54:08 +11:00
|
|
|
|
iCall.Invoke(handle, list.Pointer);
|
2020-10-09 21:11:15 +11:00
|
|
|
|
|
|
|
|
|
return list.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-10 20:19:56 +11:00
|
|
|
|
//Scene.rootCount;
|
|
|
|
|
|
|
|
|
|
internal delegate int GetRootCountInternal_delegate(int handle);
|
2020-10-16 19:40:01 +11:00
|
|
|
|
|
2020-10-27 00:54:08 +11:00
|
|
|
|
public static int GetRootCount(Scene scene) => GetRootCount(scene.handle);
|
|
|
|
|
|
|
|
|
|
public static int GetRootCount(int handle)
|
2020-10-16 19:40:01 +11:00
|
|
|
|
{
|
2020-10-28 06:39:26 +11:00
|
|
|
|
GetRootCountInternal_delegate iCall = ICallHelper.GetICall<GetRootCountInternal_delegate>("UnityEngine.SceneManagement.Scene::GetRootCountInternal");
|
2020-10-27 00:54:08 +11:00
|
|
|
|
return iCall.Invoke(handle);
|
2020-10-16 19:40:01 +11:00
|
|
|
|
}
|
2020-10-28 20:52:40 +11:00
|
|
|
|
#endif
|
2020-10-09 21:11:15 +11:00
|
|
|
|
}
|
2020-10-28 20:52:40 +11:00
|
|
|
|
}
|