Example #1
0
        private GameObject FormatBackgrounds(List <Background> list)
        {
//			GameObject backgroundsContainer =
//				new GameObject("Backgrounds") { tag = TilemapConstants.BACKGROUND_CONTAINER_TAG };
            GameObject backgroundCamera = GameObject.FindWithTag(Tags.BACKGROUND_CAMERA_TAG);

            if (backgroundCamera == null)
            {
                Debug.Log("Creating new camera");
                backgroundCamera = new GameObject(Tags.BACKGROUND_CAMERA_TAG)
                {
                    tag = Tags.BACKGROUND_CAMERA_TAG
                };
                backgroundCamera.transform.position = new Vector3(0, 0, -50);
                backgroundCamera.AddComponent <CameraMovement>();
                Camera bgCam = backgroundCamera.TryAddComponent <Camera>();
                bgCam.orthographic     = true;
                bgCam.orthographicSize = 7;
                PixelPerfectCamera ppCam = backgroundCamera.TryAddComponent <PixelPerfectCamera>();
                ppCam.InitializeCamera(settings);
                CreateBackgroundObjects(list, backgroundCamera);
            }
            else
            {
                backgroundCamera.TryAddComponent <CameraMovement>();
                if (overwriteBackgrounds)
                {
                    backgroundCamera.transform.RemoveAllChildren();
                    CreateBackgroundObjects(list, backgroundCamera);
                }
            }

            return(backgroundCamera);
        }