// reseeting the scene when the start button is pushed. private void ResetScene() { // reseting variables to their default state CancelInvoke("ResetScene"); mTimerCounter = 0; timerDisplay.text = "0:00"; failCount.text = "0"; successCount.text = "0"; mGreenPoints = 0; mRedPoints = 0; // reseting camera to default position ResetCameraPosition(); // reseting game objects to their positions and the materials for both target and movable object. GameObject[] gameObjects = GameObject.FindObjectsOfType <GameObject> (); for (int i = 0; i < gameObjects.Length; i++) { ObjectScript objScript = gameObjects [i].GetComponent <ObjectScript> (); if (objScript != null) { if (!objScript.isTargetObject) { objScript.Reset(); gameObjects [i].GetComponent <Renderer> ().material = objectMaterial; } else { gameObjects [i].GetComponent <Renderer> ().material = targetMaterial; } } } }