示例#1
0
        // ###################################################################################################################
        // ############################ Methods used mostly by the Custom Editor classes #####################################
        // ###################################################################################################################

        public override void GenerateBiome()
        {
            MaterialTerrain bioMat = BiomeManager.GetMaterial(biome);

            bioMat.SetShaderType(WorldManager.worldInstance.shaderType);

            SplatPrototype[] splats = new SplatPrototype[1];
            splats[0]         = new SplatPrototype();
            splats[0].texture = (Texture2D)(bioMat.GetTexture("_Texture0"));
            terrain.terrainData.splatPrototypes = splats;

            if (WorldManager.worldInstance.shaderType == eShaderType.Shader_OriginalMode)
            {
                bioMat.material.SetFloat("_Transition1", terrain.terrainData.size[0] / 2);
                bioMat.material.SetFloat("_Transition2", terrain.terrainData.size[0] / 2);
                bioMat.material.SetInt("_TransitionType1", 0);
                bioMat.material.SetInt("_TransitionType2", 0);
                bioMat.material.SetFloat("_TransitionPos0", 0);
                bioMat.material.SetFloat("_TransitionPos1", 0);
                bioMat.material.SetFloat("_LimitMax", terrain.terrainData.size[0]);
            }
            bioMat.material.SetFloat("_MapHeight", terrain.terrainData.size[1]);
            bioMat.material.SetFloat("_MapSize", terrain.terrainData.size[0]);

            terrain.materialType     = Terrain.MaterialType.Custom;
            terrain.materialTemplate = (Material)Instantiate(bioMat.material);
        }
示例#2
0
 public void Init()
 {
     EditorWindow.GetWindow <BiomeSettingsWindow>();
     materialTerrain = BiomeManager.GetMaterial(0);
     manager         = AbstractManagerEditor.manager;
     biomeSelected   = BiomeManager.biomes.Count + 1;
 }
示例#3
0
        void DrawWindow()
        {
            EditorGUILayout.BeginHorizontal();
            {
                dynamicUpdate = GUILayout.Toggle(dynamicUpdate, "Dynamic update");

                if (manager.GetType() == typeof(WorldManager))
                {
                    string[] biomes_str = null; int[] biomes_int = null;
                    EditorUtils.Enum(ref biomes_str, ref biomes_int, BiomeManager.biomes.Count + 1, BiomeManager.biomes);

                    biomes_str[BiomeManager.biomes.Count] = "All";
                    biomes_int[BiomeManager.biomes.Count] = biomes_str.Length;

                    GUILayout.Label("Biome type");

                    biomeSelected = EditorGUILayout.IntPopup(biomeSelected, biomes_str, biomes_int);

                    if (biomeSelected != lastBiomeSelected)
                    {
                        lastBiomeSelected = biomeSelected;
                    }

                    if (GUILayout.Button("+"))
                    {
                        NewBiomeWindow.CreateInstance <NewBiomeWindow>().Init();
                    }
                }
                else
                {
                    biomeSelected = manager.GetComponent <TerrainManager>().biome;
                }


                MaterialTerrain matTerrain = BiomeManager.GetMaterial(biomeSelected);
                if (matTerrain != null && materialTerrain != null)
                {
                    materialTerrain = matTerrain;
                }
            }
            EditorGUILayout.EndHorizontal();

            if (materialTerrain == null)
            {
                return;
            }

            scrollpos = EditorGUILayout.BeginScrollView(scrollpos, GUILayout.Width(600), GUILayout.Height(500));
            BiomeSettingsInspector.Draw(materialTerrain);
            EditorGUILayout.EndScrollView();

            if (GUILayout.Button("Update changes"))
            {
                updateButton = true;
            }

            UpdateChanges();
        }
示例#4
0
 void OnGUI()
 {
     newbiome = EditorGUILayout.TextArea(newbiome);
     if (GUILayout.Button("Add"))
     {
         BiomeManager.CreateNewBiome(newbiome);
         Close();
     }
 }
        public void DrawTransitions()
        {
            // This lines are a trick for adjust the all material heights for getting a proper visuals transitions color
            int             biomeSelected = BiomeManager.biomes.Count + 1;
            MaterialTerrain material      = BiomeManager.GetMaterial(0);

            ChangeMaterialSettings(biomeSelected, material, material.GetMaterialSettingsFromShader());

            // Do the transition
            Utils.DrawTransitions();
        }
        void OnEnable()
        {
            terrainManager = (TerrainManager)target;

            AbstractManagerEditor.manager = terrainManager;

            biomeSelected     = terrainManager.biome;
            lastBiomeSelected = biomeSelected;

            if (terrainManager.terrain.materialTemplate == null)
            {
                Debug.LogError("You need generate biomes first");
            }

            materialTerrain = BiomeManager.GetMaterial(terrainManager.biome);

            defaultColor = GUI.color;
        }
        void Awake()
        {
            if (Application.isPlaying)
            {
                return;
            }

            worldInstance = this;

            ResourceLoader.LoadResources();
            BiomeManager.FillBiomeList();

            TerrainName = TerrainObjectName;

            terrainResolution = new TerrainResolution();

            nameScene = UnityEditor.EditorApplication.currentScene.Substring(UnityEditor.EditorApplication.currentScene.LastIndexOf("/") + 1);
            nameScene = nameScene.Substring(0, nameScene.IndexOf("."));
            Load(Paths.SavedWorlds + nameScene + ".data");
        }
