Пример #1
0
 public void DestroyCombinedLODManager()
 {
     combinedLODManager = GetComponent <CombinedLODManager>();
     if (combinedLODManager != null)
     {
         DestroyImmediate(combinedLODManager);
     }
 }
Пример #2
0
        } // ==========================================================================================================================

        public void AddCombinedLODManager()
        {
            combinedLODManager = GetComponent <CombinedLODManager>();
            if (combinedLODManager == null)
            {
                combinedLODManager = gameObject.AddComponent <CombinedLODManager>();
            }

            combinedLODManager.UpdateLods(this, lodAmount);
        }
Пример #3
0
        public void CombineLods()
        {
            DestroyCombinedGameObjects();
            if (!octreeCreated || combined)
            {
                AddToOctree();
            }
            if (!octreeCreated)
            {
                return;
            }
            if (newVertices == null)
            {
                InitLists();
            }
            // if (octree == null) Debug.Log("Octree is null");

            for (int i = 0; i < lodAmount; i++)
            {
                Combine(i);
            }

            if (lodAmount > 1)
            {
                if (combinedLODManager == null)
                {
                    combinedLODManager = gameObject.AddComponent <CombinedLODManager>();
                }
                combinedLODManager.lods      = new CombinedLODManager.LOD[lodAmount];
                combinedLODManager.distances = new float[lodAmount];

                for (int i = 0; i < lodAmount; i++)
                {
                    combinedLODManager.lods[i]      = new CombinedLODManager.LOD(combinedList[i]);
                    combinedLODManager.distances[i] = i * cellSize;
                }

                combinedLODManager.ResetOctree();
                combinedLODManager.octreeCenter = octree.bounds.center;
                combinedLODManager.octreeSize   = octree.bounds.size;
                combinedLODManager.maxLevels    = octree.maxLevels;
            }

            combinedActive = true;
            combined       = true;

            GarbageCollectLists();
        } // ==========================================================================================================================
Пример #4
0
        public override void OnInspectorGUI()
        {
            // DrawDefaultInspector();
            CombinedLODManager combinedLODManager = (CombinedLODManager)target;

            serializedObject.Update();

            GUI.color = Color.yellow * editorSkinMulti;
            EditorGUILayout.BeginVertical("Box");
            GUI.color = Color.white;

            GUIDraw.LabelWidthUnderline(new GUIContent("LOD Settings", ""), 14);

            EditorGUILayout.PropertyField(drawGizmos);
            EditorGUILayout.PropertyField(lodMode);
            GUI.changed = false;
            EditorGUILayout.PropertyField(lodDistanceMode);
            if (GUI.changed)
            {
                MeshCombiner meshCombiner = combinedLODManager.GetComponent <MeshCombiner>();
                if (meshCombiner != null)
                {
                    serializedObject.ApplyModifiedProperties();
                    combinedLODManager.UpdateDistances(meshCombiner);
                    return;
                }
            }

            EditorGUILayout.PropertyField(lodCulled);
            if (lodCulled.boolValue)
            {
                EditorGUILayout.PropertyField(lodCullDistance);
                if (lodCullDistance.floatValue < 0)
                {
                    lodCullDistance.floatValue = 0;
                }
            }

            if (lodMode.enumValueIndex == 1)
            {
                EditorGUILayout.PropertyField(showLod);
                if (showLod.intValue < 0)
                {
                    showLod.intValue = 0;
                }
                if (showLod.intValue >= distances.arraySize)
                {
                    showLod.intValue = distances.arraySize - 1;
                }
            }
            else
            {
                GUI.changed = false;
                GUIDraw.PropertyArray(distances, new GUIContent(""), false, false);
                if (GUI.changed)
                {
                    lodDistanceMode.enumValueIndex = 1;
                }

                if (distanceElements == null || distanceElements.Length != distances.arraySize)
                {
                    distanceElements = new SerializedProperty[distances.arraySize];
                }

                for (int i = 0; i < distances.arraySize; i++)
                {
                    distanceElements[i] = distances.GetArrayElementAtIndex(i);
                    if (i == 0)
                    {
                        distanceElements[i].floatValue = 0;
                    }
                    else if (distanceElements[i].floatValue < distanceElements[i - 1].floatValue)
                    {
                        distanceElements[i].floatValue = distanceElements[i - 1].floatValue + 0.1f;
                    }
                }
            }


            EditorGUILayout.EndVertical();

            serializedObject.ApplyModifiedProperties();
        }