Beispiel #1
0
        void Input()
        {
            this.BeginOrtho();
            var vs = UITool.GetVS(rt.cornerLB, rtSize, Vector2.zero);

            GenTex2D();
            GLUI.BeginOrder(0);
            GLUI.DrawTex(tex, vs);

            // frame
            GLUI.BeginOrder(1);
            this.DrawBG(frameWidth, false);
            vs = UITool.GetVS(rt.center, Vector2.one * texPlayerSize, Vectors.half2d);
            GLUI.DrawTex(texPlayer, vs);

            if (Events.MouseDown0)
            {
                prevMousePos = UI.mousePosRef;
                prevViewOs   = viewMapOs;
            }
            else if (Events.Mouse0)
            {
                var os = (UI.mousePosRef - prevMousePos).RoundToInt();
                os        = (os * Vector2.one / viewScale).RoundToInt();
                viewMapOs = prevViewOs - os;
            }
        }
Beispiel #2
0
 public static void StartGLWorld(this MonoBehaviour mono, int order = 0)
 {
     UI.owner = mono.gameObject;
     UI.ClearGL();
     UI.gl.order = order;
     GLUI.BeginOrder(0);
 }
Beispiel #3
0
        public void CameraPostRender()
        {
            Owner = owner;
            GLUI.SetLineMaterial();

            var checkList = new List <GLHandler>();

            foreach (var hdr in glHandlers)
            {
                var go = hdr.owner as GameObject;
                if (go != null)
                {
                    checkList.Add(hdr);
                }
            }
            glHandlers = checkList;

            glHandlers.Sort(SortList);
            foreach (var hdr in glHandlers)
            {
                var go = (GameObject)hdr.owner;
                if (go == null || go.activeInHierarchy)
                {
                    GL.PushMatrix();
                    hdr.Execute();
                    GL.PopMatrix();
                }
            }
        }
Beispiel #4
0
        void Thumbnail()
        {
            var startPos = UI.AbsRefPos(thumbnail);

            rects = new List <Rect>();
            //palette = new List<Color>();
            //tips = new List<string>();
            for (int y = 0; y < gridCount.y; y++)
            {
                for (int x = 0; x < gridCount.x; x++)
                {
                    rects.Add(new Rect(startPos + gridOsFactor * new Vector2(x, y) *
                                       (gridOs + Vector2.one * gridSize), gridSize));
                    //palette.Add(colorList[y].colors[x]);
                    //tips.Add(colorList[y].names[x]);
                }
            }
            var i = 0;

            foreach (var rt in rects)
            {
                GLUI.BeginOrder(0);
                rt.Draw(palette[i++], true);
                GLUI.BeginOrder(1);
                if (drawBorder)
                {
                    rt.Draw(drawBorderClr, false);
                }
            }
            GLUI.BeginOrder(0);
            preview.Draw(color, true);
            GLUI.BeginOrder(1);
            preview.Draw(drawPvBorderClr);
        }
Beispiel #5
0
        private void Draw()
        {
            this.StartGLWorld();
            GLUI.DrawGrid(gridSize, gridUnitSize, colorGrid);

            var half = gridSize * 0.5f;

            GLUI.BeginOrder(1);
            GLUI.DrawLineDirect(-half.X(), half.X(), colorAxisX);
            GLUI.DrawLineDirect(-half.Z(), half.Z(), colorAxisZ);

            GLUI.BeginOrder(2);
            var selAxisSize = gridSize * 10f;
            var pos         = transform.position;

            if (drawAxis == 0)
            {
                GLUI.DrawLineDirect(pos - selAxisSize.X(), pos + selAxisSize.X(), colorAxisXSel);
            }
            else if (drawAxis == 1)
            {
                GLUI.DrawLineDirect(pos - selAxisSize.Y(), pos + selAxisSize.Y(), colorAxisYSel);
            }
            else if (drawAxis == 2)
            {
                GLUI.DrawLineDirect(pos - selAxisSize.Z(), pos + selAxisSize.Z(), colorAxisZSel);
            }

            if (dragging && drawAxisProj)
            {
                DrawLineScreen(screenThisPos, screenThisPos + screenAxis.normalized * drawAxisLength, Color.white);
                DrawLineScreen(screenThisPos, mousePosProj, Color.red);
                DrawLineScreen(screenThisPos, UnityEngine.Input.mousePosition, Color.black);
            }
        }
