Ejemplo n.º 1
0
 /**
  * <summary>Unregisters a BackgroundImage, so that it is no longer updated</summary>
  * <param name = "_object">The BackgroundImage to unregister</param>
  */
 public void Unregister(BackgroundImage _object)
 {
     if (backgroundImages.Contains(_object))
     {
         backgroundImages.Remove(_object);
     }
 }
Ejemplo n.º 2
0
 /**
  * <summary>Registers a BackgroundImage, so that it can be updated</summary>
  * <param name = "_object">The BackgroundImage to register</param>
  */
 public void Register(BackgroundImage _object)
 {
     if (!backgroundImages.Contains(_object))
     {
         backgroundImages.Add(_object);
     }
 }
		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);
		}
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
            }
        }
        public override void OnInspectorGUI()
        {
            EditorGUILayout.BeginVertical("Button");

                        #if ALLOW_LEGACY_UI
            _target.backgroundMethod25D = (BackgroundImage.BackgroundMethod25D)CustomGUILayout.EnumPopup("Method:", _target.backgroundMethod25D, string.Empty, "How 2.5D backgrounds are renderered");
            switch (_target.backgroundMethod25D)
            {
            case BackgroundImage.BackgroundMethod25D.GUITexture:
                if (Object.FindObjectOfType <BackgroundImageUI>() != null)
                {
                    BackgroundImageUI.Instance.ClearTexture(null);
                }
                if (_target.GUITexture == null)
                {
                    EditorGUILayout.HelpBox("A GUITexture component must be attached to this object for the chosen method to work.", MessageType.Warning);
                }
                break;

            case BackgroundImage.BackgroundMethod25D.UnityUI:
                _target = ShowUnityUIMethod(_target);
                break;
            }
                        #else
            _target = ShowUnityUIMethod(_target);
                        #endif

                        #if ALLOW_VIDEO
            if (_target.backgroundImageSource == BackgroundImage.BackgroundImageSource.VideoClip)
            {
                EditorGUILayout.EndVertical();
                UnityVersionHandler.CustomSetDirty(_target);
                return;
            }
                        #endif

                        #if UNITY_STANDALONE && (UNITY_5 || UNITY_2017_1_OR_NEWER || UNITY_PRO_LICENSE) && !UNITY_2018_2_OR_NEWER
            EditorGUILayout.LabelField("When playing a MovieTexture:");
            _target.loopMovie = CustomGUILayout.Toggle("Loop clip?", _target.loopMovie, string.Empty, "If True, then any MovieTexture set as the background will be looped");
            _target.restartMovieWhenTurnOn = CustomGUILayout.Toggle("Restart clip each time?", _target.restartMovieWhenTurnOn, string.Empty, "If True, then any MovieTexture set as the background will start from the beginning when the associated Camera is activated");
                        #endif

            EditorGUILayout.EndVertical();
            UnityVersionHandler.CustomSetDirty(_target);
        }
        private BackgroundImage ShowUnityUIMethod(BackgroundImage _target)
        {
                        #if ALLOW_VIDEO
            _target.backgroundImageSource = (BackgroundImage.BackgroundImageSource)CustomGUILayout.EnumPopup("Background type:", _target.backgroundImageSource, string.Empty, "What type of asset is used as a background");
            switch (_target.backgroundImageSource)
            {
            case BackgroundImage.BackgroundImageSource.Texture:
                _target.backgroundTexture = (Texture)CustomGUILayout.ObjectField <Texture> ("Texture:", _target.backgroundTexture, false, string.Empty, "The texture to display full-screen");
                break;

            case BackgroundImage.BackgroundImageSource.VideoClip:
                _target.backgroundTexture = (Texture)CustomGUILayout.ObjectField <Texture> ("Placeholder texture:", _target.backgroundTexture, false, string.Empty, "The texture to display full-screen while the VideoClip is being prepared");
                _target.backgroundVideo   = (VideoClip)CustomGUILayout.ObjectField <VideoClip> ("Video clip:", _target.backgroundVideo, false, string.Empty, "The VideoClip to animate full-screen");
                break;
            }
                        #else
            _target.backgroundTexture = (Texture)CustomGUILayout.ObjectField <Texture> ("Background texture:", _target.backgroundTexture, false, string.Empty, "The texture to display full-screen");
                        #endif

            return(_target);
        }
Ejemplo n.º 8
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.BeginVertical("Button");

            _target = ShowUnityUIMethod(_target);

                        #if ALLOW_VIDEO
            if (_target.backgroundImageSource == BackgroundImage.BackgroundImageSource.VideoClip)
            {
                EditorGUILayout.EndVertical();
                UnityVersionHandler.CustomSetDirty(_target);
                return;
            }
                        #endif

                        #if UNITY_STANDALONE && !UNITY_2018_2_OR_NEWER
            EditorGUILayout.LabelField("When playing a MovieTexture:");
            _target.loopMovie = CustomGUILayout.Toggle("Loop clip?", _target.loopMovie, string.Empty, "If True, then any MovieTexture set as the background will be looped");
            _target.restartMovieWhenTurnOn = CustomGUILayout.Toggle("Restart clip each time?", _target.restartMovieWhenTurnOn, string.Empty, "If True, then any MovieTexture set as the background will start from the beginning when the associated Camera is activated");
                        #endif

            EditorGUILayout.EndVertical();
            UnityVersionHandler.CustomSetDirty(_target);
        }
Ejemplo n.º 9
0
 /**
  * <summary>Unregisters a BackgroundImage, so that it is no longer updated</summary>
  * <param name = "_object">The BackgroundImage to unregister</param>
  */
 public void Unregister(BackgroundImage _object)
 {
     backgroundImages.Remove(_object);
 }
Ejemplo n.º 10
0
 /**
  * <summary>Registers a BackgroundImage, so that it can be updated</summary>
  * <param name = "_object">The BackgroundImage to register</param>
  */
 public void Register(BackgroundImage _object)
 {
     backgroundImages.Add(_object);
 }
Ejemplo n.º 11
0
 private void OnEnable()
 {
     _target = (BackgroundImage)target;
 }