/// <summary> /// Returns the instance of BackgroundDimensions for the currently active level. /// </summary> /// <returns>An instance of BackgroundDimensions.</returns> private BackgroundDimensions GetBackgroundDimensionSecure() { GameObject[] bg = GameObject.FindGameObjectsWithTag("BackgroundBounds"); if (debug) { Debug.Log("CAM>>" + bg + " length=" + bg.Length); } BackgroundDimensions bgDim = null; foreach (var item in bg) { if (debug) { Debug.Log(item.gameObject.name); } if (bgDim == null) { bgDim = item.GetComponent <BackgroundDimensions>(); if (bgDim != null) { Debug.Log("Found CameraBounds: CAM>>" + bgDim); } } } return(bgDim); }
// Use this for initialization void Start() { cameraScript = GetComponentInChildren <CameraFollowPlayer>(); Debug.Log("CameraPan>>" + cameraScript); camHeight = cameraScript.cameraHeight; Debug.Log("CameraPan>> camHeight instantiated " + camHeight); Bounds b = cameraScript.OrthographicBounds(); bgDim = cameraScript.GetBackroundDim(); }
/// <summary> /// Returns the instance of BackgroundDimensions for the currently active level. /// </summary> /// <returns>An instance of BackgroundDimensions.</returns> private BackgroundDimensions GetBackgroundDimensionSecure() { GameObject[] bg = GameObject.FindGameObjectsWithTag("BackgroundBounds"); BackgroundDimensions bgDim = null; foreach (var item in bg) { if (bgDim == null) { bgDim = item.GetComponent <BackgroundDimensions>(); } } return(bgDim); }
// Use this for initialization void Start() { levelController = LevelController.GetCurrentLevelController(); currentPosition = new Vector3(followingPos.transform.position.x, followingPos.transform.position.y, -10); transform.position = currentPosition; bgDim = GetBackgroundDimensionSecure(); if (debug) { Debug.Log("CAM>>" + bgDim); } Assert.IsTrue(bgDim != null, "BG DIMENSIONS NOT IN LEVEL!"); backgroundStart = bgDim.GetBackgroundStart(); backgroundEnd = bgDim.GetBackgroundEnd(); cameraHeight = 4f; }