using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

namespace Valkyrie
{
    public class ShadowShaderGUI : BasicShaderGUI
    {
        private static class Styles
        {
            public static string shaderText = "[----------Shadow----------]";        
            public static GUIContent lightInfoShadowLabel = EditorGUIUtility.TrTextContent("Shadow LightInfo(阴影光照,XYZ:方向,W:高度偏移)",""); //_LightInfoShadow
            public static GUIContent terrainHeightLabel = EditorGUIUtility.TrTextContent("Terrain Height","地型高度,阴影长度随地型高度变化"); //_TerrainHeight
            public static GUIContent shadowColorLabel = EditorGUIUtility.TrTextContent("Shadow Color","阴影颜色,RGB:阴影颜色值,A:与透明度结合"); //_TerrainHeight
            
        }

        MaterialProperty lightInfoShadow = null;
        MaterialProperty terrainHeight = null;
        MaterialProperty shadowColor = null;

        public new void FindProperties(MaterialProperty[] props)
        {
            lightInfoShadow = FindProperty("_LightInfoShadow", props);
            terrainHeight = FindProperty("_TerrainHeight", props);
            shadowColor = FindProperty("_ShadowColor", props);
        }

        public new void ShaderPropertiesGUI(Material material)
        {
            EditorGUI.BeginChangeCheck();
            {
                GUILayout.Label(Styles.shaderText, EditorStyles.boldLabel);
                m_MaterialEditor.ShaderProperty(lightInfoShadow, Styles.lightInfoShadowLabel);
                m_MaterialEditor.ShaderProperty(terrainHeight, Styles.terrainHeightLabel);
                m_MaterialEditor.ShaderProperty(shadowColor, Styles.shadowColorLabel);

                EditorGUILayout.Space();
                
            }
            if (EditorGUI.EndChangeCheck())
            {
                
            }
        }

        public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
        {
            base.FindProperties(props);
            FindProperties(props);
            m_MaterialEditor = materialEditor;
            Material material = materialEditor.target as Material;
            base.ShaderPropertiesGUI(material);
            ShaderPropertiesGUI(material);
            m_MaterialEditor.RenderQueueField();
            m_MaterialEditor.EnableInstancingField();
        }
    }
}
