This may be a common question , but I couldn't find any proper answer I wanted . Even-though some answers are in JavaScript , some are in Unity 4.x etc .
I am working on a simple game project . Now I got one, and have a problem . The problem is accessing the variable from one script to another .
For example :-
I have 2 Scenes (Game Scene and Game Over Scene) , Game Scene has a Player Game Object , who has a int Variable Score .
using UnityEngine;
using System.Collections;
public class Game_Scene_Script : MonoBehaviour
{
private int Score ;
// Use this for initialization
void Start ()
{
Score = 0 ;
}
// Update is called once per frame
void Update ()
{
// Let us assume some one played the game
// And Now the Score is 207
Score = 207 ;
}
}
nowNow I want to access that int Variable Score in Game Over Scene which a Game Object .
So how can I access that int Variable from that script ?
Please help me I searched for, Thanks but couldn't find any proper answer I wanted. Even-though some answers are in JavaScript :), some are in Unity 4.x etc.