Beispiel #6
0
        void Tips()
        {
            this.StartIM();
            for (int i = 0; i < rects.Count; i++)
            {
                var rt = rects[i];
                if (rt.Contains(UI.mousePosRef))
                {
                    //show tips
                    IMUI.fontStyle.normal.textColor = tipsTxtColor;
                    var str  = tips[i];
                    var size = IMUI.CalSize(str);
                    size += fontBorder;

                    var os = offset + osFactor * size;
                    GLUI.DrawString(str, UI.mousePosRef + os, Vectors.half2d);
                    GLUI.BeginOrder(2);
                    var bg = new Rect(UI.mousePosRef + os, size, Vectors.half2d);
                    bg.Draw(tipsBgColor, true);

                    if (Events.MouseDown1to3)
                    {
                        Select(i);
                        return;
                    }
                }
            }
        }
Beispiel #7
0
 void DrawQuads(Vector2 a, Vector2 b, Vector2 c, Vector2 d, Color color, Matrix4x4 m)
 {
     a = m.MultiplyPoint(a);
     b = m.MultiplyPoint(b);
     c = m.MultiplyPoint(c);
     d = m.MultiplyPoint(d);
     GLUI.DrawQuad(a, b, c, d, color);
 }
Beispiel #8
0
 public void Update(float t)
 {
     t           = Mathf.Clamp01(t);
     this.t      = t;
     curr.size.x = t * bg.size.x;
     GLUI.DrawQuad(Color.white, bg.ToCW().ToArray());
     GLUI.DrawQuad(color, curr.ToCW().ToArray());
 }
Beispiel #9
0
 public static void DrawLine(Vector2 a, Vector2 b, Color color)
 {
     if (debug)
     {
         Debug.DrawLine(a, b, color);
     }
     else
     {
         GLUI.DrawLine(a, b, color, false);
     }
 }
Beispiel #10
0
 public static void DrawSquare(Vector2 pos, float size, Color color, bool solid)
 {
     if (solid)
     {
         GLUI.DrawQuad(ToPointsRect(pos, size), color);
     }
     else
     {
         DrawSquare(pos, size, color);
     }
 }
Beispiel #11
0
 public static void Draw(this Rect rt, Color color, bool solid = false)
 {
     if (solid)
     {
         GLUI.DrawQuad(rt.ToPointsCWLT(), color);
     }
     else
     {
         Draw(rt.ToPointsCWLT(), color);
     }
 }
Beispiel #12
0
 public static void BeginOrtho(this MonoBehaviour mono, int glOrder = 0)
 {
     UI.owner = mono.gameObject;
     UI.ClearCmd();
     if (glOrder != 0)
     {
         UI.gl.order = glOrder;
     }
     GLUI._insertOrder = 0;
     GLUI.BeginOrder(0);
     GLUI.LoadOrtho();
 }
Beispiel #13
0
 public static void BeginOrtho(this object obj, int glOrder = 0)
 {
     UI.owner = obj;
     UI.ClearCmd();
     if (glOrder != 0)
     {
         UI.gl.order = glOrder;
     }
     GLUI._insertOrder = 0;
     GLUI.BeginOrder(0);
     GLUI.LoadOrtho();
 }
Beispiel #14
0
 void DrawLine(Vector2 a, Vector2 b, Color color, Matrix4x4 m, float width = 1f)
 {
     a = m.MultiplyPoint(a);
     b = m.MultiplyPoint(b);
     if (width == 1)
     {
         GLUI.DrawLine(a, b, color, clip);
     }
     else
     {
         GLUI.DrawLine(a, b, width, color, clip);
     }
 }
Beispiel #15
0
        void _Input()
        {
            this.BeginOrtho();
            this.DrawBG();
            var rtHead = new Rect(headRT);
            var rtName = new Rect(nameRT);
            var rtProp = new Rect(propRT);

            GLUI.DrawTex(headTex, UITool.GetVS(rtHead.cornerLB, rtHead.size, Vector2.zero));
            var P = CharCtrl.I.P;

            GLUI.DrawString(rtName.center, P.charName, Vectors.half2d);
            GLUI.DrawString(rtProp.cornerLB, "生命: " + P.hp + "/" + P.hpMax);
            GLUI.DrawString(rtProp.cornerLB + -28.Y(), "魔法: " + P.mp + "/" + P.mpMax);
            GLUI.DrawString(rtProp.cornerLB + -28 * 2.Y(), "经验值: " + P.exp + "/" + P.expMax);
            GLUI.DrawString(rtProp.cornerLB + -28 * 3.Y(), "等级: " + P.lvl);
        }
