diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-06-01 15:09:59 +0800 |
|---|---|---|
| committer | Weicao-CatilGrass <1992414357@qq.com> | 2026-06-01 15:09:59 +0800 |
| commit | e63c8557b3b860f0d1d1dcea69816fca35ebc6a6 (patch) | |
| tree | 328d6f684157b0b2957caf10e891b7a8035556e5 /Assets/Scripts | |
| parent | cd6a2e619b80fe88279388470ebd4ea7e2fe5b3a (diff) | |
增加单向门
Diffstat (limited to 'Assets/Scripts')
| -rw-r--r-- | Assets/Scripts/Editor.meta | 8 | ||||
| -rw-r--r-- | Assets/Scripts/Editor/OneWayDoorBehaviourEditor.cs | 61 | ||||
| -rw-r--r-- | Assets/Scripts/Editor/OneWayDoorBehaviourEditor.cs.meta | 11 | ||||
| -rw-r--r-- | Assets/Scripts/OneWayDoorBehaviour.cs | 11 | ||||
| -rw-r--r-- | Assets/Scripts/OneWayDoorBehaviour.cs.meta | 11 | ||||
| -rw-r--r-- | Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs | 41 | ||||
| -rw-r--r-- | Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs.meta | 11 |
7 files changed, 154 insertions, 0 deletions
diff --git a/Assets/Scripts/Editor.meta b/Assets/Scripts/Editor.meta new file mode 100644 index 0000000..52270d7 --- /dev/null +++ b/Assets/Scripts/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b370129016fce4348872345ca7b04938 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Editor/OneWayDoorBehaviourEditor.cs b/Assets/Scripts/Editor/OneWayDoorBehaviourEditor.cs new file mode 100644 index 0000000..819deff --- /dev/null +++ b/Assets/Scripts/Editor/OneWayDoorBehaviourEditor.cs @@ -0,0 +1,61 @@ +#if UNITY_EDITOR +using System.Globalization; +using UnityEditor; +using UnityEngine; + +namespace Editor +{ + [CustomEditor(typeof(OneWayDoorBehaviour))] + public class OneWayDoorBehaviourEditor : UnityEditor.Editor + { + /* + * Editor page created by Mountools + * Author : WangSoul Team + * Date : 2026 / 06 / 01 - 15:06:38 + */ + + public OneWayDoorBehaviour oneWayDoorBehaviour; + + private void OnEnable() + { + oneWayDoorBehaviour = (OneWayDoorBehaviour) target; + } + + private void DrawOneWayDoorBehaviourEditor() + { + EditorGUI.BeginDisabledGroup(true); + { + EditorGUILayout.LabelField("单项门角度", oneWayDoorBehaviour.Angle.ToString(CultureInfo.InvariantCulture)); + EditorGUILayout.LabelField("单项门开合百分比", oneWayDoorBehaviour.AnglePercent.ToString(CultureInfo.InvariantCulture)); + EditorGUILayout.Toggle("单项门是否打开", oneWayDoorBehaviour.IsOpened); + } + EditorGUI.EndDisabledGroup(); + } + + #region _ + + public override void OnInspectorGUI() + { + Undo.RecordObject(oneWayDoorBehaviour, "Edit OneWayDoorBehaviour"); + EditorGUI.BeginChangeCheck(); + + DrawDefaultInspector(); + DrawOneWayDoorBehaviourEditor(); + + if (EditorGUI.EndChangeCheck()) + { + EditorUtility.SetDirty(oneWayDoorBehaviour); + Undo.FlushUndoRecordObjects(); + serializedObject.ApplyModifiedProperties(); + } + } + + private bool Property(string label, string propertyName, params GUILayoutOption[] options) + { + return EditorGUILayout.PropertyField(serializedObject.FindProperty(propertyName), new GUIContent(label), options); + } + + #endregion + } +} +#endif
\ No newline at end of file diff --git a/Assets/Scripts/Editor/OneWayDoorBehaviourEditor.cs.meta b/Assets/Scripts/Editor/OneWayDoorBehaviourEditor.cs.meta new file mode 100644 index 0000000..379d85f --- /dev/null +++ b/Assets/Scripts/Editor/OneWayDoorBehaviourEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4cf7bc48aa8bfad45afe83a473719eca +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/OneWayDoorBehaviour.cs b/Assets/Scripts/OneWayDoorBehaviour.cs new file mode 100644 index 0000000..a92d8cd --- /dev/null +++ b/Assets/Scripts/OneWayDoorBehaviour.cs @@ -0,0 +1,11 @@ +using UnityEngine; + +public class OneWayDoorBehaviour : MonoBehaviour +{ + [Header("绑定")] + public Transform door; + + public float Angle => door.localRotation.eulerAngles.y; + public float AnglePercent => Angle / 90; + public bool IsOpened => Angle > 75; +} diff --git a/Assets/Scripts/OneWayDoorBehaviour.cs.meta b/Assets/Scripts/OneWayDoorBehaviour.cs.meta new file mode 100644 index 0000000..a4c0504 --- /dev/null +++ b/Assets/Scripts/OneWayDoorBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b6d609f7db4eb0a40af2ea60b9108be5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs b/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs new file mode 100644 index 0000000..6680dee --- /dev/null +++ b/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs @@ -0,0 +1,41 @@ +using System; +using UnityEngine; +using TMPro; + +namespace SoulCoreGameLoop.UI +{ + [RequireComponent(typeof(Animator))] + public class MessageBox : MonoBehaviour, IUIEventSender<Message> + { + private static readonly int TriggerPlay = Animator.StringToHash("Play"); + + public TMP_Text messageText; + private Animator _animator; + + private void Awake() + { + _animator = GetComponent<Animator>(); + UIEventListener.Register(this); + } + + private void OnDestroy() + => UIEventListener.Unregister<Message>(); + + + public void OnReceive(Message evt) + { + messageText.text = evt.MessageText; + _animator.SetTrigger(TriggerPlay); + } + } + + public struct Message + { + public readonly string MessageText; + + public Message(string messageText) + { + MessageText = messageText; + } + } +}
\ No newline at end of file diff --git a/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs.meta b/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs.meta new file mode 100644 index 0000000..5aa4ca1 --- /dev/null +++ b/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 56cb74692951d66478469249ca604209 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |
