Ejemplo n.º 1
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;
        }
        /// <summary>
        /// For GUILayout
        /// </summary>
        public static void Rec(string tip, float yoff = 5)
        {
            Rect last    = GUILayoutUtility.GetLastRect();
            Rect newRect = SWCommon.GetRect(last.center, last.size);

            Rec(tip, newRect, yoff);
        }
Ejemplo n.º 3
0
        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();
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public override void OnGUITool(SWBaseInfo info, bool isSelected)
        {
            base.OnGUITool(info, isSelected);
            var item = GUI.matrix;

            rect = SWCommon.GetRect(info.imageRect.center, new Vector2(centerSize, centerSize));
            Graphics.DrawTexture(rect, SWEditorUI.Texture(SWUITex.effectPos), mat);
        }
Ejemplo n.º 6
0
 void LineEdit_Draw()
 {
     for (int i = 0; i < node.lineInfo.pts.Count; i++)
     {
         var pt   = node.lineInfo.pts [i];
         var rect = SWCommon.GetRect(pt.mousePos, new Vector2(IconSize_Center, IconSize_Center));
         GUI.DrawTexture(rect, SWEditorUI.Texture(SWUITex.effectPos));
     }
 }
Ejemplo n.º 7
0
        public override void OnGUITool(SWBaseInfo info, bool isSelected)
        {
            base.OnGUITool(info, isSelected);
            roundRad = Mathf.Max(info.imageRect.size.x, info.imageRect.size.y) * 0.6f;
            rect     = SWCommon.GetRect(info.imageRect.center + new Vector2(-roundRad, 0), new Vector2(boxSize, boxSize));
            Rect roundRect = SWCommon.GetRect(info.imageRect.center, new Vector2(roundRad * 2.04f, roundRad * 2.04f));

            Graphics.DrawTexture(roundRect, SWEditorUI.Texture(SWUITex.effectRound), mat);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        protected virtual void DrawHead()
        {
            SetRectsAll();

            rectBig = SWCommon.GetRect(data.rect.center, data.rect.size * 1.25f);


            if (LeftAvailable())
            {
                for (int i = 0; i < rectLefts.Count; i++)
                {
                    if (!SWWindowMain.Instance.lineStartNodeFromLeft && SWWindowMain.Instance.lineStartNode != null &&
                        PortMatch(i, SWWindowMain.Instance.lineStartNode, SWWindowMain.Instance.lineStartNodePort))
                    {
                        GUI.color = SWEditorUI.ColorPalette(SWColorPl.green);
                    }
                    else
                    {
                        GUI.color = SWEditorUI.ColorPalette(SWColorPl.light);
                    }
                    GUI.DrawTexture(rectLefts[i], EditorGUIUtility.whiteTexture);
                }
                GUI.color = Color.white;
            }

            if (RightAvailable())
            {
                for (int i = 0; i < rectRights.Count; i++)
                {
                    if (SWWindowMain.Instance.lineStartNodeFromLeft && SWWindowMain.Instance.lineStartNode != null &&
                        SWWindowMain.Instance.lineStartNode.PortMatch(SWWindowMain.Instance.lineStartNodePort, this, i))
                    {
                        GUI.color = SWEditorUI.ColorPalette(SWColorPl.green);
                    }
                    else
                    {
                        GUI.color = SWEditorUI.ColorPalette(SWColorPl.light);
                    }
                    GUI.DrawTexture(rectRights[i], EditorGUIUtility.whiteTexture);
                }
                GUI.color = Color.white;
            }

            for (int i = 0; i < rectLefts.Count; i++)
            {
                DrawLeftRect(i, rectLefts[i]);
            }
            for (int i = 0; i < rectRights.Count; i++)
            {
                DrawRightRect(i, rectRights[i]);
            }
        }
        public void Draw()
        {
            data.rect = GUI.Window(index, data.rect, DrawNodeWindow, "", Style);
            //		GUI.BeginGroup(data.rect);
            //		DrawNodeWindow(0);
            //		GUI.EndGroup();
            DrawHead();


            if (SWWindowMain.Instance.selection.Contains(data.id))
            {
                Rect frameRect = SWCommon.GetRect(data.rect.center, new Vector2(
                                                      data.rect.size.x + 20f, data.rect.size.y + 18f));
                GUI.Box(frameRect, "", SWEditorUI.Style_Get(SWCustomStyle.eNodeSelected));
            }
        }
Ejemplo n.º 11
0
        public void Draw()
        {
            //performance	: only render nodes inside main rect
            if (SWCommon.RectContainsRect(window.al_rectMainInsideZoom, data.rect, false))
            {
                data.rect = GUI.Window(index, data.rect, DrawNodeWindow, "", Style);
            }
            Tooltip();

            DrawHead();

            if (SWWindowMain.Instance.selection.Contains(data.id))
            {
                Rect frameRect = SWCommon.GetRect(data.rect.center, new Vector2(
                                                      data.rect.size.x + 20f, data.rect.size.y + 18f));
                GUI.Box(frameRect, "", SWEditorUI.Style_Get(SWCustomStyle.eNodeSelected));
            }
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
        void Draw()
        {
            if (pause)
            {
                return;
            }
            Repaint();
            if (focusedWindow == this)
            {
                ShowBG_Right();
                if (brush.mode == SWBrushMode.wand || brush.mode == SWBrushMode.dropper)
                {
                    ShowBG_Root();
                }
                else
                {
                    //Draw textures(choosed in laymask) normally except mask nodes
                    ShowBG_Textures();
                    //Draw maskes(choosed in laymask)
                    ShowBG_Masks();
                }


                GUI.color = new Color(1, 1, 1, 0.5f);
                GUI.DrawTexture(drawRect, node.texMask.Texture, ScaleMode.StretchToFill);
                GUI.color = new Color(1, 1, 1, 1f);

                if (al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY)) && drawRect.Contains(mousePos))
                {
                    float size    = brush.size * 1f;
                    Rect  outRect = new Rect(mousePos.x - size, mousePos.y - size, size * 2f, size * 2f);
                    size = 6f;
                    size = Mathf.Min(size, brush.size);

                    Rect innerRect = new Rect(mousePos.x - size, mousePos.y - size, size * 2f, size * 2f);
                    size = 16;
                    Rect innerRectBig = new Rect(mousePos.x - size, mousePos.y - size, size * 2f, size * 2f);
                    if (brush.mode == SWBrushMode.wand)
                    {
                        GUI.DrawTexture(innerRectBig, SWEditorUI.Texture(SWUITex.cursorWand));
                    }
                    else if (brush.mode == SWBrushMode.dropper)
                    {
                        GUI.DrawTexture(innerRectBig, SWEditorUI.Texture(SWUITex.cursorDropper));
                    }
                    else
                    {
                        Texture2D icon       = SWEditorUI.Texture(SWUITex.cursor);
                        Texture2D iconCenter = SWEditorUI.Texture(SWUITex.cursorCenter);
                        GUI.DrawTexture(outRect, icon);
                        GUI.DrawTexture(innerRect, iconCenter);

                        Rect outRectRight = SWCommon.GetRect(outRect.center + new Vector2(drawRect.width, 0), outRect.size);
                        GUI.DrawTexture(outRectRight, icon);
                    }
                    Cursor.visible = false;
                }
                else
                {
                    Cursor.visible = true;
                }
            }

            DrawFrame(drawRect);
            DrawFrame(previewRect);
        }
Ejemplo n.º 14
0
        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);
                }
            }
        }