Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- //[AddComponentMenu(typeof(UniqueId))]
- //[RequireComponent(typeof(UniqueId))]
- public class SaveObject : MonoBehaviour {
- [DisplayWithoutEdit(), UniqueIdentifier]
- public string id;
- bool resetId;
- //[DisplayWithoutEdit()]
- //public string previewId;
- //public bool Refresh;
- void Awake () {
- //PlayerPrefs.SetInt("_" + id, PlayerPrefs.GetInt(id) + 1);
- // if(id == 0){
- // id = new System.Random().Next(1000000, 9999999);
- // }
- //id = GetComponent<UniqueId>().uniqueId;
- //gameObject.name = id.ToString();
- //var i = "_" + name;
- //int p = PlayerPrefs.GetInt(i);
- //PlayerPrefs.SetInt(i, p + 1);
- //devSettings = Resources.Load("DevSettings") as DevSettings;
- //if(devSettings.useSaveSystem){
- //id = GetComponent<GameObjectGUID>().gameObjectID;
- // if(id == System.Guid.Empty){
- // id = System.Guid.NewGuid();
- // }
- //NS.Base.Debug(gameObject + " " + id);
- //print(gameObject.GetInstanceID());
- //name = GetHashCode();
- if(PlayerPrefs.HasKey(id.ToString())){
- gameObject.SetActive(NS.SaveSystem.Check(id));
- }else{
- NS.SaveSystem.SaveObject(id, true);
- gameObject.SetActive(NS.SaveSystem.Check(id));
- }
- //previewId = id.ToString();
- //InvokeRepeating("CustomUpdate", 1, 1);
- //}
- }
- void OnEnable(){
- }
- // void CustomUpdate () {
- // if(id == ""){
- // NS.Base.Debug(gameObject);
- // }
- // //print(id);
- // //gameObject.SetActive(NS.SaveSystem.Check(GetComponent<GameObjectGUID>().gameObjectID));
- // //previewId = id.ToString();
- // }
- void OnValidate(){
- // if(id == 0){
- // id = new System.Random().Next(1000000, 9999999);
- // }
- //if(GetComponent<UniqueId>()) id = GetComponent<UniqueId>().uniqueId;
- if(resetId){
- // id = 0;
- resetId = false;
- }
- }
- public void Save(){
- NS.PlayerPrefs.SetBool(id, false);
- }
- public void Setup(){
- id = System.Guid.NewGuid().ToString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement