public void Init() { EditorWindow.GetWindow <BiomeSettingsWindow>(); materialTerrain = BiomeManager.GetMaterial(0); manager = AbstractManagerEditor.manager; biomeSelected = BiomeManager.biomes.Count + 1; }
// ################################################################################################################### // ############################ 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); }
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(); }
public override void ChangeMaterialSettings(int biome, MaterialTerrain material, MaterialTerrain.MaterialSettings settings) { material.SetMaterialSettingsToShader(settings); foreach (Chunk chunk in _chunks) { var terrainManager = chunk.chunkTerrain.GetComponent <TerrainManager>(); terrainManager.ChangeMaterialSettings(biome, material, settings); } }
public static void CreateNewBiome(string name) { MaterialTerrain materialTerrain = new MaterialTerrain(name); //string shader = (WorldManager.worldInstance.shaderType == eShaderType.Shader_OriginalMode ? PATHS.MyCustomShader : PATHS.MyCustomShader_NoTransition); //Material material = new Material(Shader.Find(shader)); // //UnityEditor.AssetDatabase.CreateAsset(material, PATHS.BiomeMaterials + newbiome + "Material.mat"); biomes.Add(new Biome(name, materialTerrain)); }
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(); }
public void SetMaterial(MaterialTerrain material) { thisMaterial = material; /*btp0 = ResourceLoader.ButtomTexturePosition0; * btp1 = ResourceLoader.ButtomTexturePosition1; * btp2 = ResourceLoader.ButtomTexturePosition2; * btp3 = ResourceLoader.ButtomTexturePosition3; * btp4 = ResourceLoader.ButtomTexturePosition4;*/ btt0 = ResourceLoader.ButtomTextureType0; btt1 = ResourceLoader.ButtomTextureType1; btt2 = ResourceLoader.ButtomTextureType2; btt3 = ResourceLoader.ButtomTextureType3; _mySkin = ResourceLoader.Skin1; }
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; }
public override void ChangeMaterialSettings(int biome, MaterialTerrain material, MaterialTerrain.MaterialSettings settings) { if (chunk.chunkTerrain.materialTemplate == null) { return; } if (chunk.chunkTerrain.materialTemplate.name.Contains(material.name) || biome == BiomeManager.biomes.Count + 1) { MaterialTerrain newMat = new MaterialTerrain(chunk.chunkTerrain.materialTemplate); if (biome == BiomeManager.biomes.Count + 1) { newMat.withoutTextures = true; } newMat.SetMaterialSettingsToShader(settings); newMat.withoutTextures = false; chunk.chunkTerrain.materialTemplate = newMat.material; } }
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; } }
//public void SetMaterial(Material material) //{ // this.material = material; //} public void SetMaterial(MaterialTerrain materialTerrain) { this.materialTerrain = materialTerrain; }
//public Material material { get; private set; } //public Biome(string name) //{ // this.name = name; // this.material = Resources.LoadAssetAtPath<Material>(Path + name + "Material.mat"); //} public Biome(string name, MaterialTerrain materialTerrain) { this.materialTerrain = materialTerrain; this.name = name; }
public void SetMaterial(MaterialTerrain material) { materialTerrain = material; }
abstract public void ChangeMaterialSettings(int biomeSelected, MaterialTerrain material, MaterialTerrain.MaterialSettings settings);
public static MaterialTerrain Draw(MaterialTerrain material) { var materialSettings = material.GetMaterialSettingsFromShader(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); GUILayout.Label("Effects"); materialSettings.color = EditorGUILayout.ColorField(materialSettings.color); EditorGUILayout.BeginHorizontal(); materialSettings.glossines = EditorGUILayout.Slider(materialSettings.glossines, 0, 1); GUILayout.Label("- Smooth"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); materialSettings.metallic = EditorGUILayout.Slider(materialSettings.metallic, 0, 1); GUILayout.Label("- Metallic"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); materialSettings.scale = EditorGUILayout.Slider(materialSettings.scale, 0, 1); GUILayout.Label("- Scale"); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); materialSettings.tex1 = EditorGUILayout.ObjectField("", materialSettings.tex1, typeof(Texture2D), true) as Texture2D; EditorGUIUtility.labelWidth = 20; if (WorldManager.worldInstance.shaderType == eShaderType.Shader_NoTransition) { materialSettings.nrm1 = EditorGUILayout.ObjectField("", materialSettings.nrm1, typeof(Texture2D), true) as Texture2D; } EditorGUILayout.EndHorizontal(); //---------------------------------------------------------------- EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); GUILayout.Label("Texture1"); EditorGUILayout.BeginHorizontal(); materialSettings.tex2h = EditorGUILayout.Slider(materialSettings.tex2h, 0, 1); GUILayout.Label("H"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); materialSettings.tex2b = EditorGUILayout.Slider(materialSettings.tex2b, 0, 100); GUILayout.Label("B"); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); materialSettings.tex2 = EditorGUILayout.ObjectField("", materialSettings.tex2, typeof(Texture2D), true) as Texture2D; EditorGUIUtility.labelWidth = 10; if (WorldManager.worldInstance.shaderType == eShaderType.Shader_NoTransition) { materialSettings.nrm2 = EditorGUILayout.ObjectField("", materialSettings.nrm2, typeof(Texture2D), true) as Texture2D; } EditorGUILayout.EndHorizontal(); //---------------------------------------------------------------- EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); GUILayout.Label("Texture2"); EditorGUILayout.BeginHorizontal(); materialSettings.tex3h = EditorGUILayout.Slider(materialSettings.tex3h, 0, 1); GUILayout.Label("H"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); materialSettings.tex3b = EditorGUILayout.Slider(materialSettings.tex3b, 0, 100); GUILayout.Label("B"); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); materialSettings.tex3 = EditorGUILayout.ObjectField("", materialSettings.tex3, typeof(Texture2D), true) as Texture2D; EditorGUIUtility.labelWidth = 10; if (WorldManager.worldInstance.shaderType == eShaderType.Shader_NoTransition) { materialSettings.nrm3 = EditorGUILayout.ObjectField("", materialSettings.nrm3, typeof(Texture2D), true) as Texture2D; } EditorGUILayout.EndHorizontal(); //---------------------------------------------------------------- EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); GUILayout.Label("Texture3"); EditorGUILayout.BeginHorizontal(); materialSettings.tex4h = EditorGUILayout.Slider(materialSettings.tex4h, 0, 1); GUILayout.Label("H"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); materialSettings.tex4b = EditorGUILayout.Slider(materialSettings.tex4b, 0, 100); GUILayout.Label("B"); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); materialSettings.tex4 = EditorGUILayout.ObjectField("", materialSettings.tex4, typeof(Texture2D), true) as Texture2D; EditorGUIUtility.labelWidth = 10; if (WorldManager.worldInstance.shaderType == eShaderType.Shader_NoTransition) { materialSettings.nrm4 = EditorGUILayout.ObjectField("", materialSettings.nrm4, typeof(Texture2D), true) as Texture2D; } EditorGUILayout.EndHorizontal(); if (WorldManager.worldInstance.shaderType == eShaderType.Shader_NoTransition) { //---------------------------------------------------------------- EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); GUILayout.Label("Texture4"); EditorGUILayout.BeginHorizontal(); materialSettings.tex5h = EditorGUILayout.Slider(materialSettings.tex5h, 0, 1); GUILayout.Label("H"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); materialSettings.tex5b = EditorGUILayout.Slider(materialSettings.tex5b, 0, 100); GUILayout.Label("B"); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); materialSettings.tex5 = EditorGUILayout.ObjectField("", materialSettings.tex5, typeof(Texture2D), true) as Texture2D; EditorGUIUtility.labelWidth = 10; materialSettings.nrm5 = EditorGUILayout.ObjectField("", materialSettings.nrm5, typeof(Texture2D), true) as Texture2D; EditorGUILayout.EndHorizontal(); //--------------------------------------------------------------- /*EditorGUILayout.Separator(); * * EditorGUILayout.BeginHorizontal(); * EditorGUILayout.BeginVertical(); * GUILayout.Label("Texture5"); * EditorGUILayout.BeginHorizontal(); * materialSettings.tex6h = EditorGUILayout.Slider(materialSettings.tex6h, 0, 1); * GUILayout.Label("H"); * EditorGUILayout.EndHorizontal(); * EditorGUILayout.BeginHorizontal(); * materialSettings.tex6b = EditorGUILayout.Slider(materialSettings.tex6b, 0, 100); * GUILayout.Label("B"); * EditorGUILayout.EndHorizontal(); * EditorGUILayout.EndVertical(); * * EditorGUILayout.Separator(); * EditorGUILayout.Separator(); * * materialSettings.tex6 = EditorGUILayout.ObjectField("", materialSettings.tex6, typeof(Texture2D), true) as Texture2D; * EditorGUIUtility.labelWidth = 10; * materialSettings.nrm6 = EditorGUILayout.ObjectField("", materialSettings.nrm6, typeof(Texture2D), true) as Texture2D; * * EditorGUILayout.EndHorizontal();*/ } EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginVertical(); { GUILayout.Label("CliffScale"); EditorGUILayout.BeginHorizontal(); materialSettings.cliffScale = EditorGUILayout.Vector2Field("", materialSettings.cliffScale); EditorGUILayout.EndHorizontal(); GUILayout.Label("CliffBlend"); materialSettings.cliffB = EditorGUILayout.Slider(materialSettings.cliffB, 0, 2); GUILayout.Label("CliffFade"); materialSettings.cliffFade = EditorGUILayout.Slider(materialSettings.cliffFade, 0, 1); GUILayout.Label("CliffMinHeight"); materialSettings.cliffMin = EditorGUILayout.Slider(materialSettings.cliffMin, -1, 1); GUILayout.Label("CliffMaxHeight"); materialSettings.cliffMax = EditorGUILayout.Slider(materialSettings.cliffMax, -1, 1); GUILayout.Label("CliffFadeTreshold"); materialSettings.cliffFadeTreshold = EditorGUILayout.Slider(materialSettings.cliffFadeTreshold, 1, 10); GUILayout.Label("CliffFadeBottom"); materialSettings.cliffFadeBottom = EditorGUILayout.Slider(materialSettings.cliffFadeBottom, 0, 200); GUILayout.Label("CliffFadeTop"); materialSettings.cliffFadeTop = EditorGUILayout.Slider(materialSettings.cliffFadeTop, 0, 200); GUILayout.Label("SteepNes"); materialSettings.steepnes = EditorGUILayout.Slider(materialSettings.steepnes, 0, 1); GUILayout.Label("SteepNesBlend"); materialSettings.steepnesBlend = EditorGUILayout.Slider(materialSettings.steepnesBlend, 0, 20); } EditorGUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); materialSettings.texCliff = EditorGUILayout.ObjectField("", materialSettings.texCliff, typeof(Texture2D), true) as Texture2D; EditorGUIUtility.labelWidth = 10; if (WorldManager.worldInstance.shaderType == eShaderType.Shader_NoTransition) { materialSettings.nrmCliff = EditorGUILayout.ObjectField("", materialSettings.nrmCliff, typeof(Texture2D), true) as Texture2D; } } EditorGUILayout.EndHorizontal(); //---------------------------------------------------------------- material.SetMaterialSettingsToShader(materialSettings); return(material); }