void Start() { ExitGames.Demos.DemoAnimator.CameraWork _cameraWork = this.gameObject.GetComponent <ExitGames.Demos.DemoAnimator.CameraWork>(); if (PlayerUiPrefab != null) { GameObject _uiGo = Instantiate(PlayerUiPrefab) as GameObject; _uiGo.SendMessage("SetTarget", this, SendMessageOptions.RequireReceiver); } else { Debug.LogError("Il manque une prefab pour votre joueur"); } if (_cameraWork != null) { if (photonView.isMine) { _cameraWork.OnStartFollowing(); } } else { Debug.LogError("<Color=Red><a>Il manque</a></Color> la caméra pour faire marcher", this); } UnityEngine.SceneManagement.SceneManager.sceneLoaded += (scene, loadingMode) => { if (this != null) { this.CalledOnLevelWasLoaded(scene.buildIndex); } }; }
/// <summary> /// MonoBehaviour method called on GameObject by Unity during initialization phase. /// </summary> void Start() { if (PlayerUiPrefab != null) { GameObject _uiGo = Instantiate(PlayerUiPrefab) as GameObject; _uiGo.SendMessage("SetTarget", this, SendMessageOptions.RequireReceiver); } else { Debug.LogWarning("<Color=Red><a>Missing</a></Color> PlayerUiPrefab reference on player Prefab.", this); } ExitGames.Demos.DemoAnimator.CameraWork _cameraWork = this.gameObject.GetComponent <ExitGames.Demos.DemoAnimator.CameraWork>(); if (_cameraWork != null) { if (photonView.isMine) { _cameraWork.OnStartFollowing(); } } else { Debug.LogError("<Color=Red><a>Missing</a></Color> CameraWork Component on playerPrefab.", this); } // Unity 5.4 has a new scene management. register a method to call CalledOnLevelWasLoaded. UnityEngine.SceneManagement.SceneManager.sceneLoaded += (scene, loadingMode) => { this.CalledOnLevelWasLoaded(scene.buildIndex); }; }