열차 목업의 내부 확인용 프로젝트
smchoi
2024-07-24 ec231f4110c782d44ea2820a1eaaa7a5711c6f16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using UnityEngine;
using UnityEditor;
 
namespace UnityStandardAssets.Water
{
    [CustomEditor(typeof(SpecularLighting))]
    public class SpecularLightingEditor : Editor
    {
        private SerializedObject serObj;
        private SerializedProperty specularLight;
 
        public void OnEnable()
        {
            serObj = new SerializedObject(target);
            specularLight = serObj.FindProperty("specularLight");
        }
 
        public override void OnInspectorGUI()
        {
            serObj.Update();
 
            GameObject go = ((SpecularLighting)serObj.targetObject).gameObject;
            WaterBase wb = (WaterBase)go.GetComponent(typeof(WaterBase));
 
            if (!wb.sharedMaterial)
                return;
 
            if (wb.sharedMaterial.HasProperty("_WorldLightDir"))
            {
                GUILayout.Label("Transform casting specular highlights", EditorStyles.miniBoldLabel);
                EditorGUILayout.PropertyField(specularLight, new GUIContent("Specular light"));
 
                if (wb.sharedMaterial.HasProperty("_SpecularColor"))
                    WaterEditorUtility.SetMaterialColor(
                        "_SpecularColor",
                        EditorGUILayout.ColorField("Specular",
                        WaterEditorUtility.GetMaterialColor("_SpecularColor", wb.sharedMaterial)),
                        wb.sharedMaterial);
                if (wb.sharedMaterial.HasProperty("_Shininess"))
                    WaterEditorUtility.SetMaterialFloat("_Shininess", EditorGUILayout.Slider(
                        "Specular power",
                        WaterEditorUtility.GetMaterialFloat("_Shininess", wb.sharedMaterial),
                        0.0F, 500.0F), wb.sharedMaterial);
            }
            else
                GUILayout.Label("The shader doesn't have the needed _WorldLightDir property.", EditorStyles.miniBoldLabel);
 
            serObj.ApplyModifiedProperties();
        }
 
    }
}