FrameSelected() public method

public FrameSelected ( ) : bool
return bool
示例#1
0
        internal void SwitchToEditMode()
        {
            this.m_EditMode = AvatarEditor.EditMode.Starting;
            this.ChangeInspectorLock(true);
            this.sceneSetup = EditorSceneManager.GetSceneManagerSetup();
            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects).name = "Avatar Configuration";
            this.m_GameObject = UnityEngine.Object.Instantiate <GameObject>(this.prefab);
            if (base.serializedObject.FindProperty("m_OptimizeGameObjects").boolValue)
            {
                AnimatorUtility.DeoptimizeTransformHierarchy(this.m_GameObject);
            }
            Dictionary <Transform, bool> modelBones = AvatarSetupTool.GetModelBones(this.m_GameObject.transform, true, null);

            AvatarSetupTool.BoneWrapper[] humanBones = AvatarSetupTool.GetHumanBones(base.serializedObject, modelBones);
            this.m_ModelBones      = AvatarSetupTool.GetModelBones(this.m_GameObject.transform, false, humanBones);
            Selection.activeObject = this.m_GameObject;
            UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(SceneHierarchyWindow));
            for (int i = 0; i < array.Length; i++)
            {
                SceneHierarchyWindow sceneHierarchyWindow = (SceneHierarchyWindow)array[i];
                sceneHierarchyWindow.SetExpandedRecursive(this.m_GameObject.GetInstanceID(), true);
            }
            this.CreateEditor();
            this.m_EditMode    = AvatarEditor.EditMode.Editing;
            this.m_SceneStates = new List <AvatarEditor.SceneStateCache>();
            IEnumerator enumerator = SceneView.sceneViews.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    SceneView sceneView = (SceneView)enumerator.Current;
                    this.m_SceneStates.Add(new AvatarEditor.SceneStateCache
                    {
                        state = new SceneView.SceneViewState(sceneView.sceneViewState),
                        view  = sceneView
                    });
                    sceneView.sceneViewState.showFlares          = false;
                    sceneView.sceneViewState.showMaterialUpdate  = false;
                    sceneView.sceneViewState.showFog             = false;
                    sceneView.sceneViewState.showSkybox          = false;
                    sceneView.sceneViewState.showImageEffects    = false;
                    sceneView.sceneViewState.showParticleSystems = false;
                    sceneView.FrameSelected();
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
        }
示例#2
0
        void DelayedFraming()
        {
            if (m_DelayCounter++ == 1)
            {
                EditorApplication.update -= DelayedFraming;
                m_DelayCounter            = 0;

                // Frame the prefab if still available
                var prefabStage = PrefabStageUtility.GetCurrentPrefabStage();
                if (prefabStage != null)
                {
                    Selection.activeGameObject = prefabStage.prefabContentsRoot;
                    m_SceneView.FrameSelected(false, true);
                }
            }
        }
示例#3
0
 internal void OnGUI(SceneView view)
 {
     if (Mathf.Min(view.position.width, view.position.height) >= 100f)
     {
         if (Event.current.type == EventType.Repaint)
         {
             Profiler.BeginSample("SceneView.AxisSelector");
         }
         Camera camera = view.camera;
         HandleUtility.PushCamera(camera);
         if (camera.orthographic)
         {
             camera.orthographicSize = 0.5f;
         }
         camera.cullingMask        = 0;
         camera.transform.position = (Vector3)(camera.transform.rotation * new Vector3(0f, 0f, -5f));
         camera.clearFlags         = CameraClearFlags.Nothing;
         camera.nearClipPlane      = 0.1f;
         camera.farClipPlane       = 10f;
         camera.fieldOfView        = view.m_Ortho.Fade(70f, 0f);
         SceneView.AddCursorRect(new Rect((view.position.width - 100f) + 22f, 22f, 56f, 102f), MouseCursor.Arrow);
         Handles.SetCamera(new Rect(view.position.width - 100f, 0f, 100f, 100f), camera);
         Handles.BeginGUI();
         Rect position = new Rect((view.position.width - 100f) + 17f, 92f, 66f, 16f);
         if (!view.in2DMode && GUI.Button(position, string.Empty, styles.viewLabelStyleLeftAligned))
         {
             if (Event.current.button == 1)
             {
                 this.DisplayContextMenu(position, view);
             }
             else
             {
                 this.ViewSetOrtho(view, !view.orthographic);
             }
         }
         int   index = 8;
         Rect  rect2 = position;
         float num3  = 0f;
         float num4  = 0f;
         for (int i = 0; i < kDirNames.Length; i++)
         {
             if (i != index)
             {
                 num4 += this.dirNameVisible[i].faded;
                 if (this.dirNameVisible[i].faded > 0f)
                 {
                     num3 += styles.viewLabelStyleLeftAligned.CalcSize(EditorGUIUtility.TempContent(kDirNames[i])).x *this.dirNameVisible[i].faded;
                 }
             }
         }
         if (num4 > 0f)
         {
             num3 /= num4;
         }
         rect2.x += 37f - (num3 * 0.5f);
         rect2.x  = Mathf.RoundToInt(rect2.x);
         for (int j = 0; (j < this.dirNameVisible.Length) && (j < kDirNames.Length); j++)
         {
             if (j != index)
             {
                 Color color = Handles.centerColor;
                 color.a *= this.dirNameVisible[j].faded;
                 if (color.a > 0f)
                 {
                     GUI.color = color;
                     GUI.Label(rect2, kDirNames[j], styles.viewLabelStyleLeftAligned);
                 }
             }
         }
         Color centerColor = Handles.centerColor;
         centerColor.a *= this.faded2Dgray * this.m_Visible.faded;
         if (centerColor.a > 0f)
         {
             GUI.color = centerColor;
             GUI.Label(position, kDirNames[index], styles.viewLabelStyleCentered);
         }
         if (this.faded2Dgray < 1f)
         {
             this.DrawIsoStatusSymbol(new Vector3(rect2.x - 8f, rect2.y + 8.5f, 0f), view, 1f - this.faded2Dgray);
         }
         Handles.EndGUI();
         for (int k = 0; k < 3; k++)
         {
             Vector3 rhs = (Vector3)(kDirectionRotations[k] * Vector3.forward);
             this.dirVisible[k].target = Mathf.Abs(Vector3.Dot(camera.transform.forward, rhs)) < 0.9f;
         }
         float size = HandleUtility.GetHandleSize(Vector3.zero) * 0.2f;
         this.AxisSelectors(view, camera, size, -1f, styles.viewAxisLabelStyle);
         Color color3 = Color.Lerp(Handles.centerColor, Color.gray, this.faded2Dgray);
         color3.a *= this.m_Visible.faded;
         if (color3.a <= 0.1f)
         {
             GUI.enabled = false;
         }
         Handles.color = color3;
         if (Handles.Button(Vector3.zero, Quaternion.identity, size * 0.8f, size, new Handles.DrawCapFunction(Handles.CubeCap)) && !view.in2DMode)
         {
             if (Event.current.clickCount == 2)
             {
                 view.FrameSelected();
             }
             else if (Event.current.shift || (Event.current.button == 2))
             {
                 this.ViewFromNiceAngle(view, true);
             }
             else
             {
                 this.ViewSetOrtho(view, !view.orthographic);
             }
         }
         this.AxisSelectors(view, camera, size, 1f, styles.viewAxisLabelStyle);
         GUI.enabled = true;
         if (!view.in2DMode && (Event.current.type == EditorGUIUtility.swipeGestureEventType))
         {
             Vector3 up;
             Event   current = Event.current;
             if (current.delta.y > 0f)
             {
                 up = Vector3.up;
             }
             else if (current.delta.y < 0f)
             {
                 up = -Vector3.up;
             }
             else if (current.delta.x < 0f)
             {
                 up = Vector3.right;
             }
             else
             {
                 up = -Vector3.right;
             }
             Vector3 direction = -up - ((Vector3)(Vector3.forward * 0.9f));
             direction = view.camera.transform.TransformDirection(direction);
             float num9 = 0f;
             int   dir  = 0;
             for (int m = 0; m < 6; m++)
             {
                 float num12 = Vector3.Dot((Vector3)(kDirectionRotations[m] * -Vector3.forward), direction);
                 if (num12 > num9)
                 {
                     num9 = num12;
                     dir  = m;
                 }
             }
             this.ViewAxisDirection(view, dir);
             Event.current.Use();
         }
         HandleUtility.PopCamera(camera);
         Handles.SetCamera(camera);
         if (Event.current.type == EventType.Repaint)
         {
             Profiler.EndSample();
         }
     }
 }
