gutterball-3/Gutterball 3/Assets/Standard Assets/Editor/Water (Pro Only)/Water4/SpecularLightingEditor.cs
SkunkStudios 71779ef7ac New Version 1.6
New 125 balls & powerups.
Improved graphics.
2025-05-07 06:18:40 +07:00

47 lines
No EOL
1.6 KiB
C#

using UnityEngine;
using UnityEditor;
[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();
}
}