Advanced POC - portals, dialogue system + floating words, room loading
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Unheimlich.Data.Dialogues;
|
||||
|
||||
[CustomEditor(typeof(DialogueNode))]
|
||||
public class DialogueNodeEditor : Editor
|
||||
{
|
||||
private SerializedProperty _dialogueTextProp;
|
||||
private SerializedProperty _dialogueTextLocalizationKeyProp;
|
||||
private SerializedProperty _choicesProp;
|
||||
private SerializedProperty _autoCloseDelayProp;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_dialogueTextProp = serializedObject.FindProperty("DialogueText");
|
||||
_dialogueTextLocalizationKeyProp = serializedObject.FindProperty("DialogueTextLocalizationKey");
|
||||
_choicesProp = serializedObject.FindProperty("Choices");
|
||||
_autoCloseDelayProp = serializedObject.FindProperty("AutoCloseDelay");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
EditorGUILayout.LabelField("Node Content", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_dialogueTextProp);
|
||||
EditorGUILayout.PropertyField(_dialogueTextLocalizationKeyProp, new GUIContent("Localization Key (Optional)"));
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
EditorGUILayout.LabelField("Choices", EditorStyles.boldLabel);
|
||||
|
||||
DialogueNode node = (DialogueNode)target;
|
||||
|
||||
if (node.IsEndNode())
|
||||
{
|
||||
EditorGUILayout.HelpBox("This node is an end of conversation (no choices).", MessageType.Info);
|
||||
|
||||
EditorGUILayout.Space(5);
|
||||
EditorGUILayout.LabelField("End Node Settings", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(_autoCloseDelayProp, new GUIContent("Auto Close Delay (seconds)"));
|
||||
|
||||
float delay = _autoCloseDelayProp.floatValue;
|
||||
if (delay > 0)
|
||||
EditorGUILayout.HelpBox($"The dialogue will automatically close after {delay:F1}s with a fade out.", MessageType.None);
|
||||
else
|
||||
EditorGUILayout.HelpBox("Player must press 'Interact' to close the dialogue.", MessageType.None);
|
||||
|
||||
EditorGUILayout.Space(5);
|
||||
}
|
||||
else if (!node.HasValidChoices())
|
||||
EditorGUILayout.HelpBox("Warning: Some choices don't have a NextNode assigned.", MessageType.Warning);
|
||||
|
||||
EditorGUILayout.PropertyField(_choicesProp, true);
|
||||
|
||||
EditorGUILayout.Space(10);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button("Add Choice"))
|
||||
{
|
||||
AddNewChoice();
|
||||
}
|
||||
|
||||
if (node.Choices != null && node.Choices.Count > 0)
|
||||
{
|
||||
if (GUILayout.Button("Clear All Choices"))
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("Clear Choices",
|
||||
"Are you sure you want to remove all choices?",
|
||||
"Yes", "Cancel"))
|
||||
{
|
||||
node.Choices.Clear();
|
||||
EditorUtility.SetDirty(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void AddNewChoice()
|
||||
{
|
||||
DialogueNode node = (DialogueNode)target;
|
||||
|
||||
DialogueChoiceData newChoice = new DialogueChoiceData
|
||||
{
|
||||
ChoiceText = "New choice",
|
||||
NextNode = null
|
||||
};
|
||||
|
||||
node.Choices.Add(newChoice);
|
||||
EditorUtility.SetDirty(node);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user