示例#4
0
        // Ensure all controlIDs used in this OnGUI are permanent controlIDs so this method can be called
        // in different places for handling input early and rendering late.
        internal void OnGUI(SceneView view)
        {
            float screenSize = Mathf.Min(view.position.width, view.position.height);

            if (screenSize < kRotationSize)
            {
                return;
            }

            if (Event.current.type == EventType.Repaint)
            {
                Profiler.BeginSample("SceneView.AxisSelector");
            }

            HandleContextClick(view);

            // This is a pretty weird way of doing things, but it works, so...
            Camera cam = view.camera;

            HandleUtility.PushCamera(cam);
            if (cam.orthographic)
            {
                cam.orthographicSize = .5f;
            }

            cam.cullingMask        = 0;
            cam.transform.position = cam.transform.rotation * new Vector3(0, 0, -5);
            cam.clearFlags         = CameraClearFlags.Nothing;
            cam.nearClipPlane      = .1f;
            cam.farClipPlane       = 10;
            cam.fieldOfView        = view.m_Ortho.Fade(70, 0);

            SceneView.AddCursorRect(new Rect(view.position.width - kRotationSize + kRotationMenuInset, kRotationMenuInset, kRotationSize - 2 * kRotationMenuInset, kRotationSize + 24 - kRotationMenuInset), MouseCursor.Arrow);

            Handles.SetCamera(new Rect(view.position.width - kRotationSize, 0, kRotationSize, kRotationSize), cam);

            Handles.BeginGUI();

            DrawRotationLock(view);
            DrawLabels(view);

            Handles.EndGUI();

            // animate visibility of three axis widgets
            for (int i = 0; i < 3; ++i)
            {
                Vector3 direction = kDirectionRotations[i] * Vector3.forward;
                dirVisible[i].target = Mathf.Abs(Vector3.Dot(cam.transform.forward, direction)) < 0.9f;
            }

            float size = HandleUtility.GetHandleSize(Vector3.zero) * .2f;

            // Do axes behind the center one
            AxisSelectors(view, cam, size, -1.0f, styles.viewAxisLabelStyle);

            // Do center handle

            Color centerColor = Handles.centerColor;

            centerColor    = Color.Lerp(centerColor, Color.gray, faded2Dgray);
            centerColor.a *= fadedVisibility;
            if (centerColor.a <= 0.1f || view.isRotationLocked)
            {
                GUI.enabled = false;
            }

            Handles.color = centerColor;
            if (Handles.Button(m_CenterButtonControlID, Vector3.zero, Quaternion.identity, size * 0.8f, size, Handles.CubeHandleCap) && !view.in2DMode && !view.isRotationLocked)
            {
                if (Event.current.clickCount == 2)
                {
                    view.FrameSelected();
                }
                else
                {
                    // If middle-click or shift-click, choose a perspective view from a nice angle,
                    // similar to in Unity 3.5.
                    if (Event.current.shift || Event.current.button == 2)
                    {
                        ViewFromNiceAngle(view, true);
                    }
                    // Else, toggle perspective
                    else
                    {
                        ViewSetOrtho(view, !view.orthographic);
                    }
                }
            }

            // Do axes in front of the center one
            AxisSelectors(view, cam, size, 1.0f, styles.viewAxisLabelStyle);

            GUI.enabled = true;

            if (!view.in2DMode && !view.isRotationLocked)
            {
                // Swipe handling
                if (Event.current.type == EditorGUIUtility.swipeGestureEventType)
                {
                    // Get swipe dir as Vector3
                    Event   evt = Event.current;
                    Vector3 swipeDir;
                    if (evt.delta.y > 0)
                    {
                        swipeDir = Vector3.up;
                    }
                    else if (evt.delta.y < 0)
                    {
                        swipeDir = -Vector3.up;
                    }
                    else if (evt.delta.x < 0) // delta x inverted for some reason
                    {
                        swipeDir = Vector3.right;
                    }
                    else
                    {
                        swipeDir = -Vector3.right;
                    }

                    // Inverse swipe dir, so swiping down will go to top view etc.
                    // This is consistent with how we do orbiting, where moving the mouse down sees the object more from above etc.
                    // Also, make swipe dir point almost 45 degrees in towards the camera.
                    // This means the swipe will pick the closest axis in the swiped direction,
                    // instead of picking the one closest to being 90 degrees away.
                    Vector3 goalVector = -swipeDir - Vector3.forward * 0.9f;

                    // Transform swipe dir by camera transform, so up is camera's local up, etc.
                    goalVector = view.camera.transform.TransformDirection(goalVector);

                    // Get global axis that's closest to the swipe dir vector
                    float bestDotProduct = 0;
                    int   dir            = 0;
                    for (int i = 0; i < 6; i++)
                    {
                        // Note that kDirectionRotations are not the forward direction of each dir;
                        // it's the back direction *towards* the camera.
                        float dotProduct = Vector3.Dot(kDirectionRotations[i] * -Vector3.forward, goalVector);
                        if (dotProduct > bestDotProduct)
                        {
                            bestDotProduct = dotProduct;
                            dir            = i;
                        }
                    }

                    // Look along chosen axis
                    ViewAxisDirection(view, dir);
                    Event.current.Use();
                }
            }

            HandleUtility.PopCamera(cam);
            Handles.SetCamera(cam);

            if (Event.current.type == EventType.Repaint)
            {
                Profiler.EndSample();
            }
        }
