notebook实装功能,galgame继续,一些bug修复

This commit is contained in:
FloatGaming
2026-03-06 02:08:43 +08:00
parent 9011fa022e
commit 1f4077cf21
468 changed files with 50175 additions and 11402 deletions
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: cf4473abb00e19640a1e4c970f4732ed
@@ -0,0 +1,233 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(ScriptableObject), true)]
public class ingame_galgame_so_Editor : Editor
{
private SerializedProperty triggerMethodProp;
private SerializedProperty timelineStandardProp;
private SerializedProperty dialogueTypeProp;
private SerializedProperty speakersDataSOProp;
private SerializedProperty dialogueListProp;
private void OnEnable()
{
if (target != null && target.GetType().Name == "ingame_galgame_so")
{
triggerMethodProp = serializedObject.FindProperty("triggerMethod");
timelineStandardProp = serializedObject.FindProperty("timelineStandard");
dialogueTypeProp = serializedObject.FindProperty("dialogueType");
speakersDataSOProp = serializedObject.FindProperty("speakersDataSO");
dialogueListProp = serializedObject.FindProperty("dialogueList");
}
}
public override void OnInspectorGUI()
{
if (target == null || target.GetType().Name != "ingame_galgame_so")
{
base.OnInspectorGUI();
return;
}
serializedObject.Update();
EnsureProperties();
if (dialogueTypeProp != null) EditorGUILayout.PropertyField(dialogueTypeProp);
if (triggerMethodProp != null) EditorGUILayout.PropertyField(triggerMethodProp);
if (timelineStandardProp != null) EditorGUILayout.PropertyField(timelineStandardProp);
if (speakersDataSOProp != null) EditorGUILayout.PropertyField(speakersDataSOProp);
EditorGUILayout.Space();
EditorGUILayout.LabelField("Dialogue List", EditorStyles.boldLabel);
// speaker dropdown data
string[] speakerNames = null;
Object speakersObj = speakersDataSOProp != null ? speakersDataSOProp.objectReferenceValue : null;
if (speakersObj != null)
{
var speakersSO = new SerializedObject(speakersObj);
var speakersList = speakersSO.FindProperty("speakers");
if (speakersList != null && speakersList.isArray)
{
int c = speakersList.arraySize;
speakerNames = new string[c + 1];
speakerNames[0] = "(None)";
for (int i = 0; i < c; i++)
{
var e = speakersList.GetArrayElementAtIndex(i);
var nameProp = e.FindPropertyRelative("spkrName");
speakerNames[i + 1] =
nameProp != null ? nameProp.stringValue : $"Speaker {i}";
}
}
}
if (dialogueListProp == null)
{
serializedObject.ApplyModifiedProperties();
return;
}
// ===== DRAW ELEMENTS =====
for (int i = 0; i < dialogueListProp.arraySize; i++)
{
var elemProp = dialogueListProp.GetArrayElementAtIndex(i);
EditorGUILayout.BeginHorizontal();
elemProp.isExpanded =
EditorGUILayout.Foldout(elemProp.isExpanded, $"Element {i}", true);
// Move up
GUI.enabled = i > 0;
if (GUILayout.Button("Up", GUILayout.Width(32)))
{
dialogueListProp.MoveArrayElement(i, i - 1);
}
// Move down
GUI.enabled = i < dialogueListProp.arraySize - 1;
if (GUILayout.Button("Down", GUILayout.Width(42)))
{
dialogueListProp.MoveArrayElement(i, i + 1);
}
GUI.enabled = true;
// Duplicate
if (GUILayout.Button("D", GUILayout.Width(25)))
{
dialogueListProp.InsertArrayElementAtIndex(i);
}
// Delete
GUI.color = Color.red;
if (GUILayout.Button("X", GUILayout.Width(25)))
{
if (EditorUtility.DisplayDialog(
"Delete Element",
"Are you sure you want to delete this element?",
"Delete",
"Cancel"))
{
dialogueListProp.DeleteArrayElementAtIndex(i);
break;
}
}
GUI.color = Color.white;
EditorGUILayout.EndHorizontal();
if (!elemProp.isExpanded)
continue;
EditorGUI.indentLevel++;
var positionTagProp = elemProp.FindPropertyRelative("positionTag");
if (positionTagProp != null)
{
EditorGUILayout.PropertyField(positionTagProp);
}
else
{
var customPosProp = elemProp.FindPropertyRelative("customPositions");
if (customPosProp != null) EditorGUILayout.PropertyField(customPosProp, true);
}
var textListProp = elemProp.FindPropertyRelative("textList");
if (textListProp != null)
{
EditorGUILayout.LabelField("Texts", EditorStyles.boldLabel);
for (int j = 0; j < textListProp.arraySize; j++)
{
var textProp = textListProp.GetArrayElementAtIndex(j);
if (textProp == null)
continue;
textProp.isExpanded =
EditorGUILayout.Foldout(textProp.isExpanded, $"Text {j}");
if (!textProp.isExpanded)
continue;
EditorGUI.indentLevel++;
var contentProp = textProp.FindPropertyRelative("content");
var textNumberProp = textProp.FindPropertyRelative("textNumber");
var senderIndexProp = textProp.FindPropertyRelative("senderIndex");
var imagePosProp = textProp.FindPropertyRelative("imagePos");
var appearTimeProp = textProp.FindPropertyRelative("appearTime");
var durationProp = textProp.FindPropertyRelative("duration");
var stepMethodProp = textProp.FindPropertyRelative("stepMethod");
var timeActionProp = textProp.FindPropertyRelative("timeAction");
var slowMotionProp = textProp.FindPropertyRelative("slowMotionScale");
var endActionProp = textProp.FindPropertyRelative("endAction");
EditorGUILayout.PropertyField(contentProp);
EditorGUILayout.PropertyField(textNumberProp);
if (speakerNames != null)
{
int current =
Mathf.Clamp(senderIndexProp.intValue + 1, 0, speakerNames.Length - 1);
int chosen =
EditorGUILayout.Popup("Sender", current, speakerNames);
senderIndexProp.intValue =
Mathf.Max(-1, chosen - 1);
}
else
{
EditorGUILayout.PropertyField(senderIndexProp);
}
EditorGUILayout.PropertyField(imagePosProp);
EditorGUILayout.PropertyField(appearTimeProp);
EditorGUILayout.PropertyField(durationProp);
EditorGUILayout.PropertyField(stepMethodProp);
EditorGUILayout.PropertyField(timeActionProp);
EditorGUILayout.PropertyField(slowMotionProp);
EditorGUILayout.PropertyField(endActionProp);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
}
}
EditorGUI.indentLevel--;
EditorGUILayout.Space();
}
EditorGUILayout.Space();
if (GUILayout.Button("Add Dialogue Element"))
{
dialogueListProp.InsertArrayElementAtIndex(dialogueListProp.arraySize);
}
serializedObject.ApplyModifiedProperties();
}
private void EnsureProperties()
{
if (triggerMethodProp == null) triggerMethodProp = serializedObject.FindProperty("triggerMethod");
if (timelineStandardProp == null) timelineStandardProp = serializedObject.FindProperty("timelineStandard");
if (dialogueTypeProp == null) dialogueTypeProp = serializedObject.FindProperty("dialogueType");
if (speakersDataSOProp == null) speakersDataSOProp = serializedObject.FindProperty("speakersDataSO");
if (dialogueListProp == null) dialogueListProp = serializedObject.FindProperty("dialogueList");
}
}
#endif
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0eb6197bfc1d20247a4a26b7523e5342