unity using get set code example
Example: get and set unity
class Thing {
private int secret; // This is a field.
public int Secret { // This is a property.
get {
Debug.Print("Somebody is accessing the secret!");
return secret;
}
set {
Debug.Print("Somebody is writing to the secret!");
secret = value; // Note the use of the implicit variable "value" here.
}
}
}