Beispiel #16
0
        public void Draw()
        {
            t += Time.deltaTime * speed;
            if (t > 1)
            {
                action.SafeInvoke();
                action = null;
                return;
            }
            var size = new Vector2(1, t * 0.5f);

            Rect up   = new Rect(Vector2.up.MulRef(), size.MulRef(), Vector2.up);
            Rect down = new Rect(Vector2.zero, size.MulRef(), Vector2.zero);

            GLUI.DrawQuad(Color.black, up.ToCWA());
            GLUI.DrawQuad(Color.black, down.ToCWA());
        }
Beispiel #17
0
        void Input()
        {
            if (Events.KeyDown(hotkey))
            {
                visible = !visible;
            }
            this.BeginOrtho();
            if (!visible)
            {
                return;
            }

            this.DrawBG();
            var rt     = new RectTrans(this);
            var center = (rt.cornerLT + rt.cornerRT) * 0.5f;
            var pos    = center - 15.Y();

            GLUI.DrawString("控制台(" + hotkey.ToString() + ")", pos, Vectors.half2d);

            var buttonSize = new Vector2(150, 45);

            if (EG.Button("遇战", center - 80.Y(), buttonSize))
            {
                Battle._Start();
            }
            else if (EG.Button("满状态", center - 140.Y(), buttonSize))
            {
                CharCtrl.I.P.hp = CharCtrl.I.P.hpMax;
                CharCtrl.I.P.mp = CharCtrl.I.P.mpMax;
            }
            //if (EG.Button("测试命令", center - 120.Y(), buttonSize))
            //{
            //    SkillMgr.GetSkill("flee").Cast();
            //}
            else if (EG.Button("X", rt.cornerRT - 24.XY() + 2.Y(), 24.XY()))
            {
                visible = !visible;
            }
            else
            {
                this.DoDragWindow();  // 可拖曳窗口
            }
        }
Beispiel #18
0
        void OnRenderObject()
        {
            var cam = Camera.main;

            vp = cam.WorldToViewportPoint(transform.position);

            //GL.LoadOrtho();
            //GLUI._DrawLineDirect(v[0], v[1], Color.red, Color.black);
            mat.SetPass(0);
            GLUI._DrawQuadDirect_CusMat(c, direct);

            //vws = new Vector3[v.Length];
            //for (int j = 0; j < vws.Length; j++)
            //{
            //    vws[j] = cam.ViewportToWorldPoint(v[j].SetZ(zOffset));
            //}
            //vwsArrange = vws.Copy().Arrange(idxs);
            //GLUI._DrawQuadDirect(Color.red, direct);
        }
Beispiel #19
0
Datei: EGUI.cs Projekt: wjk17/WSA
        public static bool Button(string name, Vector2 pos, Vector2 buttonSize)
        {
            var rt   = new Rect(pos, buttonSize);
            var down = false;

            if (Events.MouseDown0)
            {
                UITool.DrawButton(rt, Color.white, 2);
                down = rt.Contains(UI.mousePosRef); // down
            }
            else
            {
                if (rt.Contains(UI.mousePosRef)) // hover
                {
                    UITool.DrawButton(rt, Color.white, 1);
                }
                else
                {
                    UITool.DrawButton(rt, Color.white, 0); // normal
                }
            }
            GLUI.DrawString(name, pos, Vectors.half2d);
            return(down);
        }
