|
|
@ -337,7 +337,28 @@ namespace Fungus |
|
|
|
|
|
|
|
|
|
|
|
// Build menu list |
|
|
|
// Build menu list |
|
|
|
List<System.Type> menuTypes = EditorExtensions.FindDerivedTypes(typeof(Command)).ToList(); |
|
|
|
List<System.Type> menuTypes = EditorExtensions.FindDerivedTypes(typeof(Command)).ToList(); |
|
|
|
foreach(System.Type type in menuTypes) |
|
|
|
List<KeyValuePair<System.Type, CommandInfoAttribute>> filteredAttributes = GetFilteredCommandInfoAttribute(menuTypes); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach(var keyPair in filteredAttributes) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SetCommandOperation commandOperation = new SetCommandOperation(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commandOperation.sequence = sequence; |
|
|
|
|
|
|
|
commandOperation.commandType = keyPair.Key; |
|
|
|
|
|
|
|
commandOperation.index = index; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commandMenu.AddItem (new GUIContent (keyPair.Value.Category + "/" + keyPair.Value.CommandName), |
|
|
|
|
|
|
|
false, Callback, commandOperation); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commandMenu.ShowAsContext(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<KeyValuePair<System.Type,CommandInfoAttribute>> GetFilteredCommandInfoAttribute(List<System.Type> menuTypes) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Dictionary<string, KeyValuePair<System.Type, CommandInfoAttribute>> filteredAttributes = new Dictionary<string, KeyValuePair<System.Type, CommandInfoAttribute>>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (System.Type type in menuTypes) |
|
|
|
{ |
|
|
|
{ |
|
|
|
object[] attributes = type.GetCustomAttributes(false); |
|
|
|
object[] attributes = type.GetCustomAttributes(false); |
|
|
|
foreach (object obj in attributes) |
|
|
|
foreach (object obj in attributes) |
|
|
@ -345,21 +366,25 @@ namespace Fungus |
|
|
|
CommandInfoAttribute infoAttr = obj as CommandInfoAttribute; |
|
|
|
CommandInfoAttribute infoAttr = obj as CommandInfoAttribute; |
|
|
|
if (infoAttr != null) |
|
|
|
if (infoAttr != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
SetCommandOperation commandOperation = new SetCommandOperation(); |
|
|
|
string dictionaryName = string.Format("{0}/{1}", infoAttr.Category, infoAttr.CommandName); |
|
|
|
|
|
|
|
|
|
|
|
commandOperation.sequence = sequence; |
|
|
|
int existingItemPriority = -1; |
|
|
|
commandOperation.commandType = type; |
|
|
|
if (filteredAttributes.ContainsKey(dictionaryName)) |
|
|
|
commandOperation.index = index; |
|
|
|
{ |
|
|
|
|
|
|
|
existingItemPriority = filteredAttributes[dictionaryName].Value.Priority; |
|
|
|
commandMenu.AddItem (new GUIContent (infoAttr.Category + "/" + infoAttr.CommandName), |
|
|
|
} |
|
|
|
false, Callback, commandOperation); |
|
|
|
|
|
|
|
|
|
|
|
if (infoAttr.Priority > existingItemPriority) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
KeyValuePair<System.Type, CommandInfoAttribute> keyValuePair = new KeyValuePair<System.Type, CommandInfoAttribute>(type, infoAttr); |
|
|
|
|
|
|
|
filteredAttributes[dictionaryName] = keyValuePair; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return filteredAttributes.Values.ToList<KeyValuePair<System.Type,CommandInfoAttribute>>(); |
|
|
|
commandMenu.ShowAsContext(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Callback(object obj) |
|
|
|
void Callback(object obj) |
|
|
|
{ |
|
|
|
{ |
|
|
|
SetCommandOperation commandOperation = obj as SetCommandOperation; |
|
|
|
SetCommandOperation commandOperation = obj as SetCommandOperation; |
|
|
|