您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

51 行
1.6 KiB

using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(LightSourceEvents))]
public class LightSourceEventsEditor : Editor
{
SerializedProperty defaultState;
SerializedProperty useRandomDelay;
SerializedProperty maxRandomDelay;
SerializedProperty bakedIndirectMultiplier;
SerializedProperty eventsReceivers;
LightSourceEvents targetObject;
private void OnEnable()
{
defaultState = serializedObject.FindProperty("defaultState");
useRandomDelay = serializedObject.FindProperty("useRandomDelay");
maxRandomDelay = serializedObject.FindProperty("maxRandomDelay");
bakedIndirectMultiplier = serializedObject.FindProperty("bakedIndirectMultiplier");
eventsReceivers = serializedObject.FindProperty("eventsReceivers");
targetObject = (LightSourceEvents)serializedObject.targetObject;
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.BeginVertical("Box");
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(defaultState);
EditorGUILayout.PropertyField(bakedIndirectMultiplier);
EditorGUILayout.EndVertical();
if (EditorGUI.EndChangeCheck())
{
serializedObject.ApplyModifiedProperties();
targetObject.SetLightDimmer();
targetObject.SetIndirectMultiplier();
}
EditorGUILayout.PropertyField(useRandomDelay);
if(useRandomDelay.boolValue)
EditorGUILayout.PropertyField(maxRandomDelay);
EditorGUILayout.PropertyField(eventsReceivers, true);
serializedObject.ApplyModifiedProperties();
}
}