Beispiel #20
0
        private void Update()
        {
            this.BeginOrtho();
            this.Draw(Color.grey);
            var pos = UI.AbsRefPos(rtArea) - rtArea.rect.size * 0.5f;
            var scl = rtAreaSize / SizeInt;

            var os           = Matrix4x4.Translate(START);
            var m_CurveToRef = Matrix4x4.TRS(pos, Quaternion.identity, scl) * os;
            var m_RulerToRef = Matrix4x4.TRS(UI.AbsRefPos(ruler) - rulerSize.X() * 0.5f
                                             , Quaternion.identity, rtSize / SizeInt) * os;

            var a = Vector2.zero;
            var b = Vector2.up * SIZE.y;
            var f = 1f / SIZE.x;

            xSpaceTextInRuler = Mathf.RoundToInt(SIZE.x * gridFactorText);
            var fitted = (xSpaceTextInRuler / 5) * 5;

            if (Mathf.Abs(xSpaceTextInRuler - fitted) > maxError)
            {
                fitted = (xSpaceTextInRuler / 2) * 2;
            }

            xSpaceTextInRuler = Mathf.Max(2, fitted);


            xSpaceLineInRuler = Mathf.RoundToInt(SIZE.x * gridFactorLine);
            fitted            = (xSpaceLineInRuler / 5) * 5;
            if (Mathf.Abs(xSpaceLineInRuler - fitted) > maxError)
            {
                fitted = (xSpaceLineInRuler / 2) * 2;
            }

            xSpaceLineInRuler = Mathf.Max(2, xSpaceLineInRuler);

            // grid
            for (int i = Mathf.RoundToInt(-START.x); i < -START.x + SIZE.x; i++)
            {
                if ((i % xSpaceLineInRuler) == 0)
                {
                    a.x = b.x = i; // 曲线空间坐标
                    DrawLine(a, b, I.clrGrid, m_CurveToRef);
                }
                if ((i % xSpaceTextInRuler) == 0)
                {
                    a.x = i + f * 0.5f;
                    Vector2 c = m_RulerToRef.MultiplyPoint(a);
                    c = rulerPos + c.ToLT();
                    GLUI.DrawString(i.ToString(), c, Vectors.half2d);// 画字 帧号标签
                }
            }
            // timeline
            GLUI.BeginOrder(5);
            b.x = a.x = frameIdx;
            DrawLine(a, b, I.clrTimeLine, m_CurveToRef, width);
            // axis
            GLUI.BeginOrder(2);
            b.x = a.x = 0;
            DrawLine(a, b, I.clrAxis, m_CurveToRef, width);
        }
Beispiel #21
0
        public void Input()
        {
            ic.order = drawOrder;
            this.BeginOrtho();
            var startPos = this.AbsRefPos();

            rects = new List <Rect>();
            for (int y = 0; y < gridCount.y; y++)
            {
                for (int x = 0; x < gridCount.x; x++)
                {
                    rects.Add(new Rect(startPos + gridOsFactor * new Vector2(x, y) *
                                       (gridOs + gridSize), gridSize, pivot));
                }
            }
            var i = 0; bool clicked = false;

            foreach (var rt in rects)
            {
                if (visible.NotEmpty() && !visible[i])
                {
                    i++; continue;
                }
                GLUI.fontColor = fontColor;
                GLUI.BeginOrder(0);

                if (!clickable[i])
                {
                    DrawButton(rt, 2);
                }
                else
                {
                    if (rt.Contains(UI.mousePosRef) && clickable[i])
                    {
                        OnOver(i);
                        if (Events.Mouse1to3)
                        {
                            DrawButton(rt, 2);
                            if (Events.MouseDown1to3 && !clicked)
                            {
                                OnClick(i);
                                clicked = true;
                            }
                        }
                        else
                        {
                            DrawButton(rt, 1);
                            if (drawTips)
                            {
                                // tips
                                var str  = names[i];
                                var size = IMUI.CalSize(str);
                                size += fontBorder;

                                var os = offset + osFactor * size;
                                GLUI.DrawString(str, UI.mousePosRef + os, Vectors.half2d);
                                GLUI.BeginOrder(3);
                                var bg = new Rect(UI.mousePosRef + os, size, Vectors.half2d);
                                bg.Draw(Color.white, true);
                            }
                        }
                    }
                    else
                    {
                        DrawButton(rt, 0);
                    }
                    if (drawName)
                    {
                        GLUI.DrawString(names[i], (rt.pos + nameOffset), Vectors.half2d);
                    }
                    GLUI.BeginOrder(1);
                    if (textures.NotEmpty() && textures[i] != null)
                    {
                        GLUI.DrawTex(textures[i], rt.ToPointsCWLT(-1));
                    }

                    GLUI.SetLineMat();
                    GLUI.BeginOrder(0);
                }
                // 待做优化 tex和line分开两个loop
                GLUI.BeginOrder(2);
                if (drawBorder)
                {
                    rt.Draw(drawBorderClr, false);
                }
                i++;
            }
        }
