- Home /
How do I get to display Timetaken to finish the the game scene on the final scene?
How can I collect the time taken information from my previous scene to display on another scene?
I have this variable in my script on the player in scene1.
private var roundTimeRemaining : int = 0;
I want to collect this information from that scene so that i can display it on my final scene.
Answer by dannyskim · Jan 31, 2012 at 06:19 PM
The best thing to do is place this into a singleton GameObject that has
function Awake()
{
DontDestroyOnLoad(gameObject);
}
in it. This way, you can record whatever values that you want and then access them in any scene.
http://unity3d.com/support/documentation/ScriptReference/Object.DontDestroyOnLoad.html
How to access information from the script component of that game object which is in another scene? :| What would be the script?
I think you should use GetComponent for that. But not sure.
But check this:- http://unity3d.com/support/documentation/ScriptReference/GameObject.GetComponent.html
I am unsure how to use the get component. Whether to get component from the game object or the script attached to it. Should I use getComponent.Player for the game object or getComponent.HealthTracker for the script attached to it. I tried both and I get this error "" The name 'Player' or 'HealthScript' does not denote a valid type ('not found'). ""