Esempio n. 1
0
        public override void AfterLoad()
        {
            base.AfterLoad();
            if (GetChildTexture() != null)
            {
                texChildOrigin  = GetChildTexture();
                texChildResized = SWTextureProcess.TextureResize(texChildOrigin, data.resolution, data.resolution);
            }
            if (textureEx != null)
            {
                if (data.resolution != textureEx.width)
                {
                    data.reso = (SWTexResolution)SWDataNode.resoList.IndexOf(textureEx.width);
                }
            }


            if (data.rd != null && data.rd.l != null && data.rd.l.pts != null)
            {
                for (int i = 0; i < data.rd.l.pts.Count; i++)
                {
                    var           pData = data.rd.l.pts [i];
                    RemapWayPoint pt    = new RemapWayPoint();
                    pt.uv       = pData.uv;
                    pt.matArrow = new Material(SWEditorUI.GetShader("RectTRS"));
                    lineInfo.pts.Add(pt);
                }
            }
        }
Esempio n. 2
0
        void ShowBG_Textures()
        {
            foreach (var tempNode in SWWindowMain.Instance.nodes)
            {
                if (tempNode.data.id == node.data.id)
                {
                    continue;
                }
                if (tempNode is SWNodeMask)
                {
                    continue;
                }
                var tex = tempNode.Texture;
                if (tex == null)
                {
                    continue;
                }
                if (!node.data.layerMask.Has(tempNode.data.id))
                {
                    continue;
                }

                var      dt     = tempNode.data;
                Material matBot = new Material(SWEditorUI.GetShader("RectTRS"));
                Set_Material(matBot, -dt.effectData.t_startMove, dt.effectData.r_angle, dt.effectData.s_scale);
                Set_MaterialLoop(matBot, dt);
                Graphics.DrawTexture(drawRect, tex, matBot);
            }
        }
Esempio n. 3
0
        void ShowBG_Right()
        {
            var dic = node.GetParentNodeAllAll();
            List <SWNodeBase> parentNodes = new List <SWNodeBase> ();

            foreach (var item in dic)
            {
                parentNodes.Add(item.Value);
            }
            parentNodes.Reverse();

            foreach (var item in parentNodes)
            {
                if (item is SWNodeMask)
                {
                    continue;
                }
                var tex = item.Texture;
                if (tex == null)
                {
                    continue;
                }
                Material matBotMasked = new Material(SWEditorUI.GetShader("RectTRSMask"));
                Set_MaterialMask(matBotMasked, -item.data.effectData.t_startMove, item.data.effectData.r_angle, item.data.effectData.s_scale, node.texMask.Texture);
                Graphics.DrawTexture(previewRect, tex, matBotMasked);
            }
            GUI.Label(new Rect(previewRect.x + previewRect.width - 100 - 30, previewRect.y + 5, 100, 20), "Masked Area Preview", SWEditorUI.Style_Get(SWCustomStyle.eTxtLight));
        }
        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();
            }
        }
        void DrawPreview(Rect rect)
        {
            //When pressing in the area,show masked area
            if (SWWindowMain.Instance.mousePressing && rect.Contains(Event.current.mousePosition))
            {
                if (HasParentTexture())
                {
                    List <SWNodeBase> parentNodes = GetParentNodes();
                    foreach (var item in parentNodes)
                    {
                        if (item.texture == null)
                        {
                            continue;
                        }
                        Material matBotMasked = new Material(SWEditorUI.GetShader("RectTRSMask"));
                        matBotMasked.SetVector("t", -item.data.effectData.t_startMove);
                        matBotMasked.SetFloat("r", item.data.effectData.r_angle);
                        matBotMasked.SetVector("s", item.data.effectData.s_scale);
                        matBotMasked.SetTexture("_Mask", texMask.Texture);
                        matBotMasked.SetVector("rectShow", SWWindowMain.Instance.rectShow);

                        Graphics.DrawTexture(rect, item.texture, matBotMasked);
                    }
                }
                else
                {
                    GUI.DrawTexture(rect, texMask.Texture);
                }
            }
            //Show Green Mask usually
            else
            {
                GUI.DrawTexture(rect, texMask.Texture);
            }
        }
