Beispiel #1
0
        public static LoadedAssetDebugger Create(string type, string uniqueKey, Object theObject)
        {
            if (BaseLoaderDebugger.IsApplicationQuit)
            {
                return(null);
            }

            //simplified uniqueKey
            uniqueKey = uniqueKey.Replace(AssetConfig.GetWritablePath(), "").Replace(AssetConfig.GetStreamingAssetsPath(), "").Replace(AssetConfig.GameAssetsFolder, "");

            // create a LoadedAssetDebugger
            GameObject newHelpGameObject = new GameObject(uniqueKey);
            var        newHelp           = newHelpGameObject.AddComponent <LoadedAssetDebugger>();

            newHelp.type       = type;
            newHelp.theObject  = theObject;
            newHelp.memorySize = string.Format("{0:F5}KB",
#if UNITY_2018_1_OR_NEWER
                                               UnityEngine.Profiling.Profiler.GetRuntimeMemorySizeLong(theObject) / 1024f
#elif UNITY_5_5 || UNITY_2017_1_OR_NEWER
                                               UnityEngine.Profiling.Profiler.GetRuntimeMemorySize(theObject) / 1024f
#else
                                               UnityEngine.Profiler.GetRuntimeMemorySize(theObject) / 1024f
#endif
                                               );

            // add to hierarchy
            DebuggerObjectTool.SetParent(bigType, type, newHelpGameObject);

            return(newHelp);
        }
Beispiel #2
0
        public static BaseLoaderDebugger Create(string type, string uniqueKey, BaseLoader loader)
        {
            if (IsApplicationQuit)
            {
                return(null);
            }

            //simplified uniqueKey
            uniqueKey = uniqueKey.Replace(AssetConfig.GetWritablePath(), "").Replace(AssetConfig.GetStreamingAssetsPath(), "").Replace(AssetConfig.GameAssetsFolder, "");

            // create a BaseLoaderDebugger
            GameObject newHelpGameObject = new GameObject(uniqueKey);
            var        newHelp           = newHelpGameObject.AddComponent <BaseLoaderDebugger>();

            newHelp.loader = loader;

            loader.DisposeEvent += () =>
            {
                DebuggerObjectTool.RemoveFromParent(bigType, type, newHelpGameObject);
            };

            // add to hierarchy
            DebuggerObjectTool.SetParent(bigType, type, newHelpGameObject);

            return(newHelp);
        }