示例#5
0
        internal void OnGUI(SceneView view)
        {
            float num = Mathf.Min(view.position.width, view.position.height);

            if (num < 100f)
            {
                return;
            }
            if (Event.current.type == EventType.Repaint)
            {
                Profiler.BeginSample("SceneView.AxisSelector");
            }
            this.HandleContextClick(view);
            Camera camera = view.camera;

            HandleUtility.PushCamera(camera);
            if (camera.orthographic)
            {
                camera.orthographicSize = 0.5f;
            }
            camera.cullingMask        = 0;
            camera.transform.position = camera.transform.rotation * new Vector3(0f, 0f, -5f);
            camera.clearFlags         = CameraClearFlags.Nothing;
            camera.nearClipPlane      = 0.1f;
            camera.farClipPlane       = 10f;
            camera.fieldOfView        = view.m_Ortho.Fade(70f, 0f);
            SceneView.AddCursorRect(new Rect(view.position.width - 100f + 22f, 22f, 56f, 102f), MouseCursor.Arrow);
            Handles.SetCamera(new Rect(view.position.width - 100f, 0f, 100f, 100f), camera);
            Handles.BeginGUI();
            this.DrawLabels(view);
            Handles.EndGUI();
            for (int i = 0; i < 3; i++)
            {
                Vector3 rhs = SceneViewRotation.kDirectionRotations[i] * Vector3.forward;
                this.dirVisible[i].target = (Mathf.Abs(Vector3.Dot(camera.transform.forward, rhs)) < 0.9f);
            }
            float num2 = HandleUtility.GetHandleSize(Vector3.zero) * 0.2f;

            this.AxisSelectors(view, camera, num2, -1f, SceneViewRotation.styles.viewAxisLabelStyle);
            Color color = Handles.centerColor;

            color    = Color.Lerp(color, Color.gray, this.faded2Dgray);
            color.a *= this.m_Visible.faded;
            if (color.a <= 0.1f)
            {
                GUI.enabled = false;
            }
            Handles.color = color;
            if (Handles.Button(this.m_CenterButtonControlID, Vector3.zero, Quaternion.identity, num2 * 0.8f, num2, new Handles.DrawCapFunction(Handles.CubeCap)) && !view.in2DMode)
            {
                if (Event.current.clickCount == 2)
                {
                    view.FrameSelected();
                }
                else if (Event.current.shift || Event.current.button == 2)
                {
                    this.ViewFromNiceAngle(view, true);
                }
                else
                {
                    this.ViewSetOrtho(view, !view.orthographic);
                }
            }
            this.AxisSelectors(view, camera, num2, 1f, SceneViewRotation.styles.viewAxisLabelStyle);
            GUI.enabled = true;
            if (!view.in2DMode && Event.current.type == EditorGUIUtility.swipeGestureEventType)
            {
                Event   current = Event.current;
                Vector3 a;
                if (current.delta.y > 0f)
                {
                    a = Vector3.up;
                }
                else if (current.delta.y < 0f)
                {
                    a = -Vector3.up;
                }
                else if (current.delta.x < 0f)
                {
                    a = Vector3.right;
                }
                else
                {
                    a = -Vector3.right;
                }
                Vector3 vector = -a - Vector3.forward * 0.9f;
                vector = view.camera.transform.TransformDirection(vector);
                float num3 = 0f;
                int   dir  = 0;
                for (int j = 0; j < 6; j++)
                {
                    float num4 = Vector3.Dot(SceneViewRotation.kDirectionRotations[j] * -Vector3.forward, vector);
                    if (num4 > num3)
                    {
                        num3 = num4;
                        dir  = j;
                    }
                }
                this.ViewAxisDirection(view, dir);
                Event.current.Use();
            }
            HandleUtility.PopCamera(camera);
            Handles.SetCamera(camera);
            if (Event.current.type == EventType.Repaint)
            {
                Profiler.EndSample();
            }
        }
 internal void OnGUI(SceneView view)
 {
   if ((double) Mathf.Min(view.position.width, view.position.height) < 100.0)
     return;
   if (Event.current.type == EventType.Repaint)
     Profiler.BeginSample("SceneView.AxisSelector");
   this.HandleContextClick(view);
   Camera camera = view.camera;
   HandleUtility.PushCamera(camera);
   if (camera.orthographic)
     camera.orthographicSize = 0.5f;
   camera.cullingMask = 0;
   camera.transform.position = camera.transform.rotation * new Vector3(0.0f, 0.0f, -5f);
   camera.clearFlags = CameraClearFlags.Nothing;
   camera.nearClipPlane = 0.1f;
   camera.farClipPlane = 10f;
   camera.fieldOfView = view.m_Ortho.Fade(70f, 0.0f);
   SceneView.AddCursorRect(new Rect((float) ((double) view.position.width - 100.0 + 22.0), 22f, 56f, 102f), MouseCursor.Arrow);
   Handles.SetCamera(new Rect(view.position.width - 100f, 0.0f, 100f, 100f), camera);
   Handles.BeginGUI();
   this.DrawLabels(view);
   Handles.EndGUI();
   for (int index = 0; index < 3; ++index)
   {
     Vector3 rhs = SceneViewRotation.kDirectionRotations[index] * Vector3.forward;
     this.dirVisible[index].target = (double) Mathf.Abs(Vector3.Dot(camera.transform.forward, rhs)) < 0.899999976158142;
   }
   float num1 = HandleUtility.GetHandleSize(Vector3.zero) * 0.2f;
   this.AxisSelectors(view, camera, num1, -1f, SceneViewRotation.styles.viewAxisLabelStyle);
   Color color = Color.Lerp(Handles.centerColor, Color.gray, this.faded2Dgray);
   color.a *= this.m_Visible.faded;
   if ((double) color.a <= 0.100000001490116)
     GUI.enabled = false;
   Handles.color = color;
   if (Handles.Button(this.m_CenterButtonControlID, Vector3.zero, Quaternion.identity, num1 * 0.8f, num1, new Handles.DrawCapFunction(Handles.CubeCap)) && !view.in2DMode)
   {
     if (Event.current.clickCount == 2)
       view.FrameSelected();
     else if (Event.current.shift || Event.current.button == 2)
       this.ViewFromNiceAngle(view, true);
     else
       this.ViewSetOrtho(view, !view.orthographic);
   }
   this.AxisSelectors(view, camera, num1, 1f, SceneViewRotation.styles.viewAxisLabelStyle);
   GUI.enabled = true;
   if (!view.in2DMode && Event.current.type == EditorGUIUtility.swipeGestureEventType)
   {
     Event current = Event.current;
     Vector3 direction = -((double) current.delta.y <= 0.0 ? ((double) current.delta.y >= 0.0 ? ((double) current.delta.x >= 0.0 ? -Vector3.right : Vector3.right) : -Vector3.up) : Vector3.up) - Vector3.forward * 0.9f;
     Vector3 rhs = view.camera.transform.TransformDirection(direction);
     float num2 = 0.0f;
     int dir = 0;
     for (int index = 0; index < 6; ++index)
     {
       float num3 = Vector3.Dot(SceneViewRotation.kDirectionRotations[index] * -Vector3.forward, rhs);
       if ((double) num3 > (double) num2)
       {
         num2 = num3;
         dir = index;
       }
     }
     this.ViewAxisDirection(view, dir);
     Event.current.Use();
   }
   HandleUtility.PopCamera(camera);
   Handles.SetCamera(camera);
   if (Event.current.type != EventType.Repaint)
     return;
   Profiler.EndSample();
 }
		internal void OnGUI(SceneView view)
		{
			int num = Mathf.Min(Screen.width, Screen.height);
			if (num < 100)
			{
				return;
			}
			if (Event.current.type == EventType.Repaint)
			{
				Profiler.BeginSample("SceneView.AxisSelector");
			}
			Camera camera = view.camera;
			HandleUtility.PushCamera(camera);
			if (camera.orthographic)
			{
				camera.orthographicSize = 0.5f;
			}
			camera.cullingMask = 0;
			camera.transform.position = camera.transform.rotation * new Vector3(0f, 0f, -5f);
			camera.clearFlags = CameraClearFlags.Nothing;
			camera.nearClipPlane = 0.1f;
			camera.farClipPlane = 10f;
			camera.fieldOfView = view.m_Ortho.Fade(70f, 0f);
			SceneView.AddCursorRect(new Rect((float)(Screen.width - 100 + 22), 22f, 56f, 102f), MouseCursor.Arrow);
			Handles.SetCamera(new Rect((float)(Screen.width - 100), 0f, 100f, 100f), camera);
			Handles.BeginGUI();
			Rect rect = new Rect((float)(Screen.width - 100 + 17), 92f, 66f, 16f);
			if (!view.in2DMode && GUI.Button(rect, string.Empty, SceneViewRotation.styles.viewLabelStyleLeftAligned))
			{
				if (Event.current.button == 1)
				{
					this.DisplayContextMenu(rect, view);
				}
				else
				{
					this.ViewSetOrtho(view, !view.orthographic);
				}
			}
			int num2 = 8;
			Rect position = rect;
			float num3 = 0f;
			float num4 = 0f;
			for (int i = 0; i < SceneViewRotation.kDirNames.Length; i++)
			{
				if (i != num2)
				{
					num4 += this.dirNameVisible[i].faded;
					if (this.dirNameVisible[i].faded > 0f)
					{
						num3 += SceneViewRotation.styles.viewLabelStyleLeftAligned.CalcSize(EditorGUIUtility.TempContent(SceneViewRotation.kDirNames[i])).x * this.dirNameVisible[i].faded;
					}
				}
			}
			if (num4 > 0f)
			{
				num3 /= num4;
			}
			position.x += 37f - num3 * 0.5f;
			position.x = (float)Mathf.RoundToInt(position.x);
			int num5 = 0;
			while (num5 < this.dirNameVisible.Length && num5 < SceneViewRotation.kDirNames.Length)
			{
				if (num5 != num2)
				{
					Color centerColor = Handles.centerColor;
					centerColor.a *= this.dirNameVisible[num5].faded;
					if (centerColor.a > 0f)
					{
						GUI.color = centerColor;
						GUI.Label(position, SceneViewRotation.kDirNames[num5], SceneViewRotation.styles.viewLabelStyleLeftAligned);
					}
				}
				num5++;
			}
			Color centerColor2 = Handles.centerColor;
			centerColor2.a *= this.faded2Dgray * this.m_Visible.faded;
			if (centerColor2.a > 0f)
			{
				GUI.color = centerColor2;
				GUI.Label(rect, SceneViewRotation.kDirNames[num2], SceneViewRotation.styles.viewLabelStyleCentered);
			}
			if (this.faded2Dgray < 1f)
			{
				this.DrawIsoStatusSymbol(new Vector3(position.x - 8f, position.y + 8.5f, 0f), view, 1f - this.faded2Dgray);
			}
			Handles.EndGUI();
			for (int j = 0; j < 3; j++)
			{
				Vector3 rhs = SceneViewRotation.kDirectionRotations[j] * Vector3.forward;
				this.dirVisible[j].target = (Mathf.Abs(Vector3.Dot(camera.transform.forward, rhs)) < 0.9f);
			}
			float num6 = HandleUtility.GetHandleSize(Vector3.zero) * 0.2f;
			this.AxisSelectors(view, camera, num6, -1f, SceneViewRotation.styles.viewAxisLabelStyle);
			Color color = Handles.centerColor;
			color = Color.Lerp(color, Color.gray, this.faded2Dgray);
			color.a *= this.m_Visible.faded;
			if (color.a <= 0.1f)
			{
				GUI.enabled = false;
			}
			Handles.color = color;
			if (Handles.Button(Vector3.zero, Quaternion.identity, num6 * 0.8f, num6, new Handles.DrawCapFunction(Handles.CubeCap)) && !view.in2DMode)
			{
				if (Event.current.clickCount == 2)
				{
					view.FrameSelected();
				}
				else
				{
					if (Event.current.shift || Event.current.button == 2)
					{
						this.ViewFromNiceAngle(view, true);
					}
					else
					{
						this.ViewSetOrtho(view, !view.orthographic);
					}
				}
			}
			this.AxisSelectors(view, camera, num6, 1f, SceneViewRotation.styles.viewAxisLabelStyle);
			GUI.enabled = true;
			if (!view.in2DMode && Event.current.type == EditorGUIUtility.swipeGestureEventType)
			{
				Event current = Event.current;
				Vector3 a;
				if (current.delta.y > 0f)
				{
					a = Vector3.up;
				}
				else
				{
					if (current.delta.y < 0f)
					{
						a = -Vector3.up;
					}
					else
					{
						if (current.delta.x < 0f)
						{
							a = Vector3.right;
						}
						else
						{
							a = -Vector3.right;
						}
					}
				}
				Vector3 vector = -a - Vector3.forward * 0.9f;
				vector = view.camera.transform.TransformDirection(vector);
				float num7 = 0f;
				int dir = 0;
				for (int k = 0; k < 6; k++)
				{
					float num8 = Vector3.Dot(SceneViewRotation.kDirectionRotations[k] * -Vector3.forward, vector);
					if (num8 > num7)
					{
						num7 = num8;
						dir = k;
					}
				}
				this.ViewAxisDirection(view, dir);
				Event.current.Use();
			}
			HandleUtility.PopCamera(camera);
			Handles.SetCamera(camera);
			if (Event.current.type == EventType.Repaint)
			{
				Profiler.EndSample();
			}
		}
