Пример #1
0
        /*生成SceneLOD接口,指定hlodGenerate*/
        public void GenerateSceneLODByHLODGenerate(HLODGenerate hlodGenerate, Action <GameObject, GameObject> endCall = null)
        {
            m_CurrHLODGenerate = hlodGenerate;
#if UNITY_EDITOR
            if (hlodGenerate.m_RootLODVolume)
            {
                m_RootVolume = hlodGenerate.m_RootLODVolume.GetComponent <LODVolume>();
            }
            else
            {
                m_RootVolume = null;
            }
            m_CreateRootVolumeForScene = SceneManager.GetActiveScene().name;
            MonoBehaviourHelper.StartCoroutine(GenerateHLOD(hlodGenerate.m_Targets, endCall));
#endif
        }
Пример #2
0
        public static void PersistHLODOfFbx(Transform hlodRoot, string savePath)
        {
            if (hlodRoot)
            {
                if (string.IsNullOrEmpty(AssetDatabase.GetAssetPath(hlodRoot)))
                {
                    //SaveUniqueHLODAssetOfFbx(hlodRoot, savePath);
                    MonoBehaviourHelper.StartCoroutine(SaveUniqueHLODAssetOfFbx(hlodRoot, savePath));
                }
            }

            foreach (Transform child in hlodRoot.transform)
            {
                PersistHLODOfFbx(child, savePath);
            }
        }
Пример #3
0
        IEnumerator GenerateHLOD(GameObject[] gameObjects = null, Action <GameObject, GameObject> endCall = null)
        {
            m_CoroutineQueue.Enqueue(UpdateOctreeByLodGroup(gameObjects));

            s_endCall = endCall;

            yield return(MonoBehaviourHelper.StartCoroutine(m_CoroutineQueue.Dequeue()));

            while (m_RootVolume == null)
            {
                yield return(null);
            }

            #if UNITY_EDITOR
            if (m_RootVolume && m_RootVolume.dirty)
            {
                GameObject hlods = null;
                if (m_CurrHLODGenerate != null)//更新
                {
                    hlods = m_CurrHLODGenerate.m_HLODS;
                }
                if (!hlods)//创建
                {
                    hlods = new GameObject("RootHLOD");
                }

                m_CoroutineQueue.Enqueue(m_RootVolume.CheckAfterBVHUpdata(m_CurrHLODGenerate.m_BVHDivide.m_MaximunLayer));
                m_CoroutineQueue.Enqueue(m_RootVolume.UpdateHLODs(m_CurrHLODGenerate.m_BVHDivide.m_MaximunLayer, hlods));


                m_CoroutineQueue.Enqueue(m_RootVolume.UpdateRootVolume((List <LODVolume> backList) => {
                    HLODCull hlodCull = m_RootVolume.GetComponent <HLODCull>();
                    if (!m_RootVolume.GetComponent <HLODCull>())
                    {
                        hlodCull = m_RootVolume.gameObject.AddComponent <HLODCull>();
                        Selection.activeGameObject = hlodCull.gameObject;
                    }
                    hlodCull.m_BackSort = backList;
                    EditorUtility.ClearProgressBar();
                    EditorUtility.SetDirty(m_RootVolume);
                    AssetDatabase.SaveAssets();
                    AssetDatabase.Refresh();
                    EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene());
                    //AutoLOD.sceneLODEnabled = false;

                    if (s_endCall != null)
                    {
                        s_endCall.Invoke(m_RootVolume.gameObject, hlods.gameObject);
                    }
                }));
            }
            else
            {
                EditorUtility.ClearProgressBar();
                if (s_endCall != null)
                {
                    s_endCall.Invoke(null, null);
                }
            }
#endif
            while (m_CoroutineQueue.Count > 0)
            {
                yield return(MonoBehaviourHelper.StartCoroutine(m_CoroutineQueue.Dequeue()));
            }
        }