Browse Source

GetCommandInfo returns the highest priority CommandInfo to better support multiple names while maintaining what is shown in the inspector

master
desktop-maesty/steve 7 years ago
parent
commit
cc7bbf0db1
  1. 3
      Assets/Fungus/Scripts/Commands/SpawnObject.cs
  2. 9
      Assets/Fungus/Scripts/Editor/CommandEditor.cs

3
Assets/Fungus/Scripts/Commands/SpawnObject.cs

@ -11,7 +11,8 @@ namespace Fungus
/// </summary>
[CommandInfo("Scripting",
"Spawn Object",
"Spawns a new object based on a reference to a scene or prefab game object.")]
"Spawns a new object based on a reference to a scene or prefab game object.",
Priority = 10)]
[CommandInfo("GameObject",
"Instantiate",
"Instantiate a game object")]

9
Assets/Fungus/Scripts/Editor/CommandEditor.cs

@ -16,17 +16,22 @@ namespace Fungus.EditorUtils
public static CommandInfoAttribute GetCommandInfo(System.Type commandType)
{
CommandInfoAttribute retval = null;
object[] attributes = commandType.GetCustomAttributes(typeof(CommandInfoAttribute), false);
foreach (object obj in attributes)
{
CommandInfoAttribute commandInfoAttr = obj as CommandInfoAttribute;
if (commandInfoAttr != null)
{
return commandInfoAttr;
if (retval == null)
retval = commandInfoAttr;
else if (retval.Priority < commandInfoAttr.Priority)
retval = commandInfoAttr;
}
}
return null;
return retval;
}
public virtual void DrawCommandInspectorGUI()

Loading…
Cancel
Save