示例#8
0
    public void OnSceneGUI()
    {
        current = Event.current;

        if (!current.isKey || current.type != EventType.KeyDown)
        {
            return;
        }

        sceneView   = UnityEditor.SceneView.lastActiveSceneView;
        eulerAngles = sceneView.camera.transform.rotation.eulerAngles;
        rotHelper   = sceneView.camera.transform.rotation;

        switch (current.keyCode)
        {
        case KeyCode.Keypad1:
            if (current.control == false)
            {
                sceneView.LookAtDirect(
                    SceneView.lastActiveSceneView.pivot,
                    Quaternion.Euler(new Vector3(0f, 360f, 0f)));
            }
            else
            {
                sceneView.LookAtDirect(
                    SceneView.lastActiveSceneView.pivot,
                    Quaternion.Euler(new Vector3(0f, 180f, 0f)));
            }
            break;

        case KeyCode.Keypad2:
            sceneView.LookAtDirect(
                SceneView.lastActiveSceneView.pivot,
                rotHelper * Quaternion.Euler(new Vector3(-15f, 0f, 0f)));
            break;

        case KeyCode.Keypad3:
            if (current.control == false)
            {
                sceneView.LookAtDirect(
                    SceneView.lastActiveSceneView.pivot,
                    Quaternion.Euler(new Vector3(0f, 270f, 0f)));
            }
            else
            {
                sceneView.LookAtDirect(
                    SceneView.lastActiveSceneView.pivot,
                    Quaternion.Euler(new Vector3(0f, 90f, 0f)));
            }
            break;

        case KeyCode.Keypad4:
            sceneView.LookAtDirect(
                SceneView.lastActiveSceneView.pivot,
                Quaternion.Euler(new Vector3(eulerAngles.x, eulerAngles.y + 15f, eulerAngles.z)));
            break;

        case KeyCode.Keypad5:
            sceneView.orthographic = !sceneView.orthographic;
            break;

        case KeyCode.Keypad6:
            sceneView.LookAtDirect(
                SceneView.lastActiveSceneView.pivot,
                Quaternion.Euler(new Vector3(eulerAngles.x, eulerAngles.y - 15f, eulerAngles.z)));
            break;

        case KeyCode.Keypad7:
            if (current.control == false)
            {
                sceneView.LookAtDirect(
                    SceneView.lastActiveSceneView.pivot,
                    Quaternion.Euler(new Vector3(90f, 0f, 0f)));
            }
            else
            {
                sceneView.LookAtDirect(
                    SceneView.lastActiveSceneView.pivot,
                    Quaternion.Euler(new Vector3(270f, 0f, 0f)));
            }
            break;

        case KeyCode.Keypad8:
            sceneView.LookAtDirect(
                SceneView.lastActiveSceneView.pivot,
                rotHelper * Quaternion.Euler(new Vector3(15f, 0f, 0f)));
            break;

        case KeyCode.KeypadPeriod:
            if (Selection.transforms.Length == 1)
            {
                sceneView.LookAtDirect(Selection.activeTransform.position, sceneView.camera.transform.rotation);
            }
            else if (Selection.transforms.Length > 1)
            {
                Vector3 tempVec = new Vector3();
                for (int i = 0; i < Selection.transforms.Length; i++)
                {
                    tempVec += Selection.transforms[i].position;
                }
                sceneView.LookAtDirect((tempVec / Selection.transforms.Length), sceneView.camera.transform.rotation);
            }
            break;

        case KeyCode.KeypadMinus:
            SceneView.RepaintAll();
            sceneView.size *= 1.1f;
            break;

        case KeyCode.KeypadPlus:
            SceneView.RepaintAll();
            sceneView.size /= 1.1f;
            break;

        case KeyCode.Keypad0:
            sceneView.FrameSelected();
            break;
        }
    }
