82 lines
3.0 KiB
C#
82 lines
3.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
|
|
[CustomEditor(typeof(SetMaterialsPropertris))]
|
|
public class SetMaterialsPropertrisEditor : Editor
|
|
{
|
|
SetMaterialsPropertris inst;
|
|
|
|
private void OnEnable()
|
|
{
|
|
inst = (SetMaterialsPropertris)target;
|
|
}
|
|
|
|
public override void OnInspectorGUI()
|
|
{
|
|
base.OnInspectorGUI();
|
|
|
|
//
|
|
if(GUILayout.Button("Do it", GUILayout.Height(50)))
|
|
{
|
|
inst.materialsCheck.Clear();
|
|
|
|
foreach (Transform t in inst.root.GetComponentsInChildren<Transform>())
|
|
{
|
|
if(t.gameObject.activeSelf && t.GetComponent<MeshRenderer>())
|
|
{
|
|
foreach (Material mat in t.GetComponent<MeshRenderer>().sharedMaterials)
|
|
{
|
|
if (mat != null && mat.shader != null &&
|
|
(mat.shader == Shader.Find("ASE/LandScape") || mat.shader == Shader.Find("ASE/Stone") || mat.shader == Shader.Find("ASE/Building")))
|
|
{
|
|
inst.materialsCheck.Add(mat);
|
|
asdasdasd(mat);
|
|
}
|
|
|
|
if (mat != null && mat.shader != null &&
|
|
(mat.shader == Shader.Find("Shader Graphs/Tree") || mat.shader == Shader.Find("Shader Graphs/Grass") || mat.shader == Shader.Find("Shader Graphs/Flower")))
|
|
{
|
|
inst.materialsCheck.Add(mat);
|
|
asdasdasssssd(mat);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Debug.Log("Done!");
|
|
}
|
|
}
|
|
|
|
void asdasdasd(Material material)
|
|
{
|
|
//Rainny
|
|
//material.SetColor("_WaterColor", inst.waterColor);
|
|
material.SetVector("_WaterNoiseScale", inst.waterNoiseScale);
|
|
material.SetTexture("_WaterWaveNormal", inst.waterWaveNormal);
|
|
material.SetVector("_WaterWaveNormalScale", inst.waterWaveNormalScale);
|
|
material.SetFloat("_WaterWaveNoiseScale", inst.waterWaveNoiseScale);
|
|
material.SetVector("_WaterWaveSpeedDir", inst.waterWaveSpeedDir);
|
|
material.SetTexture("_RippleMask", inst.rippleMask);
|
|
material.SetFloat("_RippleScaleA", inst.rippleScaleA);
|
|
material.SetFloat("_RippleScaleB", inst.rippleScaleB);
|
|
material.SetFloat("_RippleMaskStength", inst.rippleMaskStength);
|
|
material.SetFloat("_Rainny", inst.rainny);
|
|
|
|
//Snownny
|
|
material.SetColor("_SnowColor", inst.snowColor);
|
|
material.SetVector("_SnowNoiseScale", inst.snowNoiseScale);
|
|
material.SetTexture("_SnowNormalTex", inst.snowNormalTex);
|
|
material.SetFloat("_SnowNormalStrength", inst.snowNormalStrength);
|
|
material.SetFloat("_Snownny", inst.snownny);
|
|
}
|
|
|
|
void asdasdasssssd(Material material)
|
|
{
|
|
//Snownny
|
|
material.SetColor("_SnowColor", inst.snowColor);
|
|
material.SetFloat("_Snownny", inst.snownny);
|
|
}
|
|
}
|