- Home /
The question is answered, right answer was accepted
setting the properties in the inspector
[ExecuteInEditMode]
public class Trap : MonoBehaviour
{
[SerializeField]
private bool trapTurnedON;
public bool TrapTurnedON
{
get
{
return trapTurnedON;
}
set
{
Debug.Log("HERE");
trapTurnedON = value;
}
}
}
if I check or uncheck the bool in the inspector while or not while running the game Debug.Log doesn't trigger. It only triggers when the bool is changed inside a script.
Any idea how to trigger it in the inspector?
Answer by YinXiaozhou · Sep 29, 2016 at 07:36 AM
The default inspector has nothing to do with the properties. They only serialize fields. So the bool toggle you see in the inspector is actually link to the trapTurnedOn. You see it as Trap Turned On is because Unity will format all the names in inspector like this. To get want you want you can write a custom editor for Trap. Or make a something different like a context menu
thanks, I solved it using this
http://wiki.unity3d.com/index.php/ExposePropertiesInInspector_Generic
Follow this Question
Related Questions
Hide/Show properties dynamically in inspector. 6 Answers
If I have a bool method, how can I see in the inspector whether it returns true or false? 2 Answers
Fill/populate [SerializeField] automatically via script in editor mode? 3 Answers
Why can't a MonoBehaviour subtype with generic arguments be serialized in a list since Unity 4.5? 0 Answers