Created
November 6, 2015 16:57
-
-
Save tsubaki/93130be4898c0ad09bf6 to your computer and use it in GitHub Desktop.
DontDestroyのシングルトン
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class LoadScene : MonoBehaviour | |
{ | |
public static LoadScene Instance{ | |
get; private set; | |
} | |
public int score = 0; | |
void Awake() | |
{ | |
if (Instance != null) { | |
Destroy(gameObject); | |
return; | |
} | |
Instance = this; | |
DontDestroyOnLoad (gameObject); | |
score = 30; | |
} | |
// click callback | |
public void OnClick() | |
{ | |
Application.LoadLevel (1); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class ReadData : MonoBehaviour | |
{ | |
void Start () | |
{ | |
LoadScene loadScene = LoadScene.Instance; | |
Debug.Log (loadScene.score); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment