void DrawPoints()
        {
            for (int i = 0; i < node.lineInfo.pts.Count; i++)
            {
                if (i < node.lineInfo.pts.Count - 1 || rData.l.st)
                {
                    Vector2 v1 = node.lineInfo.pts [i].mousePos;
                    Vector2 v2 = node.lineInfo.pts [(i + 1) % node.lineInfo.pts.Count].mousePos;

                    Vector2 dir = (v2 - v1);
                    float   dis = dir.magnitude;
                    dir.Normalize();
                    float angle = SWCommon.Vector2Angle(v2 - v1);


                    Set_Material(node.lineInfo.pts [i].matArrow, Vector2.zero, -angle, Vector2.one);


                    var item = new Material(SWEditorUI.GetShader("Rect"));
                    Set_Material(item);

                    Vector2 mid = (v2 + v1) * 0.5f;
                    Graphics.DrawTexture(SWCommon.GetRect(mid, new Vector2(IconSize_Arrow, IconSize_Arrow)), SWEditorUI.Texture(SWUITex.effectArrow), node.lineInfo.pts [i].matArrow);
                    SWDraw.DrawLine(v1, v2, Color.white, 1, item);
                }
                GUI.DrawTexture(new Rect(node.lineInfo.pts [i].mousePos.x - brushSize * 1f, node.lineInfo.pts [i].mousePos.y - brushSize * 1f, brushSize * 2f, brushSize * 2f),
                                SWEditorUI.Texture(SWUITex.cursor));
            }


            if (LineEditMode())
            {
                LineEdit_Draw();
            }
        }
Example #2
0
        public override void OnGUITool(SWBaseInfo info, bool isSelected)
        {
            base.OnGUITool(info, isSelected);
            float roundRad = Mathf.Max(info.imageRect.size.x, info.imageRect.size.y) * 0.6f;

            startPos = info.imageRect.center + new Vector2(0, -roundRad + 5);
            rect     = SWCommon.GetRect(startPos + offset, new Vector2(boxSize, boxSize));

            //bg circle
            var c = mat.GetColor("_Color");

            mat.SetColor("_Color", new Color32(128, 128, 128, 255));
            Rect roundRect = SWCommon.GetRect(info.imageRect.center, new Vector2(roundRad * 2, roundRad * 2));

            Graphics.DrawTexture(roundRect, SWEditorUI.Texture(SWUITex.effectRound), mat);
            mat.SetColor("_Color", c);



            mat.SetFloat("r", -SWCommon.Vector2Angle(offset));
            if (offset.magnitude > 8f)
            {
                Graphics.DrawTexture(rect, SWEditorUI.Texture(SWUITex.effectArrow), mat);
            }
            Graphics.DrawTexture(SWCommon.GetRect(startPos, new Vector2(centerSize, centerSize)),
                                 SWEditorUI.Texture(SWUITex.effectCenter), mat);


            mat.SetFloat("r", 0f);
            mat.SetTexture("_MainTex", SWEditorUI.Texture(SWUITex.effectLine));
            SWDraw.DrawLine(startPos, startPos + offset, Color.white, lineWidth, mat);
        }
Example #3
0
        public override void OnGUITool(SWBaseInfo info, bool isSelected)
        {
            center = info.imageRect.center + offset;
            base.OnGUITool(info, isSelected);
            rect = SWCommon.GetRect(center + ArrowOff, new Vector2(boxSize, boxSize));


            mat.SetFloat("r", -SWCommon.Vector2Angle(ArrowOff));
            if (ArrowOff.magnitude > 8f)
            {
                Graphics.DrawTexture(rect, SWEditorUI.Texture(SWUITex.effectArrow), mat);
            }
            Graphics.DrawTexture(SWCommon.GetRect(center, new Vector2(centerSize, centerSize)),
                                 SWEditorUI.Texture(SWUITex.effectCenter), mat);



            mat.SetFloat("r", 0f);
            mat.SetTexture("_MainTex", SWEditorUI.Texture(SWUITex.effectLine));
            SWDraw.DrawLine(center, rect.center, Color.white, lineWidth, mat);

            float dis = ArrowOff.magnitude;

            dis = dis - 3;
            dis = Mathf.Clamp(dis, 0, float.MaxValue);
            Vector2 v = center + ArrowOff.normalized * dis;

            v         = center;
            GUI.color = Color.black;
            GUI.Label(SWCommon.GetRect(v, new Vector2(15, 15)), title);
            GUI.color = Color.white;
        }
