How to differ a variable is set in the inspector or not?

SkyWalker

New member
C#:
public class CastSkill:Action
{
    public int magicId;
    
    public override void OnStart()
    {
        if(magicId ==0)//If magicId is set in the inspector, Then it should not be changed. 
            magicId = SkillManager.Instance.CurrentSkillID;//Otherwise it should be changed by CurrentSkillID whitch is changed by player
     }
}
The problem of these code is that the magicId will be set only once. if the player changed CurrentSkillID, magicId !=0. So magicId will not changed.How to differ a variable is set from the inspector or not?
 
You could initialize magicID to -1 and then if it's not -1 do that comparison. I'm assuming that in the inspector you would not use a -1 value.
 
Top