- Home /
How to reset component properties from script
Hello! I am working on an editor script to reset the properties of a component which we do by clicking the reset button from the context menu. How would I simulate this behavior from script? I know there is MonoBehavior.Reset but I want to reset non mono-behavior components i.e. SpriteRenderer, Collider,...
Thanks
Answer by Pnvanol · Apr 02, 2019 at 06:44 AM
What you need to do is destroy the component , and then add the component this will reset it.
Answer by Adam-Mechtley · Oct 18, 2016 at 02:28 PM
Hi @THEAK472009! Unfortunately this is not possible. Many Component types defined on the native side do not implement a Reset method in managed code, and so the context menu item is only ever executing native code.
Your answer
Follow this Question
Related Questions
How to prevent Static List from resetting when i run the game in the editor? 1 Answer
Custom Inspector resets after Unity restarts 0 Answers
Reset script variable values automatically? 2 Answers
Editor Script Update Button? 1 Answer
Toggle bool reset after using DestroyImmediate (On Editor Script) 0 Answers