Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f7caeb308 |
@@ -130,7 +130,6 @@ namespace AibisDream.UI
|
|||||||
private string _inputBuffer = "";
|
private string _inputBuffer = "";
|
||||||
private bool _cursorVisible = true;
|
private bool _cursorVisible = true;
|
||||||
private Coroutine _crashSpamCoroutine;
|
private Coroutine _crashSpamCoroutine;
|
||||||
private double _editorLastRepaintTime;
|
|
||||||
|
|
||||||
// 全局 alpha(用于 DreamDoorSystem 淡入淡出)
|
// 全局 alpha(用于 DreamDoorSystem 淡入淡出)
|
||||||
public float Alpha { get; set; } = 0f;
|
public float Alpha { get; set; } = 0f;
|
||||||
@@ -154,12 +153,6 @@ namespace AibisDream.UI
|
|||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (!Application.isPlaying)
|
|
||||||
{
|
|
||||||
UpdateEditorPreview();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_phase == TerminalPhase.WaitingInput)
|
if (_phase == TerminalPhase.WaitingInput)
|
||||||
HandleTypingInput();
|
HandleTypingInput();
|
||||||
else if (_phase == TerminalPhase.Confirming)
|
else if (_phase == TerminalPhase.Confirming)
|
||||||
@@ -178,17 +171,16 @@ namespace AibisDream.UI
|
|||||||
base.OnEnable();
|
base.OnEnable();
|
||||||
EnsureDefaultFontReference();
|
EnsureDefaultFontReference();
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
if (!Application.isPlaying)
|
if (!Application.isPlaying)
|
||||||
ApplyEditorPreviewState();
|
EditorRunPreviewTick();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnValidate()
|
private void OnValidate()
|
||||||
{
|
{
|
||||||
EnsureDefaultFontReference();
|
EnsureDefaultFontReference();
|
||||||
MorphProgress = morphProgress;
|
MorphProgress = morphProgress;
|
||||||
|
|
||||||
if (!Application.isPlaying)
|
|
||||||
ApplyEditorPreviewState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -231,33 +223,6 @@ namespace AibisDream.UI
|
|||||||
return Vector2.Lerp(morphStartSize, terminalSize, frameProgress);
|
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
|
#endregion
|
||||||
|
|
||||||
#region Shapes 绘制(DrawShapes 覆写)
|
#region Shapes 绘制(DrawShapes 覆写)
|
||||||
@@ -876,7 +841,7 @@ namespace AibisDream.UI
|
|||||||
public float delayAfter;
|
public float delayAfter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum PreviewStage
|
public enum PreviewStage
|
||||||
{
|
{
|
||||||
Hidden,
|
Hidden,
|
||||||
FrameOnly,
|
FrameOnly,
|
||||||
@@ -898,7 +863,10 @@ namespace AibisDream.UI
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
private void UpdateEditorPreview()
|
private double _editorLastRepaintTime;
|
||||||
|
|
||||||
|
/// <summary>仅编辑器:由 DreamTerminalUIEditor(CustomEditor)在需要时调用。</summary>
|
||||||
|
public void EditorRunPreviewTick()
|
||||||
{
|
{
|
||||||
ApplyEditorPreviewState();
|
ApplyEditorPreviewState();
|
||||||
|
|
||||||
|
|||||||
@@ -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:
|
||||||
Reference in New Issue
Block a user