示例#9
0
 internal void OnGUI(SceneView view)
 {
     if (Mathf.Min(view.position.width, view.position.height) >= 100f)
     {
         if (Event.current.type == EventType.Repaint)
         {
             Profiler.BeginSample("SceneView.AxisSelector");
         }
         Camera camera = view.camera;
         HandleUtility.PushCamera(camera);
         if (camera.orthographic)
         {
             camera.orthographicSize = 0.5f;
         }
         camera.cullingMask = 0;
         camera.transform.position = (Vector3) (camera.transform.rotation * new Vector3(0f, 0f, -5f));
         camera.clearFlags = CameraClearFlags.Nothing;
         camera.nearClipPlane = 0.1f;
         camera.farClipPlane = 10f;
         camera.fieldOfView = view.m_Ortho.Fade(70f, 0f);
         SceneView.AddCursorRect(new Rect((view.position.width - 100f) + 22f, 22f, 56f, 102f), MouseCursor.Arrow);
         Handles.SetCamera(new Rect(view.position.width - 100f, 0f, 100f, 100f), camera);
         Handles.BeginGUI();
         Rect position = new Rect((view.position.width - 100f) + 17f, 92f, 66f, 16f);
         if (!view.in2DMode && GUI.Button(position, string.Empty, styles.viewLabelStyleLeftAligned))
         {
             if (Event.current.button == 1)
             {
                 this.DisplayContextMenu(position, view);
             }
             else
             {
                 this.ViewSetOrtho(view, !view.orthographic);
             }
         }
         int index = 8;
         Rect rect2 = position;
         float num3 = 0f;
         float num4 = 0f;
         for (int i = 0; i < kDirNames.Length; i++)
         {
             if (i != index)
             {
                 num4 += this.dirNameVisible[i].faded;
                 if (this.dirNameVisible[i].faded > 0f)
                 {
                     num3 += styles.viewLabelStyleLeftAligned.CalcSize(EditorGUIUtility.TempContent(kDirNames[i])).x * this.dirNameVisible[i].faded;
                 }
             }
         }
         if (num4 > 0f)
         {
             num3 /= num4;
         }
         rect2.x += 37f - (num3 * 0.5f);
         rect2.x = Mathf.RoundToInt(rect2.x);
         for (int j = 0; (j < this.dirNameVisible.Length) && (j < kDirNames.Length); j++)
         {
             if (j != index)
             {
                 Color color = Handles.centerColor;
                 color.a *= this.dirNameVisible[j].faded;
                 if (color.a > 0f)
                 {
                     GUI.color = color;
                     GUI.Label(rect2, kDirNames[j], styles.viewLabelStyleLeftAligned);
                 }
             }
         }
         Color centerColor = Handles.centerColor;
         centerColor.a *= this.faded2Dgray * this.m_Visible.faded;
         if (centerColor.a > 0f)
         {
             GUI.color = centerColor;
             GUI.Label(position, kDirNames[index], styles.viewLabelStyleCentered);
         }
         if (this.faded2Dgray < 1f)
         {
             this.DrawIsoStatusSymbol(new Vector3(rect2.x - 8f, rect2.y + 8.5f, 0f), view, 1f - this.faded2Dgray);
         }
         Handles.EndGUI();
         for (int k = 0; k < 3; k++)
         {
             Vector3 rhs = (Vector3) (kDirectionRotations[k] * Vector3.forward);
             this.dirVisible[k].target = Mathf.Abs(Vector3.Dot(camera.transform.forward, rhs)) < 0.9f;
         }
         float size = HandleUtility.GetHandleSize(Vector3.zero) * 0.2f;
         this.AxisSelectors(view, camera, size, -1f, styles.viewAxisLabelStyle);
         Color color3 = Color.Lerp(Handles.centerColor, Color.gray, this.faded2Dgray);
         color3.a *= this.m_Visible.faded;
         if (color3.a <= 0.1f)
         {
             GUI.enabled = false;
         }
         Handles.color = color3;
         if (Handles.Button(Vector3.zero, Quaternion.identity, size * 0.8f, size, new Handles.DrawCapFunction(Handles.CubeCap)) && !view.in2DMode)
         {
             if (Event.current.clickCount == 2)
             {
                 view.FrameSelected();
             }
             else if (Event.current.shift || (Event.current.button == 2))
             {
                 this.ViewFromNiceAngle(view, true);
             }
             else
             {
                 this.ViewSetOrtho(view, !view.orthographic);
             }
         }
         this.AxisSelectors(view, camera, size, 1f, styles.viewAxisLabelStyle);
         GUI.enabled = true;
         if (!view.in2DMode && (Event.current.type == EditorGUIUtility.swipeGestureEventType))
         {
             Vector3 up;
             Event current = Event.current;
             if (current.delta.y > 0f)
             {
                 up = Vector3.up;
             }
             else if (current.delta.y < 0f)
             {
                 up = -Vector3.up;
             }
             else if (current.delta.x < 0f)
             {
                 up = Vector3.right;
             }
             else
             {
                 up = -Vector3.right;
             }
             Vector3 direction = -up - ((Vector3) (Vector3.forward * 0.9f));
             direction = view.camera.transform.TransformDirection(direction);
             float num9 = 0f;
             int dir = 0;
             for (int m = 0; m < 6; m++)
             {
                 float num12 = Vector3.Dot((Vector3) (kDirectionRotations[m] * -Vector3.forward), direction);
                 if (num12 > num9)
                 {
                     num9 = num12;
                     dir = m;
                 }
             }
             this.ViewAxisDirection(view, dir);
             Event.current.Use();
         }
         HandleUtility.PopCamera(camera);
         Handles.SetCamera(camera);
         if (Event.current.type == EventType.Repaint)
         {
             Profiler.EndSample();
         }
     }
 }
