コード例 #1
0
        //GameObject异步加载资源ResourceItem成功后的回调
        private void OnAsyncLoadGameObjectFinish(string path, GameObjectItem gameObjectItem,
                                                 object param1 = null, object param2 = null, object param3 = null)
        {
            if (gameObjectItem == null)
            {
                return;
            }
            if (gameObjectItem.ResourceItem.Obj == null)
            {
#if UNITY_EDITOR
                Debug.Log("异步资源加载的资源为空: " + path);
#endif
            }
            else
            {
                gameObjectItem.Obj = GameObject.Instantiate(gameObjectItem.ResourceItem.Obj) as GameObject;
            }
            if (gameObjectItem.Obj != null && gameObjectItem.SetSceneParent)
            {
                gameObjectItem.Obj.transform.SetParent(m_sceneGos, false);
            }
            if (gameObjectItem.DealFinishCallback != null)
            {
                gameObjectItem.DealFinishCallback(path, gameObjectItem.Obj,
                                                  gameObjectItem.Param1, gameObjectItem.Param2, gameObjectItem.Param3);
            }
        }
コード例 #2
0
        //GameObject异步加载资源ResourceItem成功后的回调
        private void OnAsyncLoadGameObjectFinish(string path, GameObjectItem gameObjectItem,
                                                 object param1 = null, object param2 = null, object param3 = null)
        {
            if (gameObjectItem == null)
            {
                return;
            }
            if (gameObjectItem.ResourceItem.Obj == null)
            {
#if UNITY_EDITOR
                Debug.LogError("异步资源加载的资源为空: " + path);
#endif
            }
            else
            {
                gameObjectItem.Obj         = GameObject.Instantiate(gameObjectItem.ResourceItem.Obj) as GameObject;
                gameObjectItem.OfflineData = gameObjectItem.Obj.GetComponent <OfflineData>();
            }
            //加载完成, 就从正在加载的异步中移除
            if (m_asyncGameObjectItemDict.ContainsKey(gameObjectItem.Guid))
            {
                m_asyncGameObjectItemDict.Remove(gameObjectItem.Guid);
            }
            if (gameObjectItem.Obj != null && gameObjectItem.SetSceneParent)
            {
                gameObjectItem.Obj.transform.SetParent(m_sceneGos, false);
            }
            if (gameObjectItem.DealFinishCallback != null)
            {
                int guid = gameObjectItem.Obj.GetInstanceID();
                if (!m_gameObjectItemDict.ContainsKey(guid))
                {
                    m_gameObjectItemDict.Add(guid, gameObjectItem);
                }
                gameObjectItem.DealFinishCallback(path, gameObjectItem.Obj,
                                                  gameObjectItem.Param1, gameObjectItem.Param2, gameObjectItem.Param3);
            }
        }