You did not specify a backup variable - you have a property whose getters and setters call themselves. It is not clear to me why the first form is not supported by Unity, which means that the equivalent is not supported, but basically this:
private ConstraintSet aValue; public ConstraintSet a { get { return aValue; } set { aValue = value; } }
I would usually have a more conditional name, of course, which means that you can leave without the value bit:
private ConstraintSet constraints; public ConstraintSet Constraints { get { return constraints; } set { constraints = value; } }
To give more details on why your current second form throws a StackOverflowException , you should always remember that properties are mostly masked. Your broken code is as follows:
public ConstraintSet get_a() { return get_a(); } public void set_a(ConstraintSet value) { set_a(value); }
Hopefully this is obvious why this version is blowing onto the stack. The modified version simply sets the variable instead of calling the property again, so when expanded, it looks like this:
private ConstraintSet aValue; public ConstraintSet get_a() { return aValue; } public void set_a(ConstraintSet value) { aValue = value; }
Jon skeet
source share