예제 #1
0
        public static void Cleanup()
        {
            m_Env   = null;
            m_Light = null;
            cmdBuffer.Clear();
            //for (int i = 0; i < m_LoadingObjectList.Count; i++)
            //	m_LoadingObjectList[i].doRelease = true;
            m_LoadingObjectList.Clear();
            for (int i = 0; i < m_LoadedObjectList.Count; i++)
            {
                if (!ResourceManager.UnloadPrefab(m_LoadedObjectList[i]))
                {
                    GameObject.Destroy(m_LoadedObjectList[i]);
                }
            }

            m_LoadedObjectList.Clear();
            if (m_CurrentElements)
            {
                ResourceManager.UnloadAsset(m_CurrentElements);
                m_CurrentElements = null;
            }
            if (m_CurrentEnv)
            {
                ResourceManager.UnloadAsset(m_CurrentEnv);
                m_CurrentEnv = null;
            }
            Name = null;
        }
예제 #2
0
        public static async void LoadMapInternal(XLua.LuaTable precess, string mapName, Action callback = null)
        {
            m_Env   = GameObject.Find("Env");
            m_Light = GameObject.Find("Sun").GetComponent <Light>();
            //1.加载场景信息
            string        InfoPath = $"Assets/Art/Scenes/{mapName}/{mapName}/sceneenv.asset";
            SceneEnvAsset env      = await ResourceManager.LoadAsset(InfoPath) as SceneEnvAsset;

            string ElementPath = $"Assets/Art/Assets/Scene/{mapName}/{mapName}.asset";
            //2.加载地形
            SceneElementAsset sceneElements = await ResourceManager.LoadAsset(ElementPath) as SceneElementAsset;

            List <GameObject> list = await MapManager.LoadPreElement(sceneElements);

            m_CurrentEnv      = env;
            m_CurrentElements = sceneElements;
            m_LoadedObjectList.AddRange(list);
            callback?.Invoke();
            //4.优先展示出来基本的灯光、草的环境
            Show(true);
            Name = mapName;
            //5.最后去异步加载出来场景中的元素
            AddSceneElements();


            ////3.如果是野外场景需要动态生成导航网格,战斗场景和UI场景不需要
            //if (env.sceneType == SceneType.Wild)
            //{
            //	LocalNavMeshLoading.Instance.UpdateNavMesh(true);
            //	Debug.Log($"[C#] SceneTree.cs ::load({mapName}) 展示基本灯光、草后开启异步加载场景元素并开始异步烘焙导航网格");
            //}

            callback?.Invoke();
            //加载完成, 通知lua
            precess.Set("IsDone", true);
            precess.Set("proess", 1);
        }