//======================================== // Unity's function //------------------------------ protected void Awake() { mTargetList = new JCS_Vector <JCS_Player>(); mAudioListener = this.GetComponent <AudioListener>(); // find the camera in the scene first mJCS_2DCamera = (JCS_2DCamera)FindObjectOfType(typeof(JCS_2DCamera)); // if still null spawn a default one! if (mJCS_2DCamera == null) { JCS_Debug.LogError("There is not JCS_2DCamera attach to, spawn a default one!"); // Spawn a Default one! this.mJCS_2DCamera = JCS_Utility.SpawnGameObject( JCS_2DCamera.JCS_2DCAMERA_PATH, transform.position, transform.rotation).GetComponent <JCS_2DCamera>(); } mJCS_2DCamera.SetFollowTarget(this.transform); // record down the fild of view mTargetFieldOfView = mJCS_2DCamera.fieldOfView; }
//---------------------- // Protected Functions //---------------------- // Private Functions //////////// 2D ////////////////////////// /// <summary> /// Iniialize the camera. /// </summary> private void InitCamera() { if (mJCS_2DCamera == null) { JCS_Debug.LogError("There is not JCS_2DCamera attach to, spawn a default one!"); // Spawn a Default one! this.mJCS_2DCamera = JCS_Utility.SpawnGameObject( JCS_2DCamera.JCS_2DCAMERA_PATH, transform.position, transform.rotation).GetComponent <JCS_2DCamera>(); } // if still null, setting error!! if (mJCS_2DCamera == null) { JCS_Debug.LogError("The object spawn does not have the \"JCS_2DCamera\" components..."); return; } // set target to follow! mJCS_2DCamera.SetFollowTarget(this.transform); }