Update inspector to be less annoying
This commit is contained in:
@@ -14,6 +14,9 @@ namespace Interactions
|
|||||||
SerializedProperty characterArrivedProp;
|
SerializedProperty characterArrivedProp;
|
||||||
SerializedProperty interactionCompleteProp;
|
SerializedProperty interactionCompleteProp;
|
||||||
|
|
||||||
|
private bool showBaseSettings = true;
|
||||||
|
private bool showEvents = false;
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
isOneTimeProp = serializedObject.FindProperty("isOneTime");
|
isOneTimeProp = serializedObject.FindProperty("isOneTime");
|
||||||
@@ -29,63 +32,89 @@ namespace Interactions
|
|||||||
{
|
{
|
||||||
serializedObject.Update();
|
serializedObject.Update();
|
||||||
|
|
||||||
EditorGUILayout.LabelField("Interaction Settings", EditorStyles.boldLabel);
|
// Draw child-specific properties first (anything not part of base class)
|
||||||
EditorGUILayout.PropertyField(isOneTimeProp);
|
DrawPropertiesExcluding(serializedObject,
|
||||||
EditorGUILayout.PropertyField(cooldownProp);
|
"m_Script",
|
||||||
EditorGUILayout.PropertyField(characterToInteractProp);
|
"isOneTime",
|
||||||
|
"cooldown",
|
||||||
|
"characterToInteract",
|
||||||
|
"interactionStarted",
|
||||||
|
"interactionInterrupted",
|
||||||
|
"characterArrived",
|
||||||
|
"interactionComplete");
|
||||||
|
|
||||||
// Add the buttons for creating move targets
|
// Base Interaction Settings (Collapsible)
|
||||||
EditorGUILayout.Space(10);
|
EditorGUILayout.Space(10);
|
||||||
EditorGUILayout.LabelField("Character Move Targets", EditorStyles.boldLabel);
|
showBaseSettings = EditorGUILayout.Foldout(showBaseSettings, "Base Interaction Settings", true, EditorStyles.foldoutHeader);
|
||||||
|
if (showBaseSettings)
|
||||||
|
{
|
||||||
|
EditorGUI.indentLevel++;
|
||||||
|
EditorGUILayout.PropertyField(isOneTimeProp);
|
||||||
|
EditorGUILayout.PropertyField(cooldownProp);
|
||||||
|
EditorGUILayout.PropertyField(characterToInteractProp);
|
||||||
|
|
||||||
|
// Character Move Targets (sub-section)
|
||||||
|
EditorGUILayout.Space(5);
|
||||||
|
EditorGUILayout.LabelField("Character Move Targets", EditorStyles.boldLabel);
|
||||||
|
|
||||||
EditorGUILayout.BeginHorizontal();
|
EditorGUILayout.BeginHorizontal();
|
||||||
if (GUILayout.Button("Add Trafalgar Target"))
|
if (GUILayout.Button("Add Trafalgar Target"))
|
||||||
{
|
{
|
||||||
CreateMoveTarget(CharacterToInteract.Trafalgar);
|
CreateMoveTarget(CharacterToInteract.Trafalgar);
|
||||||
}
|
}
|
||||||
if (GUILayout.Button("Add Pulver Target"))
|
if (GUILayout.Button("Add Pulver Target"))
|
||||||
{
|
{
|
||||||
CreateMoveTarget(CharacterToInteract.Pulver);
|
CreateMoveTarget(CharacterToInteract.Pulver);
|
||||||
}
|
}
|
||||||
EditorGUILayout.EndHorizontal();
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
// Add a button for creating a "Both" target
|
// Add a button for creating a "Both" target
|
||||||
if (GUILayout.Button("Add Both Characters Target"))
|
if (GUILayout.Button("Add Both Characters Target"))
|
||||||
{
|
{
|
||||||
CreateMoveTarget(CharacterToInteract.Both);
|
CreateMoveTarget(CharacterToInteract.Both);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display character target counts
|
// Display character target counts
|
||||||
InteractableBase interactable = (InteractableBase)target;
|
InteractableBase interactable = (InteractableBase)target;
|
||||||
CharacterMoveToTarget[] moveTargets = interactable.GetComponentsInChildren<CharacterMoveToTarget>();
|
CharacterMoveToTarget[] moveTargets = interactable.GetComponentsInChildren<CharacterMoveToTarget>();
|
||||||
int trafalgarTargets = 0;
|
int trafalgarTargets = 0;
|
||||||
int pulverTargets = 0;
|
int pulverTargets = 0;
|
||||||
int bothTargets = 0;
|
int bothTargets = 0;
|
||||||
|
|
||||||
foreach (var target in moveTargets)
|
foreach (var target in moveTargets)
|
||||||
{
|
{
|
||||||
if (target.characterType == CharacterToInteract.Trafalgar)
|
if (target.characterType == CharacterToInteract.Trafalgar)
|
||||||
trafalgarTargets++;
|
trafalgarTargets++;
|
||||||
else if (target.characterType == CharacterToInteract.Pulver)
|
else if (target.characterType == CharacterToInteract.Pulver)
|
||||||
pulverTargets++;
|
pulverTargets++;
|
||||||
else if (target.characterType == CharacterToInteract.Both)
|
else if (target.characterType == CharacterToInteract.Both)
|
||||||
bothTargets++;
|
bothTargets++;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorGUILayout.LabelField($"Trafalgar Targets: {trafalgarTargets}, Pulver Targets: {pulverTargets}, Both Targets: {bothTargets}");
|
EditorGUILayout.LabelField($"Trafalgar Targets: {trafalgarTargets}, Pulver Targets: {pulverTargets}, Both Targets: {bothTargets}");
|
||||||
|
|
||||||
if (trafalgarTargets > 1 || pulverTargets > 1 || bothTargets > 1 ||
|
if (trafalgarTargets > 1 || pulverTargets > 1 || bothTargets > 1 ||
|
||||||
(bothTargets > 0 && (trafalgarTargets > 0 || pulverTargets > 0)))
|
(bothTargets > 0 && (trafalgarTargets > 0 || pulverTargets > 0)))
|
||||||
{
|
{
|
||||||
EditorGUILayout.HelpBox("Warning: Multiple move targets found that may conflict. Priority order: Both > Character-specific targets.", MessageType.Warning);
|
EditorGUILayout.HelpBox("Warning: Multiple move targets found that may conflict. Priority order: Both > Character-specific targets.", MessageType.Warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Interaction Events (Collapsible)
|
||||||
EditorGUILayout.Space(10);
|
EditorGUILayout.Space(10);
|
||||||
EditorGUILayout.LabelField("Interaction Events", EditorStyles.boldLabel);
|
showEvents = EditorGUILayout.Foldout(showEvents, "Interaction Events", true, EditorStyles.foldoutHeader);
|
||||||
EditorGUILayout.PropertyField(interactionStartedProp);
|
if (showEvents)
|
||||||
EditorGUILayout.PropertyField(interactionInterruptedProp);
|
{
|
||||||
EditorGUILayout.PropertyField(characterArrivedProp);
|
EditorGUI.indentLevel++;
|
||||||
EditorGUILayout.PropertyField(interactionCompleteProp);
|
EditorGUILayout.PropertyField(interactionStartedProp);
|
||||||
|
EditorGUILayout.PropertyField(interactionInterruptedProp);
|
||||||
|
EditorGUILayout.PropertyField(characterArrivedProp);
|
||||||
|
EditorGUILayout.PropertyField(interactionCompleteProp);
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user