-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Inpector code for InputDefinition & InputSequence.
Added methods to make it possible to make custom inspector code for InputDefinition and InputSequence.
- Loading branch information
1 parent
5f0e8ee
commit 56cdec2
Showing
25 changed files
with
1,276 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,77 @@ | ||
using System.Collections.Generic; | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
#if UNITY_EDITOR | ||
using UnityEditor; | ||
#endif | ||
using Malee.List; | ||
|
||
namespace CAF.Input | ||
{ | ||
[System.Serializable] | ||
public class InputSequence | ||
{ | ||
public int executeWindow = 3; | ||
public List<InputDefinition> executeInputs = new List<InputDefinition>(); | ||
[SerializeField]public List<InputDefinition> executeInputs = new List<InputDefinition>(); | ||
public int sequenceWindow = 8; | ||
public List<InputDefinition> sequenceInputs = new List<InputDefinition>(); | ||
[SerializeField]public List<InputDefinition> sequenceInputs = new List<InputDefinition>(); | ||
|
||
#if UNITY_EDITOR | ||
[NonSerialized] private bool executeWindowFoldout = false; | ||
[NonSerialized] private bool sequenceWindowFoldout = false; | ||
#endif | ||
|
||
public virtual void DrawInspector(SerializedProperty executeInputsProperty, SerializedProperty sequenceInputsProperty) | ||
{ | ||
#if UNITY_EDITOR | ||
executeWindow = EditorGUILayout.IntField("Execute Window", executeWindow); | ||
DrawInputDefinitionList(ref executeWindowFoldout, "Execute Buttons", ref executeInputs); | ||
EditorGUILayout.Space(); | ||
sequenceWindow = EditorGUILayout.IntField("Sequence Window", sequenceWindow); | ||
DrawInputDefinitionList(ref sequenceWindowFoldout, "Sequence Buttons", ref sequenceInputs); | ||
#endif | ||
} | ||
|
||
#if UNITY_EDITOR | ||
public virtual void DrawInputDefinitionList(ref bool foldout, string foldoutName, ref List<InputDefinition> inputs) | ||
{ | ||
foldout = EditorGUILayout.Foldout(foldout, foldoutName); | ||
if (foldout) | ||
{ | ||
EditorGUI.indentLevel++; | ||
|
||
EditorGUILayout.BeginHorizontal(); | ||
GUILayout.Space(EditorGUI.indentLevel * 15); | ||
if(GUILayout.Button("Add Input")) | ||
{ | ||
inputs.Add(new InputDefinition()); | ||
} | ||
EditorGUILayout.EndHorizontal(); | ||
|
||
for(int i = 0; i < inputs.Count; i++) | ||
{ | ||
EditorGUILayout.BeginHorizontal(); | ||
GUILayout.Space(EditorGUI.indentLevel * 15); | ||
if (GUILayout.Button("X", GUILayout.Width(20))) | ||
{ | ||
inputs.RemoveAt(i); | ||
continue; | ||
} | ||
EditorGUILayout.EndHorizontal(); | ||
inputs[i].inputType = (InputDefinitionType)EditorGUILayout.EnumPopup("Input Type", inputs[i].inputType); | ||
switch (inputs[i].inputType) | ||
{ | ||
case InputDefinitionType.Button: | ||
inputs[i].buttonID = EditorGUILayout.IntField("Button ID", inputs[i].buttonID); | ||
break; | ||
case InputDefinitionType.Stick: | ||
break; | ||
} | ||
} | ||
|
||
EditorGUI.indentLevel--; | ||
} | ||
} | ||
#endif | ||
} | ||
} |
Oops, something went wrong.