Skip to content
Permalink
bbf03575ab
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
68 lines (56 sloc) 1.62 KB
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Persistence : MonoBehaviour {
public static Persistence Instance;
TextCore textCore;
public GameObject uiController = GameObject.Find("UIElementController");
//public Canvas theUI;
public int health;
public int score;
public int cores;
public int power;
//Awake
void Awake()
{
if (Instance == null)
{
DontDestroyOnLoad(gameObject);
Instance = this;
}
else if (Instance != this)
{
Destroy(gameObject);
}
}
// Use this for initialization
void Start ()
{
textCore = GameObject.Find("UIElementController").GetComponent<TextCore>();
health = Persistence.Instance.health;
power = Persistence.Instance.power;
cores = Persistence.Instance.cores;
score = Persistence.Instance.score;
uiController = Persistence.Instance.uiController;
textCore = Persistence.Instance.textCore;
// theUI = Persistence.Instance.theUI;
}
// Update is called once per frame
void Update ()
{
health = textCore.health;
score = textCore.score;
power = textCore.power;
// cores = textCore.cores;
}
//Scene Transitions
public void SavePlayer()
{
Persistence.Instance.health = health;
Persistence.Instance.score = score;
Persistence.Instance.cores = cores;
Persistence.Instance.power = power;
Persistence.Instance.uiController = uiController;
Persistence.Instance.textCore = textCore;
}
}