- Home /
How to link two serialized booleans?
How can I make sure that if one serialized boolean field is made true (in the unity inspector) the other gets unchecked? I specifically need to say that they are either Start, End or none at all. So I need 3 options, it's not a case of either being Start or End (that's not that hard, now is it? :D ) I have the following so far and am using a Debug.LogError and Error Pause in the console for testing in case I get case where both isWaypointStart and isWaypointEnd are true. Not ideal but hopefully someone can shed some light. Thanks!
[SerializeField] public bool isWaypointStart = false;
[SerializeField] public bool isWaypointEnd = false;
void Awake()
{
if (isWaypointStart && isWaypointEnd)
{
Debug.LogError("you cannot have " + this.name + " be both the start and finish waypoints at the same time.");
}
}
Answer by Elango · Jul 12, 2020 at 08:08 PM
Giving the opportunity to make a mistake rather strange decision. Just make an enum:
public enum E_Waypoint
{
None,
Start,
End
}
Can rename None to your liking like Path or whatever. Or keep it and just add fourth for Path and use default None for errors. And field for it:
public E_Waypoint waypoint;
Your answer
Follow this Question
Related Questions
Raycast Hit not toggling variable if stops hitting 1 Answer
Bool is not turning false 1 Answer
How to make boolean be true for x amount of seconds? 2 Answers
CS0019: Operator `&&' cannot be applied to operands of type `int' and `bool' 4 Answers
How do you trigger a collider to become enabled after the player collider isn't touching it anymore? 4 Answers