示例#10
0
        internal void OnGUI(SceneView view)
        {
            if ((double)Mathf.Min(view.position.width, view.position.height) < 100.0)
            {
                return;
            }
            if (Event.current.type == EventType.Repaint)
            {
                Profiler.BeginSample("SceneView.AxisSelector");
            }
            this.HandleContextClick(view);
            Camera camera = view.camera;

            HandleUtility.PushCamera(camera);
            if (camera.orthographic)
            {
                camera.orthographicSize = 0.5f;
            }
            camera.cullingMask        = 0;
            camera.transform.position = camera.transform.rotation * new Vector3(0.0f, 0.0f, -5f);
            camera.clearFlags         = CameraClearFlags.Nothing;
            camera.nearClipPlane      = 0.1f;
            camera.farClipPlane       = 10f;
            camera.fieldOfView        = view.m_Ortho.Fade(70f, 0.0f);
            SceneView.AddCursorRect(new Rect((float)((double)view.position.width - 100.0 + 22.0), 22f, 56f, 102f), MouseCursor.Arrow);
            Handles.SetCamera(new Rect(view.position.width - 100f, 0.0f, 100f, 100f), camera);
            Handles.BeginGUI();
            this.DrawLabels(view);
            Handles.EndGUI();
            for (int index = 0; index < 3; ++index)
            {
                Vector3 rhs = SceneViewRotation.kDirectionRotations[index] * Vector3.forward;
                this.dirVisible[index].target = (double)Mathf.Abs(Vector3.Dot(camera.transform.forward, rhs)) < 0.899999976158142;
            }
            float num1 = HandleUtility.GetHandleSize(Vector3.zero) * 0.2f;

            this.AxisSelectors(view, camera, num1, -1f, SceneViewRotation.styles.viewAxisLabelStyle);
            Color color = Color.Lerp(Handles.centerColor, Color.gray, this.faded2Dgray);

            color.a *= this.m_Visible.faded;
            if ((double)color.a <= 0.100000001490116)
            {
                GUI.enabled = false;
            }
            Handles.color = color;
            if (Handles.Button(this.m_CenterButtonControlID, Vector3.zero, Quaternion.identity, num1 * 0.8f, num1, new Handles.DrawCapFunction(Handles.CubeCap)) && !view.in2DMode)
            {
                if (Event.current.clickCount == 2)
                {
                    view.FrameSelected();
                }
                else if (Event.current.shift || Event.current.button == 2)
                {
                    this.ViewFromNiceAngle(view, true);
                }
                else
                {
                    this.ViewSetOrtho(view, !view.orthographic);
                }
            }
            this.AxisSelectors(view, camera, num1, 1f, SceneViewRotation.styles.viewAxisLabelStyle);
            GUI.enabled = true;
            if (!view.in2DMode && Event.current.type == EditorGUIUtility.swipeGestureEventType)
            {
                Event   current   = Event.current;
                Vector3 direction = -((double)current.delta.y <= 0.0 ? ((double)current.delta.y >= 0.0 ? ((double)current.delta.x >= 0.0 ? -Vector3.right : Vector3.right) : -Vector3.up) : Vector3.up) - Vector3.forward * 0.9f;
                Vector3 rhs       = view.camera.transform.TransformDirection(direction);
                float   num2      = 0.0f;
                int     dir       = 0;
                for (int index = 0; index < 6; ++index)
                {
                    float num3 = Vector3.Dot(SceneViewRotation.kDirectionRotations[index] * -Vector3.forward, rhs);
                    if ((double)num3 > (double)num2)
                    {
                        num2 = num3;
                        dir  = index;
                    }
                }
                this.ViewAxisDirection(view, dir);
                Event.current.Use();
            }
            HandleUtility.PopCamera(camera);
            Handles.SetCamera(camera);
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            Profiler.EndSample();
        }
