- Home /
Question by
Jeomar · Jan 15, 2018 at 01:29 PM ·
c#editor-scriptingcustom editoreditorguicustom inspector
Trying to create Custom Inspector Labels and I get erros
I am trying to create custom inspector labels and I am getting errors, any help to resolve this would be greatly appreciated
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(KeyboardTracker))]
public class KeyboardTrackerEditor : MonoBehaviour
{
public override void OnInspectorGUI()
{
KeyboardTracker target = null;
KeyboardTracker keyboardTracker = target as KeyboardTracker;
EditorGUILayout.LabelField("Axis", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
if(keyboardTracker.axisKeys.Length == 0)
{
EditorGUILayout.HelpBox("No axes defined in InputManager.", MessageType.Info);
}
else
{
SerializedProperty serializedProperty = serializedObject.FindProperty("axisKeys");
{
for (int i = 0; i < keyboardTracker.axisKeys.Length; i++)
{
EditorGUILayout.PropertyField(serializedProperty.GetArrayElementAtIndex(i), new GUIContent("Axis" + i));
}
}
EditorGUI.indentLevel--;
EditorGUILayout.LabelField("Buttons", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
if (keyboardTracker.axisKeys.Length == 0)
{
EditorGUILayout.HelpBox("No buttons defined in InputManager.", MessageType.Info);
}
else
{
for (int i = 0; i < keyboardTracker.buttonKeys.Length; i++)
{
keyboardTracker.buttonKeys[i] = (KeyCode)EditorGUILayout.EnumPopup("Button " + i, keyboardTracker.buttonKeys[i]);
}
}
}
}
}
I am following the board to bits games tutorial series on how to create character controller. This is the video that I currently am on.
Comment
Your answer
Follow this Question
Related Questions
Initialising List array for use in a custom Editor 1 Answer
Custom inspector editor - how to put new editor fields in a specific place 1 Answer
Calling a custom inspector from an editor window of an instance of a class 1 Answer
Manually set ControlID to built-in controls ? 1 Answer
How to tell if any textField has keyboard focus in editor? 2 Answers