浏览代码

Input Player Action property drawer

/feature-new-input-system
Thomas ICHÉ 4 年前
当前提交
fd6cc7f0
共有 1 个文件被更改,包括 6 次插入6 次删除
  1. 12
      Editor/PropertyDrawers/InputPlayerActionPropertyDrawer.cs

12
Editor/PropertyDrawers/InputPlayerActionPropertyDrawer.cs


public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var asset = property.FindPropertyRelative("playerInput");
var playerInput = property.FindPropertyRelative("playerInput");
EditorGUI.PropertyField(position, asset, new GUIContent("Player Input"));
EditorGUI.PropertyField(position, playerInput, new GUIContent("Player Input"));
var paths = GetPaths(asset.objectReferenceValue as InputActionAsset);
var paths = GetPaths(playerInput.objectReferenceValue as PlayerInput);
int selected = paths.IndexOf(path.stringValue);
selected = EditorGUI.Popup(position, "Action", selected, paths);
if(GUI.changed)

EditorGUI.indentLevel--;
}
string[] GetPaths(InputActionAsset asset)
string[] GetPaths(PlayerInput playerInput)
if (asset == null)
if (playerInput == null || playerInput.actions == null)
foreach(var map in asset.actionMaps)
foreach(var map in playerInput.actions.actionMaps)
{
if (map == null) continue;
foreach(var action in map.actions)

正在加载...
取消
保存