Exemplo n.º 1
0
 public static void ReleaseInstance(UnityEngine.Object go, bool releaseAsset = true)
 {
     if (go != 0)
     {
         int instanceID = go.GetInstanceID();
         UnityEngine.Object.Destroy(go);
         if (m_gameObjectNameMapping.ContainsKey(instanceID))
         {
             if (releaseAsset)
             {
                 m_assetMgr.Release(m_gameObjectNameMapping[instanceID]);
             }
             m_gameObjectNameMapping.Remove(instanceID);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 销毁资源实例。
 /// </summary>
 /// <param name="go">实例对象</param>
 public static void ReleaseInstance(Object go, bool releaseAsset = true)
 {
     if (go)
     {
         int guid = go.GetInstanceID();
         GameObject.Destroy(go);
         if (m_gameObjectNameMapping.ContainsKey(guid))
         {
             if (releaseAsset)
             {
                 m_assetMgr.Release(m_gameObjectNameMapping[guid]);
             }
             m_gameObjectNameMapping.Remove(guid);
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 销毁资源实例。
 /// </summary>
 /// <param name="go">实例对象</param>
 public static void ReleaseInstance(Object go, bool releaseAsset = true)
 {
     if (go)
     {
         int guid = go.GetInstanceID();
         GameObject.Destroy(go);
         if (m_gameObjectNameMapping.ContainsKey(guid))
         {
             if (releaseAsset)
             {
                 m_assetMgr.Release(m_gameObjectNameMapping[guid]);
             }
             m_gameObjectNameMapping.Remove(guid);
         }
         else
         {
             LoggerHelper.Warning("go not in mapping: " + go.name);
         }
     }
 }
    void OnGUI()
    {
        if (GUI.Button(new Rect(0, 0, 100, 100), "load npcs"))
        {
            var list = (loadAsset as LoadAssetBundlesMainAsset).m_filesDic.Keys.Where(t => t.StartsWith("NPC")).ToList();
            var name = list[index];
            Mogo.Util.LoggerHelper.Debug(name);

            loadAsset.LoadInstance(name, (a, b, c) =>
            {
                loadAsset.Release(name, false);
                //sw.Stop();
                //LoggerHelper.Debug(sw.ElapsedMilliseconds);
            });
            index++;
        }
        if (GUI.Button(new Rect(100, 0, 100, 100), "batching"))
        {
            StaticBatchingUtility.Combine(tempModel);
        }
        fileName = GUI.TextField(new Rect(300, 100, 300, 100), fileName);
        if (GUI.Button(new Rect(300, 0, 50, 50), "load"))
        {
            loadAsset.LoadInstance(fileName,
                                   (a, b, c) =>
            {
                //loadAsset.Release(fileName, false);
                tempModel = c as GameObject;
                //sw.Stop();
                //LoggerHelper.Debug(sw.ElapsedMilliseconds);
            },
                                   (progress) =>
            {
                Debug.Log(progress);
            });
        }
        if (GUI.Button(new Rect(350, 0, 50, 50), "load UI"))
        {
            loadAsset.LoadUIAsset(fileName, (a) =>
            {
                tempModel = GameObject.Instantiate(a) as GameObject;
                //loadAsset.Release(fileName, false);
                //sw.Stop();
                //LoggerHelper.Debug(sw.ElapsedMilliseconds);
            }, null);
        }
        if (GUI.Button(new Rect(200, 0, 100, 100), "load res"))
        {
            loadAsset.LoadAsset(fileName, (a) =>
            {
                tempModel = a as GameObject;
                //sw.Stop();
                //LoggerHelper.Debug(sw.ElapsedMilliseconds);
            });
        }

        if (GUI.Button(new Rect(400, 0, 100, 100), "unload"))
        {
            loadAsset.Release(fileName);
        }
        if (GUI.Button(new Rect(500, 0, 100, 100), "load scene"))
        {
            Application.LoadLevel(Utils.GetFileNameWithoutExtention(fileName));
        }
        if (GUI.Button(new Rect(600, 0, 100, 100), "ClearAll"))
        {
            ResourceManager.ClearAll();
        }
        if (GUI.Button(new Rect(600, 100, 100, 100), "UnloadUnused"))
        {
            Resources.UnloadUnusedAssets();
        }
        if (GUI.Button(new Rect(600, 200, 100, 100), "GC"))
        {
            System.GC.Collect();
        }
        if (GUI.Button(new Rect(400, 300, 100, 100), "set null"))
        {
            tempModel = null;
        }
        if (GUI.Button(new Rect(500, 300, 100, 100), "Instantiate"))
        {
            GameObject.Instantiate(tempModel);
        }
        if (GUI.Button(new Rect(600, 300, 100, 100), "tempPref"))
        {
            Debug.Log(tempModel);
        }
        if (GUI.Button(new Rect(300, 300, 100, 100), "show resources"))
        {
            Debug.Log(ResourceManager.resources.Values.ToList().PackList('\n'));
        }
        if (GUI.Button(new Rect(200, 300, 100, 100), "Load Meta"))
        {
            ResourceManager.LoadMetaOfMeta(() => { Debug.Log("Init META Success"); }, null);
        }
        if (GUI.Button(new Rect(100, 300, 100, 100), "GameDataControler Init"))
        {
            //LoggerHelper.Debug(FXData.dataMap.Count);
            //LoggerHelper.Debug(GlobalData.dataMap.Count);
            Mogo.GameData.GameDataControler.Init(null, () =>
            {
            });
        }
    }