Files
AppleHillsProduction/Assets/Editor/ObjectiveStepBehaviourEditor.cs
Michal Pikulski dac119fd7b First steps
2025-10-02 07:17:07 +02:00

58 lines
2.4 KiB
C#

using UnityEngine;
using UnityEditor;
using AppleHills.Editor;
using AppleHills.Core.Settings;
namespace PuzzleS.Editor
{
[CustomEditor(typeof(ObjectiveStepBehaviour))]
public class ObjectiveStepBehaviourEditor : UnityEditor.Editor
{
private SerializedProperty stepDataProperty;
private SerializedProperty indicatorPrefabProperty;
private SerializedProperty drawPromptRangeGizmoProperty;
private void OnEnable()
{
stepDataProperty = serializedObject.FindProperty("stepData");
indicatorPrefabProperty = serializedObject.FindProperty("indicatorPrefab");
drawPromptRangeGizmoProperty = serializedObject.FindProperty("drawPromptRangeGizmo");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
// Draw default inspector properties
EditorGUILayout.PropertyField(stepDataProperty);
EditorGUILayout.Space();
EditorGUILayout.LabelField("Indicator Settings", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(indicatorPrefabProperty);
EditorGUILayout.PropertyField(drawPromptRangeGizmoProperty);
// Add button to create default indicator
EditorGUILayout.Space();
if (GUILayout.Button("Create Default Indicator"))
{
var interactionSettings = EditorSettingsProvider.GetSettings<InteractionSettings>();
if (interactionSettings != null && interactionSettings.DefaultPuzzleIndicatorPrefab != null)
{
indicatorPrefabProperty.objectReferenceValue = interactionSettings.DefaultPuzzleIndicatorPrefab;
serializedObject.ApplyModifiedProperties();
Debug.Log("Default puzzle indicator prefab assigned from settings");
}
else
{
Debug.LogWarning("Default puzzle indicator prefab not set in InteractionSettings!");
EditorUtility.DisplayDialog("No Default Indicator",
"The default puzzle indicator prefab is not set in the InteractionSettings asset.", "OK");
}
}
serializedObject.ApplyModifiedProperties();
}
}
}