public override void OnInspectorGUI() { base.OnInspectorGUI(); HLODCull hlodCull = (HLODCull)target; if (hlodCull.m_RootVolume == null) { hlodCull.m_RootVolume = hlodCull.GetComponent <LODVolume>(); } }
/*流式操作*/ void GenerateStreamingLoad(HLODGenerate hlodGenerate) { if (hlodGenerate.m_RootLODVolume) { HLODCull hlodCull = hlodGenerate.m_RootLODVolume.GetComponent <HLODCull>(); if (hlodCull) { hlodCull.m_Stream = hlodGenerate.m_IsStreaming; } } if (!hlodGenerate.m_IsExportMatTex || !hlodGenerate.m_IsExportMesh) { return; } GUILayout.BeginVertical(); do { GUILayout.BeginHorizontal(); GUILayout.Label("Streming路径:"); GUILayout.Label(hlodGenerate.m_StreamingAssetPath + "\\" + s_StreamingDirectory); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (hlodGenerate.m_IsStreaming && hlodGenerate.StreamUpdate.Count > 0 && GUILayout.Button("更新")) { string savePath = Path.Combine(hlodGenerate.m_StreamingAssetPath, s_StreamingDirectory); foreach (var lv in hlodGenerate.StreamUpdate) { GeneratePrefab(lv, savePath); } hlodGenerate.StreamUpdate.Clear(); GenrateFineModelRef(hlodGenerate.m_RootLODVolume.GetComponent <LODVolume>()); } if (hlodGenerate.m_IsStreaming) { GUILayout.BeginHorizontal(); m_DeleteStreamingAsset = GUILayout.Toggle(m_DeleteStreamingAsset, "同时删除流式资源"); if (GUILayout.Button("退回")) { hlodGenerate.ComeBackInMemory(this); hlodGenerate.m_IsStreaming = false; EditorUtility.SetDirty(hlodGenerate.gameObject); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } GUILayout.EndHorizontal(); EditorGUILayout.HelpBox("Streaming已生成", MessageType.Info); break; } GUILayout.BeginHorizontal(); if (GUILayout.Button("路径选择")) { string path = EditorUtility.OpenFolderPanel("Save HLODsStreaming to....", Application.dataPath, ""); path = path.Replace(Application.dataPath, "Assets"); path = path.Replace("/", "\\"); hlodGenerate.m_StreamingAssetPath = path; } if (hlodGenerate.m_StreamingAssetPath != "" && GUILayout.Button("导出")) { hlodGenerate.m_IsStreaming = true; UpdataStreamingAsset(hlodGenerate); hlodGenerate.StreamUpdate.Clear(); EditorUtility.SetDirty(hlodGenerate.gameObject); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } GUILayout.EndHorizontal(); } while (false); GUILayout.EndVertical(); }
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())); } }