protected virtual void OnSceneGUI()
 {
     SceneViewOverlay.Window(Contents.headerPlayControls, SceneViewGUICallback, (int)SceneViewOverlay.Ordering.ParticleEffect, SceneViewOverlay.WindowDisplayOption.OneWindowPerTitle);
 }
Example #2
0
 public override void OnEnable()
 {
     base.titleContent = base.GetLocalizedTitleContent();
     this.m_RectSelection = new RectSelection(this);
     if (this.grid == null)
     {
         this.grid = new SceneViewGrid();
     }
     this.grid.Register(this);
     if (this.svRot == null)
     {
         this.svRot = new SceneViewRotation();
     }
     this.svRot.Register(this);
     base.autoRepaintOnSceneChange = true;
     this.m_Rotation.valueChanged.AddListener(new UnityAction(this.Repaint));
     this.m_Position.valueChanged.AddListener(new UnityAction(this.Repaint));
     this.m_Size.valueChanged.AddListener(new UnityAction(this.Repaint));
     this.m_Ortho.valueChanged.AddListener(new UnityAction(this.Repaint));
     base.wantsMouseMove = true;
     base.dontClearBackground = true;
     s_SceneViews.Add(this);
     this.m_Lighting = EditorGUIUtility.IconContent("SceneviewLighting", "Lighting|The scene lighting is used when toggled on. When toggled off a light attached to the scene view camera is used.");
     this.m_Fx = EditorGUIUtility.IconContent("SceneviewFx", "Fx|Toggles skybox, fog and lens flare effects.");
     this.m_AudioPlayContent = EditorGUIUtility.IconContent("SceneviewAudio", "AudioPlay|Toggles audio on or off.");
     this.m_GizmosContent = new GUIContent("Gizmos");
     this.m_2DModeContent = new GUIContent("2D");
     this.m_SceneViewOverlay = new SceneViewOverlay(this);
     EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction) Delegate.Combine(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(SceneView.RepaintAll));
     this.m_DraggingLockedState = DraggingLockedState.NotDragging;
     this.CreateSceneCameraAndLights();
     if (this.m_2DMode)
     {
         this.LookAt(this.pivot, Quaternion.identity, this.size, true, true);
     }
     base.OnEnable();
 }
        /// <summary>
        /// Main GUI update for the tool, calls every secondary methods to place points, update lines and compute the cut
        /// </summary>
        /// <param name="window">current window calling the tool : SceneView</param>
        public override void OnToolGUI(EditorWindow window)
        {
            Event evt = Event.current;

            SceneViewOverlay.Window(m_OverlayTitle, OnOverlayGUI, 0, SceneViewOverlay.WindowDisplayOption.OneWindowPerTitle);

            if (polygon == null)
            {
                return;
            }

            if (polygon.polyEditMode == PolyShape.PolyEditMode.None)
            {
                return;
            }

            // used when finishing a loop by clicking the first created point
            if (m_NextMouseUpAdvancesMode && evt.type == EventType.MouseUp)
            {
                evt.Use();

                m_NextMouseUpAdvancesMode = false;

                if (SceneCameraIsAlignedWithPolyUp())
                {
                    SetPolyEditMode(PolyShape.PolyEditMode.Edit);
                }
                else
                {
                    SetPolyEditMode(PolyShape.PolyEditMode.Height);
                }
            }

            if (m_IsModifyingVertices && (
                    evt.type == EventType.MouseUp ||
                    evt.type == EventType.Ignore ||
                    evt.type == EventType.KeyDown ||
                    evt.type == EventType.KeyUp))
            {
                OnFinishVertexMovement();
            }

            if (evt.type == EventType.KeyDown)
            {
                HandleKeyEvent(evt);
            }

            //The user can press a key to exit editing mode,
            //leading to null polygon at this point
            if (polygon == null)
            {
                return;
            }

            if (EditorHandleUtility.SceneViewInUse(evt))
            {
                return;
            }

            m_ControlId = GUIUtility.GetControlID(FocusType.Passive);

            if (evt.type == EventType.Layout)
            {
                HandleUtility.AddDefaultControl(m_ControlId);
            }

            if (polygon.polyEditMode == PolyShape.PolyEditMode.Path && !m_PlacingPoint)
            {
                m_MouseCursor = MouseCursor.ArrowPlus;
            }
            else if ((GUIUtility.hotControl != 0) || m_PlacingPoint)
            {
                m_MouseCursor = MouseCursor.MoveArrow;
            }
            else
            {
                m_MouseCursor = MouseCursor.Arrow;
            }

            if (evt.type == EventType.MouseMove)
            {
                SceneView.RepaintAll();
            }

            DoPointPlacement();
            DoExistingPointsGUI();

            if (evt.type == EventType.Repaint)
            {
                DoExistingLinesGUI();
                Rect sceneViewRect = window.position;
                sceneViewRect.x = 0;
                sceneViewRect.y = 0;
                SceneView.AddCursorRect(sceneViewRect, m_MouseCursor);
            }
        }
Example #4
0
		public override void OnEnable()
		{
			this.m_RectSelection = new RectSelection(this);
			if (this.grid == null)
			{
				this.grid = new SceneViewGrid();
			}
			this.grid.Register(this);
			if (this.svRot == null)
			{
				this.svRot = new SceneViewRotation();
			}
			this.svRot.Register(this);
			base.autoRepaintOnSceneChange = true;
			this.m_Rotation.valueChanged.AddListener(new UnityAction(base.Repaint));
			this.m_Position.valueChanged.AddListener(new UnityAction(base.Repaint));
			this.m_Size.valueChanged.AddListener(new UnityAction(base.Repaint));
			this.m_Ortho.valueChanged.AddListener(new UnityAction(base.Repaint));
			base.wantsMouseMove = true;
			base.dontClearBackground = true;
			SceneView.s_SceneViews.Add(this);
			this.m_Lighting = EditorGUIUtility.IconContent("SceneviewLighting");
			this.m_Fx = EditorGUIUtility.IconContent("SceneviewFx");
			this.m_AudioPlayContent = EditorGUIUtility.IconContent("SceneviewAudio");
			this.m_GizmosContent = new GUIContent("Gizmos");
			this.m_2DModeContent = new GUIContent("2D");
			this.m_SceneViewOverlay = new SceneViewOverlay(this);
			EditorApplication.modifierKeysChanged = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.modifierKeysChanged, new EditorApplication.CallbackFunction(SceneView.RepaintAll));
			this.m_DraggingLockedState = SceneView.DraggingLockedState.NotDragging;
			this.CreateSceneCameraAndLights();
			base.OnEnable();
		}