示例#1
0
        private void AxisSelectors(SceneView view, Camera cam, float size, float sgn, GUIStyle viewAxisLabelStyle)
        {
            for (int i = SceneViewRotation.kDirectionRotations.Length - 1; i >= 0; i--)
            {
                Quaternion quaternion = SceneViewRotation.kDirectionRotations[i];
                float      faded      = this.dirVisible[i % 3].faded;
                Vector3    vector     = SceneViewRotation.kDirectionRotations[i] * Vector3.forward;
                float      num        = Vector3.Dot(view.camera.transform.forward, vector);
                if ((double)num > 0.0 || sgn <= 0f)
                {
                    if ((double)num <= 0.0 || sgn >= 0f)
                    {
                        Color color;
                        switch (i)
                        {
                        case 0:
                            color = Handles.xAxisColor;
                            break;

                        case 1:
                            color = Handles.yAxisColor;
                            break;

                        case 2:
                            color = Handles.zAxisColor;
                            break;

                        default:
                            color = Handles.centerColor;
                            break;
                        }
                        if (view.in2DMode)
                        {
                            color = Color.Lerp(color, Color.gray, this.faded2Dgray);
                        }
                        color.a      *= faded * this.fadedVisibility;
                        Handles.color = color;
                        if (color.a <= 0.1f || view.isRotationLocked)
                        {
                            GUI.enabled = false;
                        }
                        if (sgn > 0f)
                        {
                            int        arg_1A5_0 = this.m_ViewDirectionControlIDs[i];
                            Vector3    arg_1A5_1 = quaternion * Vector3.forward * size * -1.2f;
                            Quaternion arg_1A5_2 = quaternion;
                            float      arg_1A5_4 = size * 0.7f;
                            if (SceneViewRotation.< > f__mg$cache0 == null)
                            {
                                SceneViewRotation.< > f__mg$cache0 = new Handles.CapFunction(Handles.ConeHandleCap);
                            }
                            if (Handles.Button(arg_1A5_0, arg_1A5_1, arg_1A5_2, size, arg_1A5_4, SceneViewRotation.< > f__mg$cache0))
                            {
                                if (!view.in2DMode && !view.isRotationLocked)
                                {
                                    this.ViewAxisDirection(view, i);
                                }
                            }
                        }
                        if (i < 3)
                        {
                            GUI.color = new Color(1f, 1f, 1f, this.dirVisible[i].faded * this.fadedVisibility);
                            Vector3 a = vector;
                            a += num * view.camera.transform.forward * -0.5f;
                            a  = (a * 0.7f + a.normalized * 1.5f) * size;
                            Handles.Label(-a, SceneViewRotation.s_HandleAxisLabels[i], SceneViewRotation.styles.viewAxisLabelStyle);
                        }
                        if (sgn < 0f)
                        {
                            int        arg_2CE_0 = this.m_ViewDirectionControlIDs[i];
                            Vector3    arg_2CE_1 = quaternion * Vector3.forward * size * -1.2f;
                            Quaternion arg_2CE_2 = quaternion;
                            float      arg_2CE_4 = size * 0.7f;
                            if (SceneViewRotation.< > f__mg$cache1 == null)
                            {
                                SceneViewRotation.< > f__mg$cache1 = new Handles.CapFunction(Handles.ConeHandleCap);
                            }
                            if (Handles.Button(arg_2CE_0, arg_2CE_1, arg_2CE_2, size, arg_2CE_4, SceneViewRotation.< > f__mg$cache1))
                            {
                                if (!view.in2DMode && !view.isRotationLocked)
                                {
                                    this.ViewAxisDirection(view, i);
                                }
                            }
                        }
                        Handles.color = Color.white;
                        GUI.color     = Color.white;
                        GUI.enabled   = true;
                    }
                }
            }
        }
示例#2
0
        private void AxisSelectors(SceneView view, Camera cam, float size, float sgn, GUIStyle viewAxisLabelStyle)
        {
            for (int h = kDirectionRotations.Length - 1; h >= 0; h--)
            {
                Quaternion q1        = kDirectionRotations[h];
                float      a         = dirVisible[h % 3].faded;
                Vector3    direction = kDirectionRotations[h] * Vector3.forward;
                float      dot       = Vector3.Dot(view.camera.transform.forward, direction);

                if (dot <= 0.0 && sgn > 0.0f)
                {
                    continue;
                }

                if (dot > 0.0 && sgn < 0.0f)
                {
                    continue;
                }

                Color c;
                switch (h)
                {
                case 0: c = Handles.xAxisColor; break;

                case 1: c = Handles.yAxisColor; break;

                case 2: c = Handles.zAxisColor; break;

                default: c = Handles.centerColor; break;
                }

                if (view.in2DMode)
                {
                    c = Color.Lerp(c, Color.gray, faded2Dgray);
                }
                c.a *= a * fadedVisibility;

                if (QualitySettings.activeColorSpace == ColorSpace.Linear)
                {
                    c = c.linear;
                }

                Handles.color = c;

                if (c.a <= 0.1f || view.isRotationLocked)
                {
                    GUI.enabled = false;
                }

                // axis widget when drawn behind label
                if (sgn > 0 && Handles.Button(m_ViewDirectionControlIDs[h], q1 * Vector3.forward * size * -1.2f, q1, size, size * 0.7f, Handles.ConeHandleCap))
                {
                    if (!view.in2DMode && !view.isRotationLocked)
                    {
                        ViewAxisDirection(view, h);
                    }
                }

                // primary axes have text labels
                if (h < 3)
                {
                    GUI.color = new Color(1, 1, 1, dirVisible[h].faded * fadedVisibility);

                    // Label pos is a bit further out than the end of the cone
                    Vector3 pos = direction;
                    // Remove some of the perspective to avoid labels in front
                    // being much further away from the gizmo due to perspective
                    pos += dot * view.camera.transform.forward * -0.5f;
                    // Also remove some of the spacing difference caused by rotation
                    pos = (pos * 0.7f + pos.normalized * 1.5f) * size;
                    Handles.Label(-pos, s_HandleAxisLabels[h], styles.viewAxisLabelStyle);
                }

                // axis widget when drawn in front of label
                if (sgn < 0 && Handles.Button(m_ViewDirectionControlIDs[h], q1 * Vector3.forward * size * -1.2f, q1, size, size * 0.7f, Handles.ConeHandleCap))
                {
                    if (!view.in2DMode && !view.isRotationLocked)
                    {
                        ViewAxisDirection(view, h);
                    }
                }


                Handles.color = Color.white;
                GUI.color     = Color.white;
                GUI.enabled   = true;
            }
        }
        private void AxisSelectors(SceneView view, Camera cam, float size, float sgn, GUIStyle viewAxisLabelStyle)
        {
            for (int i = kDirectionRotations.Length - 1; i >= 0; i--)
            {
                Quaternion direction = kDirectionRotations[i];
                string[]   strArray  = new string[] { "x", "y", "z" };
                float      faded     = this.dirVisible[i % 3].faded;
                Vector3    rhs       = (Vector3)(kDirectionRotations[i] * Vector3.forward);
                float      num3      = Vector3.Dot(view.camera.transform.forward, rhs);
                if (((num3 > 0.0) || (sgn <= 0f)) && ((num3 <= 0.0) || (sgn >= 0f)))
                {
                    Color xAxisColor;
                    switch (i)
                    {
                    case 0:
                        xAxisColor = Handles.xAxisColor;
                        break;

                    case 1:
                        xAxisColor = Handles.yAxisColor;
                        break;

                    case 2:
                        xAxisColor = Handles.zAxisColor;
                        break;

                    default:
                        xAxisColor = Handles.centerColor;
                        break;
                    }
                    if (view.in2DMode)
                    {
                        xAxisColor = Color.Lerp(xAxisColor, Color.gray, this.faded2Dgray);
                    }
                    xAxisColor.a *= faded * this.m_Visible.faded;
                    Handles.color = xAxisColor;
                    if (xAxisColor.a <= 0.1f)
                    {
                        GUI.enabled = false;
                    }
                    if (((sgn > 0f) && Handles.Button(this.m_ViewDirectionControlIDs[i], (Vector3)(((direction * Vector3.forward) * size) * -1.2f), direction, size, size * 0.7f, new Handles.DrawCapFunction(Handles.ConeCap))) && !view.in2DMode)
                    {
                        this.ViewAxisDirection(view, i);
                    }
                    if (i < 3)
                    {
                        GUI.color = new Color(1f, 1f, 1f, this.dirVisible[i].faded * this.m_Visible.faded);
                        Vector3 vector2 = rhs;
                        vector2 += (Vector3)((num3 * view.camera.transform.forward) * -0.5f);
                        vector2  = (Vector3)(((vector2 * 0.7f) + (vector2.normalized * 1.5f)) * size);
                        Handles.Label(-vector2, new GUIContent(strArray[i]), styles.viewAxisLabelStyle);
                    }
                    if (((sgn < 0f) && Handles.Button(this.m_ViewDirectionControlIDs[i], (Vector3)(((direction * Vector3.forward) * size) * -1.2f), direction, size, size * 0.7f, new Handles.DrawCapFunction(Handles.ConeCap))) && !view.in2DMode)
                    {
                        this.ViewAxisDirection(view, i);
                    }
                    Handles.color = Color.white;
                    GUI.color     = Color.white;
                    GUI.enabled   = true;
                }
            }
        }