Beispiel #22
0
 public static void StartGL(this MonoBehaviour mono)
 {
     StartGLWorld(mono);
     GLUI.LoadOrtho();
 }
Beispiel #23
0
 internal void DrawTexture()
 {
     GLUI.DrawTex(texture, rect.ToPointsCWLT(-1));
 }
Beispiel #24
0
        public override void ExecuteCommand(Cmd command)
        {
            var cmd = command as GLCmd;

            switch (cmd.type)
            {
            case GLCmdType.LoadOrtho: GL.LoadOrtho(); break;

            case GLCmdType.LoadMatrix: GL.LoadProjectionMatrix((Matrix4x4)cmd.args[0]); break;

            case GLCmdType.PushMatrix: GL.PushMatrix(); break;

            case GLCmdType.PopMatrix: GL.PopMatrix(); break;

            case GLCmdType.SetLineMat: GLUI.SetLineMaterial(); break;

            case GLCmdType.SetFontColor:
                if (ArgType <Color>(cmd))
                {
                    GLUI._SetFontColor((Color)cmd.args[0]);
                }
                break;

            case GLCmdType.DrawString:
                if (ArgType <Vector2, string, int, Vector2>(cmd))
                {
                    GLUI._DrawString((Vector2)cmd.args[0], (string)cmd.args[1], (int)cmd.args[2], (Vector2)cmd.args[3]);
                }
                else
                {
                    Debug.Log("DrawString Error");
                }
                break;

            case GLCmdType.DrawGrid:
                if (ArgType <Vector3, float, Color>(cmd))
                {
                    GLUI._DrawGrid((Vector3)cmd.args[0], (float)cmd.args[1], (Color)cmd.args[2]);
                }
                else
                {
                    Debug.Log("DrawGrid Error");
                }
                break;

            case GLCmdType.DrawLineDirect:
                if (ArgType <Vector3, Vector3, Color, Color>(cmd))
                {
                    GLUI._DrawLineDirect((Vector3)cmd.args[0], (Vector3)cmd.args[1], (Color)cmd.args[2], (Color)cmd.args[3]);
                }
                else if (ArgType <Vector3, Vector3, Color>(cmd))
                {
                    GLUI._DrawLineDirect((Vector3)cmd.args[0], (Vector3)cmd.args[1], (Color)cmd.args[2]);
                }
                else
                {
                    Debug.Log("Error");
                }
                break;

            case GLCmdType.DrawLineOrtho:
                if (ArgType <Vector2, Vector2>(cmd))
                {
                    GLUI._DrawLineOrtho((Vector2)cmd.args[0], (Vector2)cmd.args[1]);
                }
                else if (ArgType <Vector2, Vector2, Color>(cmd))
                {
                    GLUI._DrawLineOrtho((Vector2)cmd.args[0], (Vector2)cmd.args[1], (Color)cmd.args[2]);
                }
                else if (ArgType <Vector2, Vector2, Color, bool>(cmd))
                {
                    GLUI._DrawLineOrtho((Vector2)cmd.args[0], (Vector2)cmd.args[1], (Color)cmd.args[2], (bool)cmd.args[3]);
                }
                else if (ArgType <Vector2, Vector2, float>(cmd))
                {
                    GLUI._DrawLineWidth((Vector2)cmd.args[0], (Vector2)cmd.args[1], (float)cmd.args[2]);
                }
                else if (ArgType <Vector2, Vector2, float, Color>(cmd))
                {
                    GLUI._DrawLineWidth((Vector2)cmd.args[0], (Vector2)cmd.args[1], (float)cmd.args[2], (Color)cmd.args[3]);
                }
                else if (ArgType <Vector2, Vector2, float, Color, bool>(cmd))
                {
                    GLUI._DrawLineWidth((Vector2)cmd.args[0], (Vector2)cmd.args[1], (float)cmd.args[2], (Color)cmd.args[3], (bool)cmd.args[4]);
                }
                else
                {
                    throw new Exception("未定义 参数");
                }
                break;

            case GLCmdType.DrawQuadDirect:
                if (ArgType <Color, Vector3[]>(cmd))
                {
                    GLUI._DrawQuadDirect((Color)cmd.args[0], (Vector3[])cmd.args[1]);
                }
                else
                {
                    throw new Exception("未定义 参数");
                }
                break;

            case GLCmdType.DrawQuadOrtho:
                if (ArgType <Color, Vector3[]>(cmd))
                {
                    GLUI._DrawQuad((Color)cmd.args[0], (Vector3[])cmd.args[1]);
                }
                else if (ArgType <Color, Vector2[]>(cmd))
                {
                    GLUI._DrawQuad((Color)cmd.args[0], (Vector2[])cmd.args[1]);
                }
                else
                {
                    throw new Exception("未定义 参数");
                }
                break;

            case GLCmdType.DrawTexOrtho:
                if (ArgType <Texture2D, Color, Vector2[], Vector2[]>(cmd))
                {
                    GLUI._DrawTex((Texture2D)cmd.args[0], (Color)cmd.args[1],
                                  (Vector2[])cmd.args[2],
                                  (Vector2[])cmd.args[3]);
                }
                else if (ArgType <Texture2D, Color, Vector2, Vector2, Vector2, Vector2>(cmd))
                {
                    GLUI._DrawTex((Texture2D)cmd.args[0], (Color)cmd.args[1],
                                  (Vector2)cmd.args[2],
                                  (Vector2)cmd.args[3],
                                  (Vector2)cmd.args[4],
                                  (Vector2)cmd.args[5]);
                }
                else
                {
                    string str = "";
                    foreach (var arg in cmd.args)
                    {
                        str += (str.Length > 0 ? ", " : "") + arg.GetType().Name;
                    }
                    throw new Exception("undef(" + cmd.args.Length + "): " + str);
                }
                break;

            default: throw new Exception("未定义 命令");
            }
        }
