public override void OnInspectorGUI ()
		{
			GameCamera25D _target = (GameCamera25D) target;
			
			EditorGUILayout.BeginVertical ("Button");
			EditorGUILayout.LabelField ("Background image", EditorStyles.boldLabel);
		
			EditorGUILayout.BeginHorizontal ();
			_target.backgroundImage = (BackgroundImage) EditorGUILayout.ObjectField ("Prefab:", _target.backgroundImage, typeof (BackgroundImage), true);
			
			if (_target.backgroundImage)
			{
				if (GUILayout.Button ("Set as active", GUILayout.MaxWidth (90f)))
				{
					Undo.RecordObject (_target, "Set active background");
					
					_target.SetActiveBackground ();
					SnapCameraInEditor (_target);
				}
			}
			else
			{
				if (GUILayout.Button ("Create", GUILayout.MaxWidth (90f)))
				{
					Undo.RecordObject (_target, "Create Background Image");
					BackgroundImage newBackgroundImage = SceneManager.AddPrefab ("SetGeometry", "BackgroundImage", true, false, true).GetComponent <BackgroundImage>();
					
					string cameraName = _target.gameObject.name;

					newBackgroundImage.gameObject.name = AdvGame.UniqueName (cameraName + ": Background");
					_target.backgroundImage = newBackgroundImage;
				}
			}
			
			EditorGUILayout.EndHorizontal ();

			if (!_target.GetComponent <Camera>().orthographic)
			{
				EditorGUILayout.Space ();
				EditorGUILayout.LabelField ("Perspective offset", EditorStyles.boldLabel);
				_target.perspectiveOffset.x = EditorGUILayout.Slider ("Horizontal:", _target.perspectiveOffset.x, -0.05f, 0.05f);
				_target.perspectiveOffset.y = EditorGUILayout.Slider ("Vertical:", _target.perspectiveOffset.y, -0.05f, 0.05f);
			}

			EditorGUILayout.EndVertical ();

			if (_target.isActiveEditor)
			{
				UpdateCameraSnap (_target);
			}
			
			UnityVersionHandler.CustomSetDirty (_target);
		}
示例#2
0
        public override void OnInspectorGUI()
        {
            GameCamera25D _target = (GameCamera25D)target;

            CustomGUILayout.BeginVertical();
            EditorGUILayout.LabelField("Background image", EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal();
            _target.backgroundImage = (BackgroundImage)CustomGUILayout.ObjectField <BackgroundImage> ("Background:", _target.backgroundImage, true, "", "The BackgroundImage to display underneath all scene objects");

            if (_target.backgroundImage)
            {
                if (!Application.isPlaying && GUILayout.Button("Set as active", GUILayout.MaxWidth(90f)))
                {
                    Undo.RecordObject(_target, "Set active background");

                    _target.SetActiveBackground();
                }
            }
            else
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(90f)))
                {
                    Undo.RecordObject(_target, "Create Background Image");
                    BackgroundImage newBackgroundImage = SceneManager.AddPrefab("SetGeometry", "BackgroundImage", true, false, true).GetComponent <BackgroundImage>();

                    string cameraName = _target.gameObject.name;

                    newBackgroundImage.gameObject.name = AdvGame.UniqueName(cameraName + ": Background");
                    _target.backgroundImage            = newBackgroundImage;
                }
            }

            EditorGUILayout.EndHorizontal();

            if (MainCamera.AllowProjectionShifting(_target.GetComponent <Camera>()))
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Perspective offset", EditorStyles.boldLabel);
                _target.perspectiveOffset.x = CustomGUILayout.Slider("Horizontal:", _target.perspectiveOffset.x, -0.05f, 0.05f, "", "The horizontal offset in perspective from the camera's centre");
                _target.perspectiveOffset.y = CustomGUILayout.Slider("Vertical:", _target.perspectiveOffset.y, -0.05f, 0.05f, "", "The vertical offset in perspective from the camera's centre");
            }

            CustomGUILayout.EndVertical();

            if (_target.isActiveEditor)
            {
                _target.UpdateCameraSnap();
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
示例#3
0
        public override void OnInspectorGUI()
        {
            GameCamera25D _target = (GameCamera25D)target;

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Background image", EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal();
            _target.backgroundImage = (BackgroundImage)EditorGUILayout.ObjectField("Prefab:", _target.backgroundImage, typeof(BackgroundImage), true);

            if (_target.backgroundImage)
            {
                if (GUILayout.Button("Set as active", GUILayout.MaxWidth(90f)))
                {
                    Undo.RecordObject(_target, "Set active background");

                    _target.SetActiveBackground();
                    SnapCameraInEditor(_target);
                }
            }
            else
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(90f)))
                {
                    Undo.RecordObject(_target, "Create Background Image");
                    BackgroundImage newBackgroundImage = SceneManager.AddPrefab("SetGeometry", "BackgroundImage", true, false, true).GetComponent <BackgroundImage>();

                    string cameraName = _target.gameObject.name;

                    newBackgroundImage.gameObject.name = AdvGame.UniqueName(cameraName + ": Background");
                    _target.backgroundImage            = newBackgroundImage;
                }
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            if (_target.isActiveEditor)
            {
                UpdateCameraSnap(_target);
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(_target);
            }
        }
示例#4
0
        public void SetGameCamera(_Camera newCamera)
        {
            if (newCamera == null)
            {
                return;
            }

            if (attachedCamera != null && attachedCamera is GameCamera25D)
            {
                if (newCamera is GameCamera25D)
                {
                }
                else
                {
                    RemoveBackground();
                }
            }

            if (_camera == null && GetComponent <Camera>())
            {
                _camera = GetComponent <Camera>();
            }
            _camera.ResetProjectionMatrix();
            attachedCamera = newCamera;
            attachedCamera.SetCameraComponent();

            if (attachedCamera && attachedCamera._camera)
            {
                _camera.farClipPlane  = attachedCamera._camera.farClipPlane;
                _camera.nearClipPlane = attachedCamera._camera.nearClipPlane;
                _camera.orthographic  = attachedCamera._camera.orthographic;
            }

            // Set LookAt
            if (attachedCamera is GameCamera)
            {
                GameCamera gameCam = (GameCamera)attachedCamera;
                cursorAffectsRotation = gameCam.followCursor;
                lookAtAmount          = gameCam.cursorInfluence;
            }
            else if (attachedCamera is GameCameraAnimated)
            {
                GameCameraAnimated gameCam = (GameCameraAnimated)attachedCamera;
                if (gameCam.animatedCameraType == AnimatedCameraType.SyncWithTargetMovement)
                {
                    cursorAffectsRotation = gameCam.followCursor;
                    lookAtAmount          = gameCam.cursorInfluence;
                }
                else
                {
                    cursorAffectsRotation = false;
                }
            }
            else
            {
                cursorAffectsRotation = false;
            }

            // Set background
            if (attachedCamera is GameCamera25D)
            {
                GameCamera25D cam25D = (GameCamera25D)attachedCamera;
                cam25D.SetActiveBackground();
            }

            // TransparencySortMode
            if (attachedCamera is GameCamera2D)
            {
                _camera.transparencySortMode = TransparencySortMode.Orthographic;
            }
            else if (attachedCamera)
            {
                if (attachedCamera._camera.orthographic)
                {
                    _camera.transparencySortMode = TransparencySortMode.Orthographic;
                }
                else
                {
                    _camera.transparencySortMode = TransparencySortMode.Perspective;
                }
            }

            // UFPS
            if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
            {
                UltimateFPSIntegration._Update(KickStarter.stateHandler.gameState);
            }
        }