Esempio n. 6
0
        void ShowBG_Textures()
        {
            foreach (var item in SWWindowMain.Instance.NodeAll())
            {
                if (item.Value.data.id == info.effector.data.id)
                {
                    continue;
                }
                var tex = item.Value.Texture;
                if (item.Value is SWNodeMask)
                {
                    tex = ((SWNodeMask)item.Value).texMask.Texture;
                }
                if (tex == null)
                {
                    continue;
                }
                if (!info.effector.data.layerMask.Has(item.Value.data.id))
                {
                    continue;
                }

                var      dt     = item.Value.data;
                Material matBot = new Material(SWEditorUI.GetShader("RectTRS"));
                Set_Material(matBot, -dt.effectData.t_startMove, dt.effectData.r_angle, dt.effectData.s_scale);
                Set_MaterialLoop(matBot, dt);
                Graphics.DrawTexture(info.baseRect, tex, matBot);
            }
        }
        void DrawLine()
        {
            //Add Point
            if (SWCommon.GetMouseDown(0) && al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY)))
            {
                if (!al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY)))
                {
                    return;
                }
                if (!drawRect.Contains(mousePos))
                {
                    return;
                }

                SWUndo.Record(info);
                Vector2 m = Event.current.mousePosition;
                m = m - drawRect.position;
                m = SWTextureProcess.TexUV(size, size, (int)m.x, (int)m.y);

                RemapWayPoint pt = new RemapWayPoint();
                pt.uv       = m;
                pt.mousePos = mousePos;
                pt.matArrow = new Material(SWEditorUI.GetShader("RectTRS"));
                info.pts.Add(pt);
            }

            DrawPoints();

            //Draw Cursor
            if (focusedWindow == this)
            {
                if (al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY)) && drawRect.Contains(mousePos))
                {
                    GUI.DrawTexture(new Rect(mousePos.x - brushSize * 1f, mousePos.y - brushSize * 1f, brushSize * 2f, brushSize * 2f), SWEditorUI.Texture(SWUITex.cursor));
                    GUI.DrawTexture(new Rect(mousePos.x - 8, mousePos.y - 8, 16, 16), SWEditorUI.Texture(SWUITex.cursorCenter));
                    Cursor.visible = false;
                }
                else
                {
                    Cursor.visible = true;
                }
            }
            //Key Command
            if (Event.current.type == EventType.keyDown)
            {
                if (Event.current.keyCode == KeyCode.Return)
                {
                    node.data.dirty = true;
                    SWTextureProcess.ProcessRemap_Line(node.textureEx, info, brushSizeUV);
                }
            }
        }
Esempio n. 8
0
        public override void OnGUI()
        {
            // this can be null when start playing
            if (this == null)
            {
                return;
            }
            matBase = new Material(SWEditorUI.GetShader("RectTRS"));
            UpdateXX();
            base.OnGUI();


            float x = al_leftWidth / position.width;
            float y = (al_scrollBarWidth) / position.height;
            float z = 1 - al_scrollBarWidth / position.width;
            float w = 1 - (al_startY + al_topHeight) / position.height;

            x        = x * 2 - 1;
            y        = y * 2 - 1;
            z        = z * 2 - 1;
            w        = w * 2 - 1;
            rectShow = new Vector4(x, y, z, w);
            matBase.SetVector("rectShow", rectShow);



            EditorGUIUtility.labelWidth = SWGlobalSettings.LabelWidth;

            OnGUIBot();

            DrawMain();
            GUILayout.Space(5);
            GUILayout.BeginHorizontal(GUILayout.Height(al_topHeight));
            DrawTop();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical(GUILayout.Width(al_leftWidth));
            DrawLeft();
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            DrawRight();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            OnGUITop();
            EditorGUIUtility.labelWidth = 0f;
            GUIEnd();
        }
Esempio n. 9
0
 void ShowBG_Root()
 {
     if (SWWindowMain.Instance.nRoot.texture != null)
     {
         var item = SWWindowMain.Instance.nRoot;
         var tex  = item.Texture;
         if (tex == null)
         {
             return;
         }
         Material matBot = new Material(SWEditorUI.GetShader("RectTRS"));
         Set_Material(matBot, -item.data.effectData.t_startMove, item.data.effectData.r_angle, item.data.effectData.s_scale);
         Graphics.DrawTexture(drawRect, tex, matBot);
     }
 }
Esempio n. 10
0
        protected void ShowBG_SingleTex(SWNodeBase tempNode, bool loop)
        {
            var tex = tempNode.Texture;

            if (tex == null)
            {
                return;
            }
            var      dt     = tempNode.data;
            Material matBot = new Material(SWEditorUI.GetShader("RectTRS"));

            Set_Material(matBot, -dt.effectData.t_startMove, dt.effectData.r_angle, dt.effectData.s_scale);
            if (loop)
            {
                Set_MaterialLoop(matBot, dt);
            }
            Graphics.DrawTexture(drawRect, tex, matBot);
        }
Esempio n. 11
0
 void ShowBG_Masks()
 {
     foreach (var item in SWWindowMain.Instance.NodeAll())
     {
         if (!(item.Value is SWNodeMask))
         {
             continue;
         }
         if (!node.data.layerMask.Has(item.Value.data.id))
         {
             continue;
         }
         var        dt       = item.Value.data;
         SWNodeMask nodeMask = (SWNodeMask)item.Value;
         Material   matBot   = new Material(SWEditorUI.GetShader("RectTRSPremask"));
         Set_Material(matBot, -dt.effectData.t_startMove, dt.effectData.r_angle, dt.effectData.s_scale);
         Graphics.DrawTexture(drawRect, nodeMask.texMask.Texture, matBot);
     }
 }
        void LinePlaceUpdate()
        {
            //Add Point
            //if (SWCommon.GetMouseDown (0) && al_rectMain.Contains(mousePosOut+new Vector2(0,al_startY))) {
            if (SWCommon.GetMouseDown(0) && InMap())
            {
                if (!al_rectMain.Contains(mousePosOut + new Vector2(0, al_startY)))
                {
                    return;
                }
                if (!drawRect.Contains(mousePos))
                {
                    return;
                }

                SWUndo.Record(node.lineInfo);

                RemapWayPoint pt = new RemapWayPoint();
                UpdateRemapWayPoint(pt, Event.current.mousePosition);
                pt.matArrow = new Material(SWEditorUI.GetShader("RectTRS"));
                node.lineInfo.pts.Add(pt);
            }
        }
Esempio n. 13
0
 public override void InitOnce()
 {
     base.InitOnce();
     matBase = new Material(SWEditorUI.GetShader("RectTRS"));
 }