示例#4
0
            public override void OnPaintSceneGUI(GridLayout gridLayout, GameObject brushTarget, BoundsInt position, GridBrushBase.Tool tool, bool executing)
            {
                Tilemap tilemap = brushTarget.GetComponent <Tilemap>();

                if (tilemap != null)
                {
                    lastTilemap = tilemap;
                }

                base.OnPaintSceneGUI(gridLayout, brushTarget, position, tool, executing);

                switch (sudokuBrush.paintModel)
                {
                case PaintModel.SUDOKU:

                    break;

                case PaintModel.FOUR:
                    var       fourZPosition = new Vector3Int(position.min.x, position.min.y, sudokuBrush.z);
                    Vector3[] cellPostions  = null;
                    BoundsInt newPosition   = new BoundsInt(fourZPosition, position.size);

                    if (gridLayout.cellLayout == GridLayout.CellLayout.Isometric || gridLayout.cellLayout == GridLayout.CellLayout.Isometric)
                    {
                        cellPostions = new Vector3[]
                        {
                            gridLayout.CellToLocal(new Vector3Int(newPosition.max.x - 2, newPosition.max.y - 1, newPosition.max.z)),
                            gridLayout.CellToLocal(new Vector3Int(newPosition.max.x + 0, newPosition.max.y - 1, newPosition.max.z)),
                            gridLayout.CellToLocal(new Vector3Int(newPosition.max.x - 1, newPosition.max.y - 0, newPosition.max.z)),
                            gridLayout.CellToLocal(new Vector3Int(newPosition.max.x - 1, newPosition.max.y - 2, newPosition.max.z))
                        };
                    }
                    else
                    {
                        cellPostions = new Vector3[]
                        {
                            gridLayout.CellToLocal(new Vector3Int(newPosition.max.x - 1, newPosition.max.y - 1, newPosition.max.z)),
                            gridLayout.CellToLocal(new Vector3Int(newPosition.max.x + 1, newPosition.max.y - 1, newPosition.max.z)),
                            gridLayout.CellToLocal(new Vector3Int(newPosition.max.x, newPosition.max.y - 0, newPosition.max.z)),
                            gridLayout.CellToLocal(new Vector3Int(newPosition.max.x, newPosition.max.y - 2, newPosition.max.z))
                        };
                    }

                    Handles.color = Color.cyan;
                    Handles.DrawLine(cellPostions[0], cellPostions[1]);
                    Handles.color = Color.cyan;
                    Handles.DrawLine(cellPostions[2], cellPostions[3]);
                    break;

                default:

                    break;
                }

                var labelText = "Pos: " + new Vector3Int(position.x, position.y, sudokuBrush.z);

                if (position.size.x > 1 || position.size.y > 1)
                {
                    labelText += " Size: " + new Vector2Int(position.size.x, position.size.y);
                }

                Handles.Label(gridLayout.CellToWorld(new Vector3Int(position.x, position.y, sudokuBrush.z)), labelText);
            }