示例#11
0
        internal void OnGUI(SceneView view)
        {
            int num = Mathf.Min(Screen.width, Screen.height);

            if (num < 100)
            {
                return;
            }
            if (Event.current.type == EventType.Repaint)
            {
                Profiler.BeginSample("SceneView.AxisSelector");
            }
            Camera camera = view.camera;

            HandleUtility.PushCamera(camera);
            if (camera.orthographic)
            {
                camera.orthographicSize = 0.5f;
            }
            camera.cullingMask        = 0;
            camera.transform.position = camera.transform.rotation * new Vector3(0f, 0f, -5f);
            camera.clearFlags         = CameraClearFlags.Nothing;
            camera.nearClipPlane      = 0.1f;
            camera.farClipPlane       = 10f;
            camera.fieldOfView        = view.m_Ortho.Fade(70f, 0f);
            SceneView.AddCursorRect(new Rect((float)(Screen.width - 100 + 22), 22f, 56f, 102f), MouseCursor.Arrow);
            Handles.SetCamera(new Rect((float)(Screen.width - 100), 0f, 100f, 100f), camera);
            Handles.BeginGUI();
            Rect rect = new Rect((float)(Screen.width - 100 + 17), 92f, 66f, 16f);

            if (!view.in2DMode && GUI.Button(rect, string.Empty, SceneViewRotation.styles.viewLabelStyleLeftAligned))
            {
                if (Event.current.button == 1)
                {
                    this.DisplayContextMenu(rect, view);
                }
                else
                {
                    this.ViewSetOrtho(view, !view.orthographic);
                }
            }
            int   num2     = 8;
            Rect  position = rect;
            float num3     = 0f;
            float num4     = 0f;

            for (int i = 0; i < SceneViewRotation.kDirNames.Length; i++)
            {
                if (i != num2)
                {
                    num4 += this.dirNameVisible[i].faded;
                    if (this.dirNameVisible[i].faded > 0f)
                    {
                        num3 += SceneViewRotation.styles.viewLabelStyleLeftAligned.CalcSize(EditorGUIUtility.TempContent(SceneViewRotation.kDirNames[i])).x *this.dirNameVisible[i].faded;
                    }
                }
            }
            if (num4 > 0f)
            {
                num3 /= num4;
            }
            position.x += 37f - num3 * 0.5f;
            position.x  = (float)Mathf.RoundToInt(position.x);
            int num5 = 0;

            while (num5 < this.dirNameVisible.Length && num5 < SceneViewRotation.kDirNames.Length)
            {
                if (num5 != num2)
                {
                    Color centerColor = Handles.centerColor;
                    centerColor.a *= this.dirNameVisible[num5].faded;
                    if (centerColor.a > 0f)
                    {
                        GUI.color = centerColor;
                        GUI.Label(position, SceneViewRotation.kDirNames[num5], SceneViewRotation.styles.viewLabelStyleLeftAligned);
                    }
                }
                num5++;
            }
            Color centerColor2 = Handles.centerColor;

            centerColor2.a *= this.faded2Dgray * this.m_Visible.faded;
            if (centerColor2.a > 0f)
            {
                GUI.color = centerColor2;
                GUI.Label(rect, SceneViewRotation.kDirNames[num2], SceneViewRotation.styles.viewLabelStyleCentered);
            }
            if (this.faded2Dgray < 1f)
            {
                this.DrawIsoStatusSymbol(new Vector3(position.x - 8f, position.y + 8.5f, 0f), view, 1f - this.faded2Dgray);
            }
            Handles.EndGUI();
            for (int j = 0; j < 3; j++)
            {
                Vector3 rhs = SceneViewRotation.kDirectionRotations[j] * Vector3.forward;
                this.dirVisible[j].target = (Mathf.Abs(Vector3.Dot(camera.transform.forward, rhs)) < 0.9f);
            }
            float num6 = HandleUtility.GetHandleSize(Vector3.zero) * 0.2f;

            this.AxisSelectors(view, camera, num6, -1f, SceneViewRotation.styles.viewAxisLabelStyle);
            Color color = Handles.centerColor;

            color    = Color.Lerp(color, Color.gray, this.faded2Dgray);
            color.a *= this.m_Visible.faded;
            if (color.a <= 0.1f)
            {
                GUI.enabled = false;
            }
            Handles.color = color;
            if (Handles.Button(Vector3.zero, Quaternion.identity, num6 * 0.8f, num6, new Handles.DrawCapFunction(Handles.CubeCap)) && !view.in2DMode)
            {
                if (Event.current.clickCount == 2)
                {
                    view.FrameSelected();
                }
                else
                {
                    if (Event.current.shift || Event.current.button == 2)
                    {
                        this.ViewFromNiceAngle(view, true);
                    }
                    else
                    {
                        this.ViewSetOrtho(view, !view.orthographic);
                    }
                }
            }
            this.AxisSelectors(view, camera, num6, 1f, SceneViewRotation.styles.viewAxisLabelStyle);
            GUI.enabled = true;
            if (!view.in2DMode && Event.current.type == EditorGUIUtility.swipeGestureEventType)
            {
                Event   current = Event.current;
                Vector3 a;
                if (current.delta.y > 0f)
                {
                    a = Vector3.up;
                }
                else
                {
                    if (current.delta.y < 0f)
                    {
                        a = -Vector3.up;
                    }
                    else
                    {
                        if (current.delta.x < 0f)
                        {
                            a = Vector3.right;
                        }
                        else
                        {
                            a = -Vector3.right;
                        }
                    }
                }
                Vector3 vector = -a - Vector3.forward * 0.9f;
                vector = view.camera.transform.TransformDirection(vector);
                float num7 = 0f;
                int   dir  = 0;
                for (int k = 0; k < 6; k++)
                {
                    float num8 = Vector3.Dot(SceneViewRotation.kDirectionRotations[k] * -Vector3.forward, vector);
                    if (num8 > num7)
                    {
                        num7 = num8;
                        dir  = k;
                    }
                }
                this.ViewAxisDirection(view, dir);
                Event.current.Use();
            }
            HandleUtility.PopCamera(camera);
            Handles.SetCamera(camera);
            if (Event.current.type == EventType.Repaint)
            {
                Profiler.EndSample();
            }
        }