Пример #1
0
        public override void OnInspectorGUI()
        {
            _unityTerrain = (UnityTerrain)target;

            OverrideLogoTextureName = "Banner_UnityTerrain";
            base.OnInspectorGUI();

            EditorGUILayout.HelpBox("The Unity Terrain component implements the interface needed and communication with the Vegetation System Pro component. ", MessageType.Info);
            EditorGUI.BeginChangeCheck();
            GUILayout.BeginVertical("box");
            //_unityTerrain.AutoAddToVegegetationSystem = EditorGUILayout.Toggle("Add/Remove at Enable/Disable", _unityTerrain.AutoAddToVegegetationSystem);
            EditorGUILayout.PropertyField(_autoAddToVegegetationSystemProp, new GUIContent("Add/Remove at Enable/Disable"));
            EditorGUILayout.HelpBox("When set the terrain will add and remove itself when enabled/disabled. This will only work if automatic area calculation is disabled on the VegetationSystem. This is only done in playmode and builds", MessageType.Info);
            //_unityTerrain.ApplyFloatingOriginOffset =  EditorGUILayout.Toggle("Apply floating origin at enable.", _unityTerrain.ApplyFloatingOriginOffset);
            //EditorGUILayout.HelpBox("Disable this if the loaded terrain is instantiated at original location and then moved to match floating origin.", MessageType.Info);
            GUILayout.EndVertical();
            if (EditorGUI.EndChangeCheck())
            {
                SetSceneDirty();
            }

            GUILayout.BeginVertical("box");
            EditorGUI.BeginDisabledGroup(true);
            //EditorGUILayout.Vector3Field("Terrain position", _unityTerrain.TerrainPosition);
            EditorGUILayout.PropertyField(_terrainPositionProp, new GUIContent("Terrain position"));
            EditorGUI.EndDisabledGroup();
            GUILayout.EndVertical();

            GUILayout.BeginVertical("box");
            EditorGUILayout.PropertyField(_autoAddToVegegetationSystemProp, new GUIContent("Disable Unity trees/details"));
            EditorGUILayout.HelpBox("When enabled this will disable Unity trees and details at startup", MessageType.Info);
            GUILayout.EndVertical();

            EditorGUI.BeginChangeCheck();
            GUILayout.BeginVertical("box");
            //_unityTerrain.TerrainSourceID = (TerrainSourceID)EditorGUILayout.EnumPopup("Terrain Source ID", _unityTerrain.TerrainSourceID);
            EditorGUILayout.PropertyField(_terrainSourceIDProp, new GUIContent("Terrain Source ID"));
            EditorGUILayout.HelpBox("The Terrain Source ID can be set different on each terrain and used for spawning rules.", MessageType.Info);

            GUILayout.EndVertical();

            if (EditorGUI.EndChangeCheck())
            {
                _unityTerrain.RefreshTerrainArea();
                SetSceneDirty();
            }

            serializedObject.ApplyModifiedProperties();
        }
Пример #2
0
        public void AddAllUnityTerrains()
        {
            Terrain[] terrains = FindObjectsOfType <Terrain>();

            List <GameObject> terrainList = new List <GameObject>();

            for (int i = 0; i <= terrains.Length - 1; i++)
            {
                UnityTerrain unityTerrain = terrains[i].gameObject.GetComponent <UnityTerrain>();
                if (!unityTerrain)
                {
                    terrains[i].gameObject.AddComponent <UnityTerrain>();
                }

                terrainList.Add(terrains[i].gameObject);
            }

            AddTerrains(terrainList);
        }