Reset component

Good afternoon. How can I use a script trigger reset component values of the same item in the component menu?

You want to do what? Click Reset?

Yes

You don’t need scripting to click RMB>Reset

Just to elaborate on the answer by @andrew-lukasik

Your script needs its class fields to be explicitly defined with values, otherwise they will default to their respective default values.

public int speed = 6; // Will default to the value 6 on RESET
public int speed; // Will default to the value 0 on RESET

There is also a function that can be used to define what happens when the user presses the Reset button in the inspector. The documentation for that function can be found here: MonoBehavoiur.Reset()

If you need help finding the Reset button for any component including scripts it is shown in the video below (@56 seconds)

1 Like

How can I call function Reset from script?

What ‘Reset’ function are you referring to, what should this ‘Reset’ function do?

Are you wanting to call it at runtime or in the editor?

I want to write a script that like this:
gameobkect.GetComponent.Reset() and reset all the values in the default.

I don’t believe such a thing exists. I’d assume that the Reset functionality you see in the editor inspector is a Editor feature and not a method on the class/behaviour being ‘reset’.