private void Awake() { PhotonView = this.GetComponent <PhotonView>(); if (Instance == null) { Instance = this; //PhotonView.DontDestroyOnLoad (this); } else if (this != Instance) { //SceneManager.sceneLoaded -= OnSceneFinishingLoading; if (PhotonView.isMine) { PhotonNetwork.RemoveRPCs(PhotonView); } PhotonView.DestroyImmediate(gameObject); return; } Instance = this; // Ex: lluma#1234 PlayerName = nameInputField.text; SceneManager.sceneLoaded += OnSceneFinishingLoading; }
// Use this for initialization private void Awake() { if (instance == null) { instance = this; //PhotonView.DontDestroyOnLoad (this); } else if (this != instance) { PhotonView.DestroyImmediate(gameObject); } }