Beispiel #25
0
 internal void DrawName(Vector2 os)
 {
     GLUI.DrawString(name, (rect.pos + os), Vectors.half2d);
 }
Beispiel #26
0
        public static void DrawBG(this Rect rt, Texture2D tex, float cornerSize, Color color, bool drawCenter = true)
        {
            var corSize_Ref = Vector2.one * 10f;
            var corSize     = Vector2.one * cornerSize;
            var texSize     = tex.Size();
            var corSize_uv  = corSize_Ref / texSize;
            var w           = rt.size.x - corSize.x * 2f;
            var h           = rt.size.y - corSize.y * 2f;

            var wS = new Vector2(w, corSize.y);
            var hS = new Vector2(corSize.x, h);

            var wS_uv = new Vector2(texSize.x - corSize_Ref.x * 2, corSize_Ref.y) / texSize;
            var hS_uv = new Vector2(corSize_Ref.x, texSize.y - corSize_Ref.y * 2) / texSize;

            // LBcorner
            var uv = GetVS(Vector2.zero, corSize_uv, Vector2.zero);
            var v  = GetVS(rt.cornerLB, corSize, Vector2.zero);

            GLUI.DrawTex(tex, color, v, uv);

            // LT
            uv = GetVS(Vector2.up, corSize_uv, Vector2.up);
            v  = GetVS(rt.cornerLT, corSize, Vector2.up);
            GLUI.DrawTex(tex, color, v, uv);

            // RT
            uv = GetVS(Vector2.one, corSize_uv, Vector2.one);
            v  = GetVS(rt.cornerRT, corSize, Vector2.one);
            GLUI.DrawTex(tex, color, v, uv);

            // RB
            uv = GetVS(Vector2.right, corSize_uv, Vector2.right);
            v  = GetVS(rt.cornerRB, corSize, Vector2.right);
            GLUI.DrawTex(tex, color, v, uv);

            // T
            uv = GetVS(Vector2.up + corSize_uv.X(), wS_uv, Vector2.up);
            v  = GetVS(rt.cornerLT + corSize.X(), wS, Vector2.up);
            GLUI.DrawTex(tex, color, v, uv);

            // B
            uv = GetVS(corSize_uv.X(), wS_uv, Vector2.zero);
            v  = GetVS(rt.cornerLB + corSize.X(), wS, Vector2.zero);
            GLUI.DrawTex(tex, color, v, uv);

            // L
            uv = GetVS(corSize_uv.Y(), hS_uv, Vector2.zero);
            v  = GetVS(rt.cornerLB + corSize.Y(), hS, Vector2.zero);
            GLUI.DrawTex(tex, color, v, uv);

            // R
            uv = GetVS(Vector2.right + corSize_uv.Y(), hS_uv, Vector2.right);
            v  = GetVS(rt.cornerRB + corSize.Y(), hS, Vector2.right);
            GLUI.DrawTex(tex, color, v, uv);

            if (drawCenter)
            {
                // Center
                uv = GetVS(corSize_uv, Vector2.one - corSize_uv * 2f, Vector2.zero);
                v  = GetVS(rt.cornerLB + corSize, new Vector2(w, h), Vector2.zero);
                GLUI.DrawTex(tex, color, v, uv);
            }
        }
