MidPointPositionSlider() private static method

private static MidPointPositionSlider ( Vector3 position1, Vector3 position2, Vector3 direction ) : Vector3
position1 Vector3
position2 Vector3
direction Vector3
return Vector3
コード例 #1
0
ファイル: CameraEditor.cs プロジェクト: zuohu/UnityDecompiled
        public void OnSceneGUI()
        {
            Camera camera = (Camera)base.target;

            if (CameraEditor.IsViewPortRectValidToRender(camera.rect))
            {
                SceneViewOverlay.Window(new GUIContent("Camera Preview"), new SceneViewOverlay.WindowFunction(this.OnOverlayGUI), -100, base.target, SceneViewOverlay.WindowDisplayOption.OneWindowPerTarget);
                Color color  = Handles.color;
                Color color2 = CameraEditor.kGizmoCamera;
                color2.a     *= 2f;
                Handles.color = color2;
                Vector3[] array = new Vector3[4];
                float     num;
                if (CameraEditor.GetFrustum(camera, null, array, out num))
                {
                    Vector3 vector  = array[0];
                    Vector3 vector2 = array[1];
                    Vector3 vector3 = array[2];
                    Vector3 vector4 = array[3];
                    bool    changed = GUI.changed;
                    Vector3 vector5 = Vector3.Lerp(vector, vector3, 0.5f);
                    float   num2    = -1f;
                    Vector3 a       = CameraEditor.MidPointPositionSlider(vector2, vector3, camera.transform.up);
                    if (!GUI.changed)
                    {
                        a = CameraEditor.MidPointPositionSlider(vector, vector4, -camera.transform.up);
                    }
                    if (GUI.changed)
                    {
                        num2 = (a - vector5).magnitude;
                    }
                    GUI.changed = false;
                    a           = CameraEditor.MidPointPositionSlider(vector4, vector3, camera.transform.right);
                    if (!GUI.changed)
                    {
                        a = CameraEditor.MidPointPositionSlider(vector, vector2, -camera.transform.right);
                    }
                    if (GUI.changed)
                    {
                        num2 = (a - vector5).magnitude / num;
                    }
                    if (num2 >= 0f)
                    {
                        Undo.RecordObject(camera, "Adjust Camera");
                        if (camera.orthographic)
                        {
                            camera.orthographicSize = num2;
                        }
                        else
                        {
                            Vector3 a2 = vector5 + camera.transform.up * num2;
                            camera.fieldOfView = Vector3.Angle(camera.transform.forward, a2 - camera.transform.position) * 2f;
                        }
                        changed = true;
                    }
                    GUI.changed   = changed;
                    Handles.color = color;
                }
            }
        }
コード例 #2
0
        public void OnSceneGUI()
        {
            Camera target = (Camera)this.target;

            if (!CameraEditor.IsViewPortRectValidToRender(target.rect))
            {
                return;
            }
            SceneViewOverlay.Window(new GUIContent("Camera Preview"), new SceneViewOverlay.WindowFunction(this.OnOverlayGUI), -100, this.target, SceneViewOverlay.WindowDisplayOption.OneWindowPerTarget);
            Color color        = Handles.color;
            Color kGizmoCamera = CameraEditor.kGizmoCamera;

            kGizmoCamera.a *= 2f;
            Handles.color   = kGizmoCamera;
            Vector3[] far = new Vector3[4];
            float     frustumAspect;

            if (!CameraEditor.GetFrustum(target, (Vector3[])null, far, out frustumAspect))
            {
                return;
            }
            Vector3 vector3_1 = far[0];
            Vector3 vector3_2 = far[1];
            Vector3 vector3_3 = far[2];
            Vector3 vector3_4 = far[3];
            bool    flag      = GUI.changed;
            Vector3 vector3_5 = Vector3.Lerp(vector3_1, vector3_3, 0.5f);
            float   num       = -1f;
            Vector3 vector3_6 = CameraEditor.MidPointPositionSlider(vector3_2, vector3_3, target.transform.up);

            if (!GUI.changed)
            {
                vector3_6 = CameraEditor.MidPointPositionSlider(vector3_1, vector3_4, -target.transform.up);
            }
            if (GUI.changed)
            {
                num = (vector3_6 - vector3_5).magnitude;
            }
            GUI.changed = false;
            Vector3 vector3_7 = CameraEditor.MidPointPositionSlider(vector3_4, vector3_3, target.transform.right);

            if (!GUI.changed)
            {
                vector3_7 = CameraEditor.MidPointPositionSlider(vector3_1, vector3_2, -target.transform.right);
            }
            if (GUI.changed)
            {
                num = (vector3_7 - vector3_5).magnitude / frustumAspect;
            }
            if ((double)num >= 0.0)
            {
                Undo.RecordObject((UnityEngine.Object)target, "Adjust Camera");
                if (target.orthographic)
                {
                    target.orthographicSize = num;
                }
                else
                {
                    Vector3 vector3_8 = vector3_5 + target.transform.up * num;
                    target.fieldOfView = Vector3.Angle(target.transform.forward, vector3_8 - target.transform.position) * 2f;
                }
                flag = true;
            }
            GUI.changed   = flag;
            Handles.color = color;
        }