[펌] Find objects with DontDestroyOnLoad
The saved objects are handled on the native side, and there is no way I know of to hook into that side of Unity.
As an aside, here's an example of using an extension to track such a quality:
I would create a an extension for Object which stores all saved objects, something like this:
- public static class ObjectExtension {
- private static List<Object> savedObjects = new List<Object>();
- public static void DontDestroyOnLoad(this Object obj){
- savedObjects.Add(obj);
- Object.DontDestroyOnLoad(obj);
- }
- public static void Destory(this Object obj){
- savedObjects.Remove(obj);
- Destory(obj);
- }
- public static List<Objects> GetSavedObjects(){
- return new List<Objects>(savedObjects);
- }
- }
Now, to save the object you'll have to use this.DontDestroyOnLoad(); instead of the normal DontDestroyOnLoad(this);
EDIT:
I started looking into this and found that setting a GameObject's hideflags to HideFlags.DontSave means (as far as I can tell) the same thing as DontDestroyOnLoad, except that none of Unity's functions (Update, etc.) are called. The one with hideflags might also leak if not destroyed manually...
Finding GameObjects with its hideFlags set to DontSave is trivial.
[출처] https://answers.unity.com/questions/544886/find-objects-with-dontdestroyonload.html
'Unity3D > Extensions' 카테고리의 다른 글
[링크] Unity - Dictionary 를 Inspector 에 간단하게.. (0) | 2023.08.03 |
---|---|
[펌] Unity – How to copy a string to Clipboard (0) | 2022.07.19 |
[Unity] Play Streaming Music From Server (0) | 2018.02.06 |
[펌] ADDING TO UNITY'S BUILT-IN CLASSES USING EXTENSION METHODS (0) | 2016.10.20 |
일괄적으로 Texture Import Setting 변경 (0) | 2015.01.30 |