|
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEditor; |
|
|
|
|
|
|
|
public class InputManagerEntry |
|
|
|
{ |
|
|
|
public enum Kind { KeyOrButton, Mouse, Axis } |
|
|
|
|
|
|
public class InputRegistering |
|
|
|
{ |
|
|
|
|
|
|
|
static bool InputAlreadyRegistered(string name, InputManagerEntry.Kind kind, UnityEditor.SerializedProperty spAxes) |
|
|
|
static bool InputAlreadyRegistered(string name, InputManagerEntry.Kind kind, SerializedProperty spAxes) |
|
|
|
{ |
|
|
|
for (var i = 0; i < spAxes.arraySize; ++i) |
|
|
|
{ |
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
static void WriteEntry(UnityEditor.SerializedProperty spAxes, InputManagerEntry entry) |
|
|
|
static void WriteEntry(SerializedProperty spAxes, InputManagerEntry entry) |
|
|
|
{ |
|
|
|
if (InputAlreadyRegistered(entry.name, entry.kind, spAxes)) |
|
|
|
return; |
|
|
|
|
|
|
spAxis.FindPropertyRelative("joyNum").intValue = (int)entry.joystick; |
|
|
|
} |
|
|
|
|
|
|
|
static public void RegisterInputs(List<InputManagerEntry> entries) |
|
|
|
public static void RegisterInputs(List<InputManagerEntry> entries) |
|
|
|
/* |
|
|
|
var currentSelection = UnityEditor.Selection.activeObject; |
|
|
|
UnityEditor.EditorApplication.ExecuteMenuItem("Edit/Project Settings/Input"); |
|
|
|
var inputManager = UnityEditor.Selection.activeObject; |
|
|
|
var inputManager = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0]; |
|
|
|
var soInputManager = new UnityEditor.SerializedObject(inputManager); |
|
|
|
var soInputManager = new SerializedObject(inputManager); |
|
|
|
var spAxes = soInputManager.FindProperty("m_Axes"); |
|
|
|
|
|
|
|
foreach(InputManagerEntry entry in entries) |
|
|
|
|
|
|
|
|
|
|
// Commit
|
|
|
|
soInputManager.ApplyModifiedProperties(); |
|
|
|
|
|
|
|
UnityEditor.Selection.activeObject = currentSelection; |
|
|
|
*/ |
|
|
|
} |
|
|
|
} |
|
|
|
#endif
|