Browse Source

Display event handlers with a category after non-categorized ones

master
chrisgregan 10 years ago
parent
commit
0723f51c1d
  1. 35
      Assets/Fungus/FungusScript/Editor/SequenceEditor.cs
  2. 2
      Assets/Fungus/FungusScript/EventHandlers/EnableObject.cs

35
Assets/Fungus/FungusScript/Editor/SequenceEditor.cs

@ -121,23 +121,36 @@ namespace Fungus
GenericMenu eventHandlerMenu = new GenericMenu(); GenericMenu eventHandlerMenu = new GenericMenu();
eventHandlerMenu.AddItem(new GUIContent("None"), false, OnSelectEventHandler, noneOperation); eventHandlerMenu.AddItem(new GUIContent("None"), false, OnSelectEventHandler, noneOperation);
// Add event handlers with no category first
foreach (System.Type type in eventHandlerTypes) foreach (System.Type type in eventHandlerTypes)
{ {
EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type); EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type);
if (info.Category.Length == 0)
string typeName = "";
if (info.Category.Length > 0)
{ {
typeName = info.Category + "/"; SetEventHandlerOperation operation = new SetEventHandlerOperation();
operation.sequence = sequence;
operation.eventHandlerType = type;
eventHandlerMenu.AddItem(new GUIContent(info.EventHandlerName), false, OnSelectEventHandler, operation);
} }
typeName += info.EventHandlerName; }
SetEventHandlerOperation operation = new SetEventHandlerOperation();
operation.sequence = sequence;
operation.eventHandlerType = type;
eventHandlerMenu.AddItem(new GUIContent(typeName), false, OnSelectEventHandler, operation); // Add event handlers with a category afterwards
foreach (System.Type type in eventHandlerTypes)
{
EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type);
if (info.Category.Length > 0)
{
SetEventHandlerOperation operation = new SetEventHandlerOperation();
operation.sequence = sequence;
operation.eventHandlerType = type;
string typeName = info.Category + "/" + info.EventHandlerName;
eventHandlerMenu.AddItem(new GUIContent(typeName), false, OnSelectEventHandler, operation);
}
} }
eventHandlerMenu.ShowAsContext(); eventHandlerMenu.ShowAsContext();
} }
EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal();

2
Assets/Fungus/FungusScript/EventHandlers/EnableObject.cs

@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
[EventHandlerInfo("Scripting", [EventHandlerInfo("",
"Enable Object", "Enable Object",
"The sequence will execute when the owner game object is enabled.")] "The sequence will execute when the owner game object is enabled.")]
public class EnableObject : EventHandler public class EnableObject : EventHandler

Loading…
Cancel
Save