[Answered]Enum Switch/Case, Update once per inspector change

whats the simplest way to Update my switch/case every time a selection has been made from the inspector on the Enum drop down list? I have thought about a public bool any other alternative? Now i do understand i can put the function call into update but would that not be slightly taxing.

using UnityEngine;
using System.Collections;

public class WeaponSelector : MonoBehaviour {

    public WeaponType weaponType;
    public enum WeaponType
    {
        Pistol,
        AssultRifle01,
    } ;

    void Start()
    {
        WeaponSwitch ();
    }

    void WeaponSwitch ()
    {
        switch (weaponType) {
        case WeaponType.Pistol:
            selectedWeapon = (int)WeaponType.Pistol;
     
            break;
      
        case WeaponType.AssultRifle01:
            selectedWeapon = (int)WeaponType.AssultRifle01;
      
            break;
         }
     }
}

OnValidate

Savoir Thank you:)

1 Like

You are welcome. I do try to be awesome.