You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/3rd/D2D_Scripts/Gameplay/Editor/HealthEditor.cs

57 lines
1.7 KiB
C#

3 months ago
using AV.Inspector.Runtime;
using D2D.Core;
using D2D.Utilities;
using D2D.Utils;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
namespace D2D.Gameplay
{
[CustomEditor(typeof(Health))]
public class HealthEditor : SuperEditor
{
public override void OnInspectorGUI()
{
BeginSerialization();
var health = (Health) target;
// Show max points or data
ShowProperty(health.isHealthDataMode ? "_healthData" : "_maxPoints",
health.isHealthDataMode ? "Data" : "Max Points");
// Show current points
if (Application.isPlaying)
ReadOnlyLine("Current points", health.CurrentPoints.ToString());
// Show health effects (if needed)
if (health.particlesAreEnabled)
{
Space(10);
ShowProperty("_hitEffect", "Hit Effect");
ShowProperty("_deathEffect", "Death Effect");
ShowProperty("_meshRenderer", "Mesh Renderer");
ShowProperty("gradient", "Gradient");
}
ShowProperty("_isGrayFadeout", "Is Gray Fadeout");
EndSerialization();
}
[InitializeOnInspector]
private static void OnInspector()
{
SmartInspector.OnSetupEditorElement += x =>
{
if (!(x.target is Health target))
return;
var icons = CoreSettings.Instance.tools.icons;
x.NewFastToolbarToggle(icons.effects, nameof(target.particlesAreEnabled));
x.NewFastToolbarToggle(icons.data, nameof(target.isHealthDataMode));
};
}
}
}