- Home /
how to reset only specific properties?
when i hit the "reset" button on a script - all properties get reset from code.
- is there a way to reset only specific fields?
- is there a way to mark what should not be reset from code?
- is there a way to mark what should not be change from inspector?
i want some fields to always reset from code, and others from inspector.
changing vars to private/public just to do that is not a good practice.
you could use an editor script that will reset those specific properties... is this for multiple scripts?
Answer by hypnoticmeteor · Jan 09, 2015 at 12:14 PM
create public functions that can be accessed which change the private fields within that script.
Create functions with boolean parameters which act accordingly.
private int varOne; private int varTwo; private int varThree
// Hide public variables [HideInInspector] public bool hide;
//show public variables public bool show // Reset only specific fields public void resetTheseFields(int localVarOne, int localVarTwo) { vartwo = localVarOne; varThree = localVarTwo; }
//mark what should not be reset public void changeVarOne(int newVarOneValue, bool flagVar) { if(flagVar) varOne = newVarOneValue; else { //do nothing }
// }
Answer by Ericool · Jan 09, 2015 at 12:04 PM
Put everything private and protected or public get;set; because otherwise you will continue to have that kind of issue. With code you cant get wrong.