public void onUserConnected(List <string> names) { for (int i = 0; i < names.Count; i++) { list[i].gameObject.SetActive(true); list[i].nameText.text = names[i]; Debug.Log(names[i]); if (names[i] == playerTemp.playerName) { curPlayer = list[i]; //button0.gameObject.SetActive(true); } } if (names.Count == 2) { for (int i = 0; i < names.Count; i++) { if (names[i] != playerTemp.playerName) { GameObject player = Instantiate(playerPrefab, new Vector3(), Quaternion.identity); player.name = player.GetComponent <Player>().playerName = names[i]; DontDestroyOnLoadManager.DontDestroyOnLoad(player); } } Debug.Log("beres"); StartCoroutine(gameStart()); } }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } GameEvents.SaveInitiated += Save; GameEvents.LoadInitiated += Load; gameObject.transform.parent = null; //DontDestroyOnLoad(gameObject); DontDestroyOnLoadManager.DontDestroyOnLoad(gameObject); /* if (instance != null) * { * Debug.LogWarning("More than one instance of inventory"); * return; * } * * instance = this;*/ }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } gameObject.transform.parent = null; //DontDestroyOnLoad(gameObject); DontDestroyOnLoadManager.DontDestroyOnLoad(gameObject); foreach (Sound s in sounds) { s.source = gameObject.AddComponent <AudioSource>(); s.source.clip = s.clip; s.source.volume = s.volume; s.source.pitch = s.pitch; s.source.playOnAwake = s.playOnAwake; s.source.loop = s.loop; } }
void Start() { if (DontDestroyOnLoadManager.Objects.Count == 0) { GameObject creation = Instantiate(prefab) as GameObject; DontDestroyOnLoadManager.DontDestroyOnLoad(creation); } else if (DontDestroyOnLoadManager.Objects.Count > 1) { DontDestroyOnLoadManager.DestroyAll(); Debug.LogError("FATAL ERROR : 뭔가 이상해!!"); return; } }
void Awake() { int GameStatusCount = FindObjectsOfType <InventoryUI>().Length; if (GameStatusCount > 1) { gameObject.SetActive(false); //Destroy(gameObject); } else { //DontDestroyOnLoad(gameObject); DontDestroyOnLoadManager.DontDestroyOnLoad(gameObject); } }
public Timers() { _inst = this; gameObject = new GameObject("[FairyGUI.Timers]"); gameObject.hideFlags = HideFlags.HideInHierarchy; gameObject.SetActive(true); //Object.DontDestroyOnLoad(gameObject); DontDestroyOnLoadManager.DontDestroyOnLoad(gameObject, 2, () => { _inst = null; }); //重启流程 _engine = gameObject.AddComponent <TimersEngine>(); _items = new Dictionary <TimerCallback, Anymous_T>(); _toAdd = new Dictionary <TimerCallback, Anymous_T>(); _toRemove = new List <Anymous_T>(); _pool = new List <Anymous_T>(100); }
public void onStartClick() { string name = nameInput.text; string IP = IPInput.text; Debug.Log(name + " " + IP); PlayerPrefs.SetString("name", name); PlayerPrefs.SetString("ip", IP); GameObject player = Instantiate(playerPrefab, new Vector3(), Quaternion.identity); player.name = name; player.GetComponent <Player>().playerName = name; DontDestroyOnLoadManager.DontDestroyOnLoad(player); SceneManager.LoadScene("lobby"); }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } gameObject.transform.parent = null; //DontDestroyOnLoad(gameObject); DontDestroyOnLoadManager.DontDestroyOnLoad(gameObject); GameEvents.SaveInitiated += Save; GameEvents.LoadInitiated += Load; }
//private static MoveLetter letterInstance; /* * public string GetLetterStatus() * { return letterStatus; } * * public void SetLetterStatus(string value) * { * letterStatus = value; * } */ // Start is called before the first frame update void Start() { //DontDestroyOnLoad(this.gameObject); DontDestroyOnLoadManager.DontDestroyOnLoad(this.gameObject); /*if (letterInstance == null) * { * letterInstance = this; * } * else * { * DestroyObject(gameObject); * } */ if (FindObjectsOfType(GetType()).Length > 9) { Destroy(gameObject); } }
static void Init() { _inited = true; if (Application.isPlaying) { GameObject gameObject = new GameObject("[FairyGUI.TweenManager]"); gameObject.hideFlags = HideFlags.HideInHierarchy; gameObject.SetActive(true); //Object.DontDestroyOnLoad(gameObject); DontDestroyOnLoadManager.DontDestroyOnLoad(gameObject, 2, () => { _inited = false; _activeTweens = new GTweener[30]; _tweenerPool.Clear(); _totalActiveTweens = 0; } ); //重启流程 gameObject.AddComponent <TweenEngine>(); } }
private void Awake() { DontDestroyOnLoadManager.DontDestroyOnLoad(transform.gameObject); }