void OnEnable() { m_Camera2D = Camera.main.GetComponent <Camera2D>(); if (m_Camera2D != null) { m_Camera2D.AddFocus(this); } }
//When the ball becomes enabled void OnEnable() { //Set initial speed body.AddForce(Random.insideUnitSphere.normalized * Speed / Time.fixedDeltaTime); //Tell the camera to follow this ball m_Camera2D = Camera.main.GetComponent <Camera2D>(); m_CameraShake = Camera.main.GetComponent <Shake>(); if (m_Camera2D != null) { m_Camera2D.AddFocus(this); } }
/// <summary> /// Causes the change of the focus list to the given focus2D array. /// </summary> public void Activate() { //Check if the camera2D exists. if (m_Camera2D == null) { #if UNITY_EDITOR Debug.LogError(CAMERA_IS_NULL); #endif return; } m_Camera2D.ClearFocusList(); m_Camera2D.AddFocus(m_NewFocusList); }