Example #4
0
        public override void OnGUITool(SWBaseInfo info, bool isSelected)
        {
            base.OnGUITool(info, isSelected);
            rect = SWCommon.GetRect(info.imageRect.center + new Vector2(0, -info.imageRect.height * 0.5f), new Vector2(boxSize, boxSize));

            mat.SetFloat("r", Mathf.PI * 0.5f);
            Graphics.DrawTexture(rect, SWEditorUI.Texture(SWUITex.effectArrow), mat);

            mat.SetFloat("r", 0);
            mat.SetTexture("_MainTex", SWEditorUI.Texture(SWUITex.effectLine));
            SWDraw.DrawLine(info.imageRect.center, rect.center, Color.white, lineWidth, mat);
        }
Example #5
0
        public override void OnGUITool(SWBaseInfo info, bool isSelected)
        {
            Instance = this;
            base.OnGUITool(info, isSelected);
            rect = SWCommon.GetRect(info.imageRect.center + ArrowOff, new Vector2(boxSize, boxSize));



            mat.SetFloat("r", -SWCommon.Vector2Angle(ArrowOff));
            if (ArrowOff.magnitude > 8f)
            {
                Graphics.DrawTexture(rect, SWEditorUI.Texture(SWUITex.effectArrow), mat);
            }
            Graphics.DrawTexture(SWCommon.GetRect(info.imageRect.center, new Vector2(centerSize, centerSize)),
                                 SWEditorUI.Texture(SWUITex.effectCenter), mat);

            mat.SetFloat("r", 0f);
            mat.SetTexture("_MainTex", SWEditorUI.Texture(SWUITex.effectLine));
            SWDraw.DrawLine(info.imageRect.center, rect.center, Color.white, lineWidth, mat);
        }
        void DrawDir()
        {
            Cursor.visible = true;

            var rect = SWCommon.GetRect(drawRect.center + ArrowOff, new Vector2(IconSize_Arrow, IconSize_Arrow));

            Set_Material(matBase, Vector2.zero, 0, Vector2.one);
            matBase.SetColor("_Color", dragging ? Color.green:Color.white);
            Graphics.DrawTexture(SWCommon.GetRect(drawRect.center, new Vector2(8, 8)),
                                 SWEditorUI.Texture(SWUITex.effectCenter), matBase);

            matBase.SetFloat("r", -SWCommon.Vector2Angle(ArrowOff));
            Graphics.DrawTexture(rect, SWEditorUI.Texture(SWUITex.effectArrow), matBase);


            matBase.SetFloat("r", 0f);
            matBase.SetTexture("_MainTex", SWEditorUI.Texture(SWUITex.effectLine));
            SWDraw.DrawLine(drawRect.center, rect.center, Color.white, 3f, matBase);

            float factor = 1f / drawRect.size.x;

            if (SWCommon.GetMouseDown(0) && InMap())
            {
                RepaintGetDirty();
                if (rect.Contains(Event.current.mousePosition))
                {
                    dragging     = true;
                    lastMousePos = Event.current.mousePosition;
                }
                else
                {
                    dragging = false;
                }
            }
            else if (dragging)
            {
                if (SWCommon.GetMouse(0) && InMap())
                {
                    RepaintGetDirty();
                    ArrowOff += Event.current.mousePosition - lastMousePos;

                    if (Event.current.shift)
                    {
                        if (Mathf.Abs(ArrowOff.x) > Mathf.Abs(ArrowOff.y))
                        {
                            ArrowOff = new Vector2(ArrowOff.x, 0);
                        }
                        else
                        {
                            ArrowOff = new Vector2(0, ArrowOff.y);
                        }
                    }

                    lastMousePos = Event.current.mousePosition;
                    SWUndo.Record(this);
                    rData.d.v = new Vector2(ArrowOff.x * factor, -ArrowOff.y * factor);
                }
                if (SWCommon.GetMouseUp(0))
                {
                    dragging = false;
                    SWUndo.Record(this);
                    rData.d.v = new Vector2(ArrowOff.x * factor, -ArrowOff.y * factor);
                }
            }
            else
            {
                ArrowOff = new Vector2(rData.d.v.x / factor, -rData.d.v.y / factor);
            }



            if (Event.current.type == EventType.KeyDown)
            {
                if (Event.current.keyCode == KeyCode.Return)
                {
                    node.data.dirty = true;
                    SWTextureProcess.ProcessRemap_Dir(node.textureEx, node.texChildResized, new Vector2(rData.d.v.x, -rData.d.v.y), rData.d.pre, rData.d.pb);
                }
            }
        }