Compare commits

...
Author SHA1 Message Date
bottlefish 0f7caeb308 修复 2026-04-02 12:05:16 +08:00
4 changed files with 134 additions and 40 deletions
@@ -130,7 +130,6 @@ namespace AibisDream.UI
private string _inputBuffer = "";
private bool _cursorVisible = true;
private Coroutine _crashSpamCoroutine;
private double _editorLastRepaintTime;
// 全局 alpha(用于 DreamDoorSystem 淡入淡出)
public float Alpha { get; set; } = 0f;
@@ -154,12 +153,6 @@ namespace AibisDream.UI
private void Update()
{
if (!Application.isPlaying)
{
UpdateEditorPreview();
return;
}
if (_phase == TerminalPhase.WaitingInput)
HandleTypingInput();
else if (_phase == TerminalPhase.Confirming)
@@ -178,17 +171,16 @@ namespace AibisDream.UI
base.OnEnable();
EnsureDefaultFontReference();
#if UNITY_EDITOR
if (!Application.isPlaying)
ApplyEditorPreviewState();
EditorRunPreviewTick();
#endif
}
private void OnValidate()
{
EnsureDefaultFontReference();
MorphProgress = morphProgress;
if (!Application.isPlaying)
ApplyEditorPreviewState();
}
#endregion
@@ -231,33 +223,6 @@ namespace AibisDream.UI
return Vector2.Lerp(morphStartSize, terminalSize, frameProgress);
}
[ContextMenu("Preview/Frame Only")]
private void PreviewFrameOnly()
{
previewInEditor = true;
previewStage = PreviewStage.FrameOnly;
previewAlpha = 1f;
previewMorphProgress = 0.65f;
ApplyEditorPreviewState();
}
[ContextMenu("Preview/Waiting Input")]
private void PreviewWaitingInput()
{
previewInEditor = true;
previewStage = PreviewStage.WaitingInput;
previewAlpha = 1f;
previewMorphProgress = 1f;
ApplyEditorPreviewState();
}
[ContextMenu("Preview/Clear")]
private void ClearPreview()
{
previewInEditor = false;
ApplyEditorPreviewState();
}
#endregion
#region Shapes DrawShapes
@@ -876,7 +841,7 @@ namespace AibisDream.UI
public float delayAfter;
}
private enum PreviewStage
public enum PreviewStage
{
Hidden,
FrameOnly,
@@ -898,7 +863,10 @@ namespace AibisDream.UI
#endregion
#if UNITY_EDITOR
private void UpdateEditorPreview()
private double _editorLastRepaintTime;
/// <summary>仅编辑器:由 DreamTerminalUIEditorCustomEditor)在需要时调用。</summary>
public void EditorRunPreviewTick()
{
ApplyEditorPreviewState();
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 476765c2f1febfa46abc793693aafa81
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,107 @@
using AibisDream.UI;
using UnityEditor;
using UnityEngine;
namespace AibisDream.UI.Editor
{
[CustomEditor(typeof(DreamTerminalUI))]
[CanEditMultipleObjects]
internal sealed class DreamTerminalUIEditor : UnityEditor.Editor
{
void OnEnable()
{
EditorApplication.update += OnEditorUpdate;
RefreshAllTargets();
}
void OnDisable()
{
EditorApplication.update -= OnEditorUpdate;
}
void OnEditorUpdate()
{
if (Application.isPlaying)
return;
RefreshAllTargets();
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUI.BeginChangeCheck();
DrawDefaultInspector();
bool changed = EditorGUI.EndChangeCheck();
serializedObject.ApplyModifiedProperties();
if (changed)
RefreshAllTargets();
EditorGUILayout.Space();
using (new EditorGUILayout.HorizontalScope())
{
if (GUILayout.Button("Preview / Frame Only"))
ApplyPreset(PreviewPreset.FrameOnly);
if (GUILayout.Button("Preview / Waiting Input"))
ApplyPreset(PreviewPreset.WaitingInput);
}
if (GUILayout.Button("Preview / Clear"))
ApplyPreset(PreviewPreset.Clear);
}
enum PreviewPreset
{
FrameOnly,
WaitingInput,
Clear
}
void ApplyPreset(PreviewPreset preset)
{
Undo.RecordObjects(targets, "Dream Terminal Preview Preset");
foreach (Object o in targets)
{
var ui = (DreamTerminalUI)o;
SerializedObject so = new SerializedObject(ui);
switch (preset)
{
case PreviewPreset.FrameOnly:
so.FindProperty("previewInEditor").boolValue = true;
so.FindProperty("previewStage").enumValueIndex = (int)DreamTerminalUI.PreviewStage.FrameOnly;
so.FindProperty("previewAlpha").floatValue = 1f;
so.FindProperty("previewMorphProgress").floatValue = 0.65f;
break;
case PreviewPreset.WaitingInput:
so.FindProperty("previewInEditor").boolValue = true;
so.FindProperty("previewStage").enumValueIndex = (int)DreamTerminalUI.PreviewStage.WaitingInput;
so.FindProperty("previewAlpha").floatValue = 1f;
so.FindProperty("previewMorphProgress").floatValue = 1f;
break;
case PreviewPreset.Clear:
so.FindProperty("previewInEditor").boolValue = false;
break;
}
so.ApplyModifiedProperties();
ui.EditorRunPreviewTick();
}
}
void RefreshAllTargets()
{
foreach (Object o in targets)
{
var ui = o as DreamTerminalUI;
if (ui != null)
ui.EditorRunPreviewTick();
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 747d2c6e1751ca44ca1dc64512027f8c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: