Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created November 6, 2015 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/c0774fe128287b9928fa to your computer and use it in GitHub Desktop.
Save tsubaki/c0774fe128287b9928fa to your computer and use it in GitHub Desktop.
Application.UnloadLevel
using UnityEngine;
using System.Collections;
public class LoadScene : MonoBehaviour
{
public int score = 0;
void Awake()
{
score = 30;
}
bool isLoaded = false;
// click callback
public void OnClick()
{
if (isLoaded == false) {
isLoaded = true;
Application.LoadLevelAdditive (1);
} else {
isLoaded = false;
Application.UnloadLevel(1);
}
}
}
using UnityEngine;
using System.Collections;
public class ReadData : MonoBehaviour
{
void Start ()
{
LoadScene loadScene = GameObject.FindObjectOfType<LoadScene> ();
Debug.Log (loadScene.score);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment