blob: 7cba9a1f976aad0ee793ba1b9665fab6c3cc5a42 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
|