Reseting Component/GameObject to its initial scene state.

I would like to create a basic behaviour for my components that lets them be reset to the original values at the begining of the scene when they are complete. In otherwords, I want a simple way to create 'Repeat on Complete' functionality. Without reloading the scene or instantiating a prefab, is there a way to reset an object/component to its original scene state?

Create an object prefab with desired properties. In-game instantiate this prefab. Change those properties however you like. When you need to set defaults, simply destroy this game object and instantiate a new one from the prefab. Now, this new one will have all props set to default. If you want to change some of those, simply adjust them just before instantiation.

I don't think there's a built-in way, but you could implement this yourself by storing the values that you'd like to be re-set in the Start function. Eg:

var originalPosition : Vector3;
var originalRotation : Quaternion;

function Start() {
    originalPosition = transform.position;
    originalRotation = transform.rotation;
}

function Reset() {
    transform.position = originalPosition;
    transform.rotation = originalRotation;
    if (rigidbody != null) {
        rigidbody.velocity = Vector3.zero;
        rigidbody.angularVelocity = Vector3.zero;
    }
}

If you wanted to re-set other values such as animation state, visibility, etc, you'd have to add each of these as separate variables, with the corresponding lines of code to reset them.

Make your object an prefab and try

UnityEditor.PrefabUtility.ResetToPrefabState(this.gameObject)

It not seems to work for me though, but the docs says “Resets the properties of the component or game object to the parent prefab state”

//read all game objects and set initial position when ever it needs

in c#

private Dictionary<GameObject,Vector3> current_obj_trans_value = new Dictionary<GameObject,Vector3>();

public void intial_pos_set()
 {

   object[] allObjects = FindObjectsOfTypeAll(typeof(GameObject)) ;

   foreach(object thisObject in allObjects)
 {
    if (((GameObject) thisObject).activeInHierarchy &&((GameObject) 

        thisObject).GetComponent() != null)
		
          current_obj_trans_value[((GameObject)thisObject)]=
                                      ((GameObject)thisObject).transform.position;

 }
  
 }

public void reset_tranform_pos()
{

    foreach(KeyValuePair<GameObject,Vector3> allactobj in 

                                                   current_obj_trans_value)
	{
	
	    allactobj.Key.transform.position= allactobj.Value;
			  
        }

 }