浏览代码

Merge pull request #991 from Unity-Technologies/input-register-fix

Fixed input registering and the "ghost inspector" issue
/main
GitHub 7 年前
当前提交
31254b86
共有 1 个文件被更改,包括 7 次插入12 次删除
  1. 19
      ScriptableRenderPipeline/Core/CoreRP/Inputs/InputRegistering.cs

19
ScriptableRenderPipeline/Core/CoreRP/Inputs/InputRegistering.cs


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
正在加载...
取消
保存