Beispiel #27
0
 void DrawLine(string s)
 {
     GLUI.DrawString(s, pos, Vector2.up);
     pos.y += lineSpace;
 }
Beispiel #28
0
        public void Input()
        {
            this.BeginOrtho(drawOrder);
            var RT       = new RectTrans(this);
            var startPos = margin + RT.centerT;

            var psy = startPos.Average(osAbs.Y(), gridCount.y, Vector2.zero);

            for (int y = 0; y < gridCount.y; y++)
            {
                var os = osAbs != Vector2.zero ? osAbs : gridOs + gridSize;
                var ps = psy[y].Average(os.x, gridCount.x, Vectors.halfRight2d);
                for (int x = 0; x < gridCount.x; x++)
                {
                    var n = new Rect(ps[x], gridSize, pivot);
                    gridUnitProp[y * gridCount.x + x].rect = n;
                }
            }
            var i = 0; bool clicked = false;

            foreach (var gup in gridUnitProp)
            {
                if (!gup.visible)
                {
                    i++; continue;
                }
                GLUI.SetFontColor(fontColor);
                GLUI.BeginOrder(0);

                if (!gup.clickable)
                {
                    DrawButton(gup, 2);
                    if (drawName)
                    {
                        gup.DrawName(nameOffset);
                    }

                    if (gup.Hover())
                    {
                        Events.Use();
                    }
                }
                else
                {
                    if (gup.Hover() && !Events.used)
                    {
                        OnOver(i);
                        if (Events.Mouse1to3)
                        {
                            DrawButton(gup, 2);
                            if (Events.MouseDown1to3 && !clicked)
                            {
                                OnClick(i);
                                clicked = true;
                            }
                        }
                        else
                        {
                            DrawButton(gup, 1);
                        }
                        Events.Use();
                    }
                    else
                    {
                        DrawButton(gup, 0);
                    }

                    if (drawName)
                    {
                        gup.DrawName(nameOffset);
                    }

                    GLUI.BeginOrder(1);

                    if (gup.texture != null)
                    {
                        gup.DrawTexture();
                    }

                    GLUI.SetLineMat();
                    GLUI.BeginOrder(0);
                }
                // 待做优化 tex和line分开两个loop
                GLUI.BeginOrder(2);
                if (drawBorder)
                {
                    gup.rect.Draw(drawBorderClr, false);
                }
                i++;
            }
        }
