aboutsummaryrefslogtreecommitdiff
path: root/Assets/Scripts/DamageVolumeSystem/Editor/HealthDataEditor.cs
diff options
context:
space:
mode:
authorWeicao-CatilGrass <1992414357@qq.com>2026-05-12 08:49:44 +0800
committerWeicao-CatilGrass <1992414357@qq.com>2026-05-12 08:49:44 +0800
commitb1a45c232474e99b52eadc43406ab7de15b7ee95 (patch)
tree9b821060928ab5272ff739dfe3ba462f8f3db034 /Assets/Scripts/DamageVolumeSystem/Editor/HealthDataEditor.cs
parentcb06c001d8c99bcf2d4fd16db4b8443f12b3cf60 (diff)
Add health system
Diffstat (limited to 'Assets/Scripts/DamageVolumeSystem/Editor/HealthDataEditor.cs')
-rw-r--r--Assets/Scripts/DamageVolumeSystem/Editor/HealthDataEditor.cs57
1 files changed, 57 insertions, 0 deletions
diff --git a/Assets/Scripts/DamageVolumeSystem/Editor/HealthDataEditor.cs b/Assets/Scripts/DamageVolumeSystem/Editor/HealthDataEditor.cs
new file mode 100644
index 0000000..7cba9a1
--- /dev/null
+++ b/Assets/Scripts/DamageVolumeSystem/Editor/HealthDataEditor.cs
@@ -0,0 +1,57 @@
+#if UNITY_EDITOR
+using UnityEditor;
+using UnityEngine;
+
+namespace DamageVolumeSystem.Editor
+{
+ [CustomEditor(typeof(HealthData))]
+ public class HealthDataEditor : UnityEditor.Editor
+ {
+ /*
+ * Editor page created by Mountools
+ * Author : WangSoul Team
+ * Date : 2026 / 05 / 12 - 08:30:25
+ */
+
+ public HealthData healthData;
+
+ private void OnEnable()
+ {
+ healthData = (HealthData) target;
+ }
+
+ private void DrawHealthDataEditor()
+ {
+ if (Application.isPlaying)
+ {
+ healthData.Health = EditorGUILayout.IntSlider($"Health ({(float) healthData.Health / healthData.maxHealth * 100}%)", healthData.Health, 0, healthData.maxHealth);
+ }
+ }
+
+ #region _
+
+ public override void OnInspectorGUI()
+ {
+ Undo.RecordObject(healthData, "Edit HealthData");
+ EditorGUI.BeginChangeCheck();
+
+ DrawDefaultInspector();
+ DrawHealthDataEditor();
+
+ if (EditorGUI.EndChangeCheck())
+ {
+ EditorUtility.SetDirty(healthData);
+ 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