You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.7 KiB
64 lines
1.7 KiB
10 years ago
|
using UnityEditor;
|
||
|
using UnityEditorInternal;
|
||
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
namespace Fungus
|
||
|
{
|
||
|
|
||
|
[CustomEditor (typeof(EventHandler), true)]
|
||
|
public class EventHandlerEditor : Editor
|
||
|
{
|
||
10 years ago
|
/**
|
||
|
* Returns the class attribute info for an event handler class.
|
||
|
*/
|
||
|
public static EventHandlerInfoAttribute GetEventHandlerInfo(System.Type eventHandlerType)
|
||
|
{
|
||
|
object[] attributes = eventHandlerType.GetCustomAttributes(typeof(EventHandlerInfoAttribute), false);
|
||
|
foreach (object obj in attributes)
|
||
|
{
|
||
|
EventHandlerInfoAttribute eventHandlerInfoAttr = obj as EventHandlerInfoAttribute;
|
||
|
if (eventHandlerInfoAttr != null)
|
||
|
{
|
||
|
return eventHandlerInfoAttr;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}
|
||
|
|
||
10 years ago
|
public virtual void DrawInspectorGUI()
|
||
|
{
|
||
|
// Users should not be able to change the MonoScript for the command using the usual Script field.
|
||
10 years ago
|
// Doing so could cause block.commandList to contain null entries.
|
||
10 years ago
|
// To avoid this we manually display all properties, except for m_Script.
|
||
|
serializedObject.Update();
|
||
|
SerializedProperty iterator = serializedObject.GetIterator();
|
||
|
bool enterChildren = true;
|
||
|
while (iterator.NextVisible(enterChildren))
|
||
|
{
|
||
|
enterChildren = false;
|
||
|
|
||
|
if (iterator.name == "m_Script")
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]);
|
||
|
}
|
||
|
|
||
|
EventHandler t = target as EventHandler;
|
||
10 years ago
|
EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(t.GetType());
|
||
10 years ago
|
if (info != null &&
|
||
|
info.HelpText.Length > 0)
|
||
|
{
|
||
|
EditorGUILayout.HelpBox(info.HelpText, MessageType.Info);
|
||
|
}
|
||
|
|
||
|
serializedObject.ApplyModifiedProperties();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|