Beispiel #29
0
        private void Update()
        {
            this.BeginOrtho();

            Curve2.colorCtrlLines = clrCtrlLinesUnSel;
            Curve2.colorBorder    = clrBorder;

            var offset = m_Ref_Curve.ScaleV2(-drawAreaOffset);

            drawAreaStart = offset.RoundToInt();
            drawAreaEnd   = drawAreaStart + drawAreaSize_I;
            // TODO GridLine 对应 Offset调整
            // TODO Offset 绘制Curve

            var lineSpaceFst = (drawAreaSize * gridFactor).RoundToInt();

            lineSpaceFst = Vector2Int.Max(Vector2Int.one * 2, lineSpaceFst);
            var lineSpaceSnd = (lineSpaceFst * Vectors.half2d).RoundToInt();

            // grids
            var a = drawAreaStart;
            var b = new Vector2(drawAreaEnd.x, drawAreaStart.y);

            for (int i = drawAreaStart.y; i <= drawAreaEnd.y; b.y = a.y = i += 1)
            {
                if (i % lineSpaceSnd.y == 0)
                {
                    DrawLine(a, b, (i % lineSpaceFst.y == 0) ? clrGridLinesFst : clrGridLinesSnd, m_Curve_Ref);
                }
            }
            a = drawAreaStart;
            b = new Vector2(drawAreaStart.x, drawAreaEnd.y);
            for (int i = drawAreaStart.x; i <= drawAreaEnd.x; b.x = a.x = i += 1)
            {
                if (i % lineSpaceSnd.x == 0)
                {
                    DrawLine(a, b, (i % lineSpaceFst.x == 0) ? clrGridLinesFst : clrGridLinesSnd, m_Curve_Ref);
                }
            }
            // Timeline 当前帧
            GLUI.BeginOrder(5);
            b.x = a.x = UITimeLine.I.frameIdx;
            DrawLine(a, b, UITimeLine.I.clrTimeLine, m_Curve_Ref);

            // Axis 坐标轴
            GLUI.BeginOrder(2);
            b.x = a.x = 0;
            a.y = drawAreaStart.y;
            b.y = drawAreaEnd.y;
            DrawLine(a, b, UITimeLine.I.clrAxis, m_Curve_Ref);

            b.y = a.y = 0;
            a.x = drawAreaStart.x;
            b.x = drawAreaEnd.x;
            DrawLine(a, b, UITimeLine.I.clrAxis, m_Curve_Ref);

            if (curveObj == null)
            {
                return;
            }
            var cc = 0;

            // Curve
            foreach (var curve in curveObj.curves)
            {
                if (drawSelOnly)
                {
                    Curve2.colorTrack = clrTracks[(int)_curveSelType];
                }
                else
                {
                    Curve2.colorTrack = clrTracks[cc++];
                }
                if (drawSelOnly && curve != curveSel)
                {
                    continue;
                }
                if (curve == null || curve.Count == 0)
                {
                    continue;
                }
                if (mirror) // 使用默认方法画出曲线线段
                {
                    curveMirror.drawAreaSize   = drawAreaSize;
                    curveMirror.drawAreaOffset = offset;
                    curveMirror.Draw(m_Curve_Ref, showTangentsUnSel);
                }
                else
                {
                    curve.drawAreaSize   = drawAreaSize;
                    curve.drawAreaOffset = offset;
                    curve.Draw(m_Curve_Ref, showTangentsUnSel);
                }

                // 尾线
                GLUI.BeginOrder(3);
                var l = curve.Last().frameKey;
                var e = new Vector2(drawAreaSize.x, l.y);
                DrawLine(l, e, Curve2.colorTrack, m_Curve_Ref);
            }
            GLUI.BeginOrder(4);
            Key2 k = keySel;

            if (drawSel && k != null)
            {
                var i = (subIdxs != null && id < subIdxs.Count) ? subIdxs[id] : -1;


                if (k.inMode == KeyMode.Bezier)
                {
                    DrawLine(k.frameKey, k.inKey, i == 0 || i == 1 ? clrSubSel : clrCtrlLinesSel, m_Curve_Ref);
                    //DrawTangent(k.inTangent, Curve2.colorTangents, matrixViewToRect);
                }
                if (k.outMode == KeyMode.Bezier && !(mirror && k.time == 0.5f))
                {
                    DrawLine(k.frameKey, k.outKey, i == 0 || i == 2 ? clrSubSel : clrCtrlLinesSel, m_Curve_Ref);
                    //DrawTangent(k.outTangent, Curve2.colorTangents, matrixViewToRect);
                }

                DrawRect(k.frameKey, Vector2.one * sizeDrawVector,
                         Curve2.colorVectors, m_Curve_Ref, i == 0 ? clrSubSel : clrVectorSel, true);
                if (k.inMode == KeyMode.Bezier)
                {
                    DrawRhombus(k.inKey, Vector2.one * sizeDrawTangent,
                                Curve2.colorTangents, m_Curve_Ref, i == 0 || i == 1 ? clrSubSel : clrCtrlLinesSel, true);
                }
                if (k.outMode == KeyMode.Bezier && !(mirror && k.time == 0.5f))
                {
                    DrawRhombus(k.outKey, Vector2.one * sizeDrawTangent,
                                Curve2.colorTangents, m_Curve_Ref, i == 0 || i == 2 ? clrSubSel : clrCtrlLinesSel, true);
                }
            }
        }
Beispiel #30
0
 void DrawLine(Vector2 a, Vector2 b, Color color, Matrix4x4 m) // 接口
 {
     a = m.MultiplyPoint(a);
     b = m.MultiplyPoint(b);
     GLUI.DrawLine(a, b, color);
 }