Ejemplo n.º 1
0
        public static KResoourceLoadedAssetDebugger Create(string type, string url, UnityEngine.Object theObject)
        {
            var newHelpGameObject = new GameObject(string.Format("LoadedObject-{0}-{1}", type, url));

            KDebuggerObjectTool.SetParent(bigType, type, newHelpGameObject);

            var newHelp = newHelpGameObject.AddComponent <KResoourceLoadedAssetDebugger>();

            newHelp.Type       = type;
            newHelp.TheObject  = theObject;
            newHelp.MemorySize = string.Format("{0:F5}KB",
#if UNITY_5_5
                                               UnityEngine.Profiling.Profiler.GetRuntimeMemorySize(theObject) / 1024f
#else
                                               UnityEngine.Profiling.Profiler.GetRuntimeMemorySize(theObject) / 1024f
#endif
                                               );
            return(newHelp);
        }
Ejemplo n.º 2
0
        public static KResourceLoaderDebugger Create(string type, string url, AbstractResourceLoader loader)
        {
            if (IsApplicationQuit)
            {
                return(null);
            }

            const string bigType = "ResourceLoaderDebuger";

            Func <string> getName = () => string.Format("{0}-{1}-{2}", type, url, loader.Desc);

            var newHelpGameObject = new GameObject(getName());

            KDebuggerObjectTool.SetParent(bigType, type, newHelpGameObject);
            var newHelp = newHelpGameObject.AddComponent <KResourceLoaderDebugger>();

            newHelp.TheLoader = loader;

            loader.SetDescEvent += (newDesc) =>
            {
                if (loader.RefCount > 0)
                {
                    newHelpGameObject.name = getName();
                }
            };

            loader.DisposeEvent += () =>
            {
                if (!IsApplicationQuit)
                {
                    KDebuggerObjectTool.RemoveFromParent(bigType, type, newHelpGameObject);
                }
            };

            return(newHelp);
        }