Hey I want to show in the Inspector the % value of the result of all the Probability that are added.
I got it to work but I dont know how to move it beside the Probability slider
This is what I got right now :
using UnityEngine;
using UnityEditor;
using Sirenix.OdinInspector.Editor;
[CustomEditor(typeof(MobSpawner))]
public class CustomOdinEditor : OdinEditor
{
SerializedProperty probability;
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
MobSpawner mobSpawner = (MobSpawner)target;
foreach (MobSpawn mobSpawn in mobSpawner.mobSpawns)
{
float totalProbability = 0;
foreach (MobLootTable mobLootTable in mobSpawn.mobLootTables)
{
if (mobLootTable.ForceDrop == false)
{
totalProbability = totalProbability + mobLootTable.probability;
}
}
foreach (MobLootTable mobLootTable in mobSpawn.mobLootTables)
{
if (mobLootTable.ForceDrop == false)
{
float percentage = Mathf.Ceil(mobLootTable.probability / totalProbability * 100);
GUILayout.Label(percentage.ToString() + "%");
}
}
}
}
}
Thanks !