示例#5
0
        private void AxisSelectors(SceneView view, Camera cam, float size, float sgn, GUIStyle viewAxisLabelStyle)
        {
            for (int dir = SceneViewRotation.kDirectionRotations.Length - 1; dir >= 0; --dir)
            {
                Quaternion directionRotation = SceneViewRotation.kDirectionRotations[dir];
                string[]   strArray          = new string[3] {
                    "x", "y", "z"
                };
                float   faded = this.dirVisible[dir % 3].faded;
                Vector3 rhs   = SceneViewRotation.kDirectionRotations[dir] * Vector3.forward;
                float   num   = Vector3.Dot(view.camera.transform.forward, rhs);
                if (((double)num > 0.0 || (double)sgn <= 0.0) && ((double)num <= 0.0 || (double)sgn >= 0.0))
                {
                    Color a;
                    switch (dir)
                    {
                    case 0:
                        a = Handles.xAxisColor;
                        break;

                    case 1:
                        a = Handles.yAxisColor;
                        break;

                    case 2:
                        a = Handles.zAxisColor;
                        break;

                    default:
                        a = Handles.centerColor;
                        break;
                    }
                    if (view.in2DMode)
                    {
                        a = Color.Lerp(a, Color.gray, this.faded2Dgray);
                    }
                    a.a          *= faded * this.m_Visible.faded;
                    Handles.color = a;
                    if ((double)a.a <= 0.100000001490116)
                    {
                        GUI.enabled = false;
                    }
                    if ((double)sgn > 0.0 && Handles.Button(this.m_ViewDirectionControlIDs[dir], directionRotation * Vector3.forward * size * -1.2f, directionRotation, size, size * 0.7f, new Handles.DrawCapFunction(Handles.ConeCap)) && !view.in2DMode)
                    {
                        this.ViewAxisDirection(view, dir);
                    }
                    if (dir < 3)
                    {
                        GUI.color = new Color(1f, 1f, 1f, this.dirVisible[dir].faded * this.m_Visible.faded);
                        Vector3 vector3 = rhs + num * view.camera.transform.forward * -0.5f;
                        Handles.Label(-((vector3 * 0.7f + vector3.normalized * 1.5f) * size), new GUIContent(strArray[dir]), SceneViewRotation.styles.viewAxisLabelStyle);
                    }
                    if ((double)sgn < 0.0 && Handles.Button(this.m_ViewDirectionControlIDs[dir], directionRotation * Vector3.forward * size * -1.2f, directionRotation, size, size * 0.7f, new Handles.DrawCapFunction(Handles.ConeCap)) && !view.in2DMode)
                    {
                        this.ViewAxisDirection(view, dir);
                    }
                    Handles.color = Color.white;
                    GUI.color     = Color.white;
                    GUI.enabled   = true;
                }
            }
        }
示例#6
0
        private void AxisSelectors(SceneView view, Camera cam, float size, float sgn, GUIStyle viewAxisLabelStyle)
        {
            for (int i = SceneViewRotation.kDirectionRotations.Length - 1; i >= 0; i--)
            {
                Quaternion quaternion = SceneViewRotation.kDirectionRotations[i];
                string[]   array      = new string[]
                {
                    "x",
                    "y",
                    "z"
                };
                float   faded  = this.dirVisible[i % 3].faded;
                Vector3 vector = SceneViewRotation.kDirectionRotations[i] * Vector3.forward;
                float   num    = Vector3.Dot(view.camera.transform.forward, vector);
                if ((double)num > 0.0 || sgn <= 0f)
                {
                    if ((double)num <= 0.0 || sgn >= 0f)
                    {
                        Color color;
                        switch (i)
                        {
                        case 0:
                            color = Handles.xAxisColor;
                            break;

                        case 1:
                            color = Handles.yAxisColor;
                            break;

                        case 2:
                            color = Handles.zAxisColor;
                            break;

                        default:
                            color = Handles.centerColor;
                            break;
                        }
                        if (view.in2DMode)
                        {
                            color = Color.Lerp(color, Color.gray, this.faded2Dgray);
                        }
                        color.a      *= faded * this.m_Visible.faded;
                        Handles.color = color;
                        if (color.a <= 0.1f)
                        {
                            GUI.enabled = false;
                        }
                        if (sgn > 0f && Handles.Button(quaternion * Vector3.forward * size * -1.2f, quaternion, size, size * 0.7f, new Handles.DrawCapFunction(Handles.ConeCap)) && !view.in2DMode)
                        {
                            this.ViewAxisDirection(view, i);
                        }
                        if (i < 3)
                        {
                            GUI.color = new Color(1f, 1f, 1f, this.dirVisible[i].faded * this.m_Visible.faded);
                            Vector3 a = vector;
                            a += num * view.camera.transform.forward * -0.5f;
                            a  = (a * 0.7f + a.normalized * 1.5f) * size;
                            Handles.Label(-a, new GUIContent(array[i]), SceneViewRotation.styles.viewAxisLabelStyle);
                        }
                        if (sgn < 0f && Handles.Button(quaternion * Vector3.forward * size * -1.2f, quaternion, size, size * 0.7f, new Handles.DrawCapFunction(Handles.ConeCap)) && !view.in2DMode)
                        {
                            this.ViewAxisDirection(view, i);
                        }
                        Handles.color = Color.white;
                        GUI.color     = Color.white;
                        GUI.enabled   = true;
                    }
                }
            }
        }