OK, so I've searched all over, and found examples of how to make a public property get called with set so that I can operate on it when it's set, even in the Inspector. I've gotten it to work, and then copied and pasted the working code, changed the name, and it's not working. In the code below, Mass works, but Drag is not being called.
[SerializeField]
private float mass = 0.2f;
[SerializeField]
private float drag = 0.05f;
public float Mass
{
get { return mass; }
set
{
mass = value;
// Update the model
GetComponent().mass = mass;
}
}
public float Drag
{
get { return drag; }
set
{
Debug.Log("Setting Drag");
drag = value;
// Update the model
GetComponent().drag = drag;
}
}
Can anyone see what the difference is in the code for Drag that's preventing it from being called? No errors. Both variables show in inspector, but changes to Drag are not triggering the debug.
↧