示例#8
0
        void OnEnable()
        {
            worldManagerInspector = this;

            ResourceLoader.LoadResources();
            BiomeManager.FillBiomeList();
            FadeMenusManager.Clear();

            worldManager = (WorldManager)target;

            AbstractManagerEditor.manager = worldManager;

            _mySkin      = ResourceLoader.Skin1;
            defaultColor = GUI.color;


            FadeMenusManager.Add(FadeMenus.CreateInstance <NoiseFadeMenu>(), eFadeMenus.NOISE);
            FadeMenusManager.Add(FadeMenus.CreateInstance <WaterFadeMenu>(), eFadeMenus.WATER);
            FadeMenusManager.Add(FadeMenus.CreateInstance <SmoothTerrain>(), eFadeMenus.SMOOTH);
            FadeMenusManager.Add(FadeMenus.CreateInstance <SaveLoadFadeMenu>(), eFadeMenus.SAVELOAD);

            FadeMenusManager.SetMenusSkin(_mySkin);

            btBuild         = new PrettyButton("Build", -1);
            btBiomes        = new PrettyButton("GenerateBiomes", -1);
            btNoise         = new PrettyButton("ConfigureNoise", 1);
            btWater         = new PrettyButton("WaterSettings", 1);
            btSmooth        = new PrettyButton("SmoothTerrain", 1);
            btTransitions   = new PrettyButton("DrawTransitions", 1);
            btStitching     = new PrettyButton("StitchingChunks", 1);
            btBiomeSettings = new PrettyButton("BiomeSettings", 1);
            btGrassSettings = new PrettyButton("GrassSettings", 1);
            btReset         = new PrettyButton("ResetWorld", 1);
            btSaveLoad      = new PrettyButton("Save&Load", 1);


            TerrainResolutionInspector.SetManager(worldManager);
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (terrainManager.terrain.materialTemplate == null)
            {
                return;
            }

            string[] biomes_str = null;
            int[]    biomes_int = null;
            EditorUtils.Enum(ref biomes_str, ref biomes_int, BiomeManager.biomes.Count + 1, BiomeManager.biomes);

            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            if (WorldManagerInspector.worldManager.shaderType == eShaderType.Shader_OriginalMode)
            {
                GUILayout.Label("Biome type");

                biomeSelected = EditorGUILayout.IntPopup(biomeSelected, biomes_str, biomes_int);

                if (biomeSelected != lastBiomeSelected)
                {
                    MaterialTerrain newmat = BiomeManager.GetMaterial(biomeSelected);
                    if (newmat != null && materialTerrain != null)
                    {
                        materialTerrain      = newmat;
                        terrainManager.biome = biomeSelected;
                        terrainManager.GenerateBiome();
                    }
                }

                lastBiomeSelected = biomeSelected;
            }

            GUI.skin = ResourceLoader.Skin4;

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("BiomeSettings", GUILayout.Height(25f)))
            {
                var biomesWindow = BiomeSettingsWindow.CreateInstance <BiomeSettingsWindow>();
                biomesWindow.Init();
                biomesWindow.SetMaterial(materialTerrain);
            }
            if (GUILayout.Button("GrassSettings", GUILayout.Height(25f)))
            {
                var grassWindow = GrassSettingsWindow.CreateInstance <GrassSettingsWindow>();
                grassWindow.Init();
            }
            EditorGUILayout.EndHorizontal();

            if (WorldManagerInspector.worldManager.builded && WorldManagerInspector.worldManager.noised)
            {
                EditorUtils.ButtonPressed("SmoothTerrain", ref terrainManager.smoothTerrainFade, Color.green, defaultColor);
                FadeMenusManager.GetFadeMenu(eFadeMenus.SMOOTH).update(ref terrainManager.smoothTerrainFade);
            }

            if (WorldManager.worldInstance.shaderType == eShaderType.Shader_NoTransition)
            {
                return;
            }
        }