PlayerScript.cs
using UnityEngine; public class PlayerScript : MonoBehaviour { public int health = 100; public int maxHealth = 100; }
PlayerScriptEditor.cs
using UnityEngine; using UnityEditor; [CustomEditor(typeof(PlayerScript))] public class PlayerScriptEditor : Editor { public override void OnInspectorGUI() { PlayerScript playerScript = (PlayerScript)target; DrawDefaultInspector(); if (playerScript.maxHealth > 0) EditorGUILayout.LabelField("Health %", playerScript.health * 100 / playerScript.maxHealth + "%"); } }