using UnityEditor; using UnityEngine; namespace MantisLODEditor { [CustomEditor(typeof(ProgressiveMeshRuntime))] public class ProgressiveMeshRuntimeEditor : Editor { private ProgressiveMesh save_progressiveMesh = null; private bool show_advanced_options = true; override public void OnInspectorGUI() { DrawDefaultInspector(); var runtime = target as ProgressiveMeshRuntime; if(runtime) { // when the property changed if (runtime.progressiveMesh != save_progressiveMesh) { // clear the property if (runtime.progressiveMesh == null) { runtime.reset_all_parameters(); } else { // diffent property or mesh lod range not exists if (save_progressiveMesh != null || runtime.mesh_lod_range == null || runtime.mesh_lod_range.Length == 0) { runtime.reset_all_parameters(); int max_lod_count = runtime.progressiveMesh.triangles[0]; int mesh_count = runtime.progressiveMesh.triangles[1]; runtime.mesh_lod_range = new int[mesh_count*2]; for (int i=0; i 5.0f) runtime.updateInterval = 5.0f; EditorGUILayout.Space(); runtime.never_cull = EditorGUILayout.Toggle ("Never Cull", runtime.never_cull); GUILayout.Label( "The gameObject is alway visible or be culled when far away." , helpStyle , GUILayout.ExpandWidth(true)); runtime.cull_ratio = EditorGUILayout.FloatField("Cull Ratio", runtime.cull_ratio); if (!runtime.never_cull) { GUILayout.Label( "How far away will the gameObject be culled." , helpStyle , GUILayout.ExpandWidth(true)); } // clamp to valid range if (runtime.cull_ratio < 0.0f) runtime.cull_ratio = 0.0f; if (runtime.cull_ratio > 1.0f) runtime.cull_ratio = 1.0f; string[] options = new string[] { "Cull By Size", "Cull By Distance" }; runtime.lod_strategy = GUILayout.SelectionGrid(runtime.lod_strategy, options, 1, EditorStyles.radioButton); if (runtime.lod_strategy == 1) { runtime.disappear_distance = EditorGUILayout.FloatField("Disappear Distance", runtime.disappear_distance); GUILayout.Label( "How far away will the gameObject look like a tiny point." , helpStyle , GUILayout.ExpandWidth(true)); // clamp to valid range if (runtime.disappear_distance < 0.0f) runtime.disappear_distance = 0.0f; } // mesh lod range exists if (runtime.mesh_lod_range != null && runtime.mesh_lod_range.Length != 0) { for (int i=0; i max_lod_count-1) runtime.mesh_lod_range[i] = max_lod_count-1; } } } } } } }