protected override void DrawNodeWindow(int id)
        {
            base.DrawNodeWindow(id);
            GUILayout.Space(7);
            GUILayout.BeginHorizontal();
            GUILayout.Space(7);
            GUILayout.BeginVertical();

            float labelWith = 42;

            EffectDataColor _data = data.effectDataColor;
            string          name  = _data.hdr ? "[HDR]" : "Color";

            GUILayout.BeginHorizontal();
            GUILayout.Label(name, SWEditorUI.Style_Get(SWCustomStyle.eTxtSmallLight), GUILayout.Width(labelWith));
            SWCommon.HRDColor_Switch(window, ref data.effectDataColor.hdr);
            SWCommon.HRDColor_Field(_data.color, true, _data.hdr, 128 - labelWith, delegate(Color c) {
                _data.color = c;
                SWProperties.SetColor(data, _data.color);
            }
                                    );
            GUILayout.EndHorizontal();


            GUILayout.Space(2);
            ePopup_op.Show(128 - labelWith, "Op", labelWith);
            GUILayout.Space(2);
            SWWindowMain.Instance.Factor_Pick(ref _data.param, PickParamType.node, "Factor", null, 128);

            GUILayout.Space(2);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Depth", SWEditorUI.Style_Get(SWCustomStyle.eTxtSmallLight), GUILayout.Width(labelWith));
            var dep = EditorGUILayout.IntField(data.depth, GUILayout.Width(128 - labelWith));

            if (dep != 0 && dep != data.depth)
            {
                SWUndo.Record(this);
                data.depth = dep;
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            DrawNodeWindowEnd();
        }
        protected override void DrawNodeWindow(int id)
        {
            base.DrawNodeWindow(id);
            if (SWWindowMain.Instance.data.shaderType == SWShaderType.normal)
            {
                DrawNormal();
            }
            else if (SWWindowMain.Instance.data.shaderType == SWShaderType.sprite)
            {
                DrawSprite();
            }
            else if (SWWindowMain.Instance.data.shaderType == SWShaderType.ui)
            {
                DrawUIImage();
            }
            else if (SWWindowMain.Instance.data.shaderType == SWShaderType.uiFont)
            {
                DrawUIText();
            }
            else if (SWWindowMain.Instance.data.shaderType == SWShaderType.ngui_ui2dSprite)
            {
                DrawUIImage();
            }

            float labelWith = 38;

            GUILayout.Space(nodeHeight - 42);


            EffectDataColor _data = data.effectDataColor;
            string          name  = _data.hdr ? "[HDR]" : "Color";

            GUILayout.BeginHorizontal();
            GUILayout.Label(name, SWEditorUI.Style_Get(SWCustomStyle.eTxtSmallLight), GUILayout.Width(labelWith));
            SWCommon.HRDColor_Switch(window, ref data.effectDataColor.hdr);
            SWCommon.HRDColor_Field(_data.color, false, _data.hdr, nodeWidth - 15 - labelWith, delegate(Color c) {
                _data.color = c;
                SWProperties.SetColor(data, _data.color);
            }
                                    );
            GUILayout.EndHorizontal();


            DrawNodeWindowEnd();
        }
Exemple #3
0
        protected void UI_Color(string name, ref Color v, ref bool hdr, System.Action <SWBaseInfo, bool> act = null, bool before = false, bool isRightUp = false)
        {
            if (isRightUp)
            {
                GUILayout.BeginHorizontal();
            }
            Color temp;


            if (hdr)
            {
                name += " [HDR]";
            }
            GUILayout.Label(name, SWEditorUI.Style_Get(SWCustomStyle.eTxtSmallLight), GUILayout.Width(SWGlobalSettings.LabelWidthLong));
            SWCommon.HRDColor_Switch(this, ref hdr);
            var vvv = v;

            SWCommon.HRDColor_Field(v, true, hdr, SWGlobalSettings.FieldWidth, delegate(Color c) {
                if (before)
                {
                    if (act != null)
                    {
                        act(info, true);
                    }
                }
                vvv = c;
                if (!before)
                {
                    if (act != null)
                    {
                        act(info, true);
                    }
                }
                SWProperties.SetColor(data, vvv);
            }
                                    );
            v = vvv;
            if (isRightUp)
            {
                GUILayout.EndHorizontal();
            }
        }
        void DrawSub()
        {
            if (dataCode != null)
            {
                GUILayout.Space(gap + 2);
                GUILayout.BeginHorizontal();
                GUILayout.Space(gap);
                GUILayout.Label(dataCode.name, SWEditorUI.Style_Get(SWCustomStyle.eCodeLeft));
                GUILayout.EndHorizontal();

                paramCount = 0;

                for (int i = 0; i < dataCode.inputs.Count; i++)
                {
                    var item = dataCode.inputs [i];
                    if (!item.IsParam())
                    {
                        continue;
                    }

                    var itemUse = data.GetCodeParamUse(item.name);
                    GUILayout.BeginHorizontal();
                    paramCount++;
                    if (item.type == CodeParamType.Float)
                    {
                        GUILayout.Label(item.name, SWEditorUI.Style_Get(SWCustomStyle.eTxtSmallLight), GUILayout.Width(SWGlobalSettings.LabelWidth));
                        var f = EditorGUILayout.FloatField(itemUse.fv);
                        if (f != itemUse.fv)
                        {
                            itemUse.fv = f;
                            SWProperties.SetParam(data, itemUse);
                        }
                    }
                    if (item.type == CodeParamType.Range)
                    {
                        GUILayout.Label(item.name, SWEditorUI.Style_Get(SWCustomStyle.eTxtSmallLight), GUILayout.Width(SWGlobalSettings.LabelWidth));
                        var f = EditorGUILayout.Slider(itemUse.fv, item.min, item.max);
                        if (f != itemUse.fv)
                        {
                            itemUse.fv = f;
                            SWProperties.SetParam(data, itemUse);
                        }
                    }
                    if (item.type == CodeParamType.CustomParam)
                    {
                        GUILayout.Label(item.name, SWEditorUI.Style_Get(SWCustomStyle.eTxtSmallLight), GUILayout.Width(SWGlobalSettings.LabelWidth));
                        itemUse.v = EditorGUILayout.TextField(itemUse.v);
                    }
                    GUILayout.EndHorizontal();
                }

                float width = 40;
                for (int i = 0; i < rectLefts.Count; i++)
                {
                    Rect rt = rectLefts [i];
                    rt = new Rect(5, rt.y - data.rect.y, width, rt.height);
                    GUI.Label(rt, dataCode.RealInputs() [i].name, SWEditorUI.Style_Get(SWCustomStyle.eCodeLeft));
                }

                for (int i = 0; i < rectRights.Count; i++)
                {
                    Rect rt = rectRights [i];
                    rt = new Rect(data.rect.width - width - 5, rt.y - data.rect.y, width, rt.height);
                    GUI.Label(rt, dataCode.output.name, SWEditorUI.Style_Get(SWCustomStyle.eCodeRight));
                }
            }
        }
        protected void Factor_CustomParamCreation()
        {
            paramNameLastDeleted = "";
            DrawModuleTitle("Custom Parameters");
            Rect lastRect = GUILayoutUtility.GetLastRect();
            Rect rect     = new Rect(lastRect.x, lastRect.y, lastRect.width + SWGlobalSettings.FieldWidth, lastRect.height + rightUpUnitHeight);

            Tooltip_Rec(SWTipsText.Right_CustomParam, rect);

            paramName = EditorGUILayout.TextField(paramName, GUILayout.Width(100));


            GUILayout.BeginHorizontal();
            if (GUILayout.Button("New Float", GUILayout.Width(80)))
            {
                paramName = SWRegex.NameLegal(paramName);
                if (ParamNameUnique(paramName))
                {
                    SWParam pa = new SWParam();
                    pa.type = SWParamType.FLOAT;
                    pa.name = paramName;
                    SWWindowMain.Instance.data.paramList.Add(pa);
                }
                paramName = "";
            }
            if (GUILayout.Button("New Range", GUILayout.Width(80)))
            {
                paramName = SWRegex.NameLegal(paramName);
                if (ParamNameUnique(paramName))
                {
                    SWParam pa = new SWParam();
                    pa.type = SWParamType.RANGE;
                    pa.name = paramName;
                    SWWindowMain.Instance.data.paramList.Add(pa);
                }
                paramName = "";
            }
            GUILayout.EndHorizontal();


            int toDeleteId = -1;

            for (int i = 0; i < SWWindowMain.Instance.data.paramList.Count; i++)
            {
                //GUILayout.Space (SWGlobalSettings.UIGap);
                var item = SWWindowMain.Instance.data.paramList[i];
                GUILayout.BeginHorizontal();
                float nameWidth = 64f;
                GUILayout.Label(item.name, SWEditorUI.Style_Get(SWCustomStyle.eTxtSmallLight), GUILayout.Width(nameWidth));
                if (item.type == SWParamType.RANGE)
                {
                    var f = EditorGUILayout.FloatField(item.defaultValue, GUILayout.Width(30));
                    if (f != item.defaultValue)
                    {
                        item.defaultValue = f;
                        SWProperties.SetFloat(item.name, item.defaultValue);
                    }

                    f = GUILayout.HorizontalSlider(item.defaultValue, item.min, item.max, GUILayout.Width(40));
                    if (f != item.defaultValue)
                    {
                        item.defaultValue = f;
                        SWProperties.SetFloat(item.name, item.defaultValue);
                    }


                    GUILayout.Label("Min", SWEditorUI.Style_Get(SWCustomStyle.eTxtSmallLight), GUILayout.Width(22));
                    item.min = EditorGUILayout.FloatField("", item.min, GUILayout.Width(25));
                    GUILayout.Label("Max", SWEditorUI.Style_Get(SWCustomStyle.eTxtSmallLight), GUILayout.Width(26));
                    item.max = EditorGUILayout.FloatField("", item.max, GUILayout.Width(25));
                }
                if (item.type == SWParamType.FLOAT)
                {
                    var f = EditorGUILayout.FloatField(item.defaultValue, GUILayout.Width(rightupWidth - nameWidth - SWGlobalSettings.UIGap * 2 - 18 - 2));
                    if (f != item.defaultValue)
                    {
                        item.defaultValue = f;
                        SWProperties.SetFloat(item.name, item.defaultValue);
                    }
                }

                lastRect = GUILayoutUtility.GetLastRect();

                if (GUI.Button(new Rect(position.width - 33 - SWGlobalSettings.UIGap, lastRect.y, 18, 17), "X"))
                {
                    toDeleteId = i;
                }
                GUILayout.EndHorizontal();
            }
            if (toDeleteId >= 0)
            {
                paramNameLastDeleted = SWWindowMain.Instance.data.paramList[toDeleteId].name;
                SWWindowMain.Instance.data.paramList.RemoveAt(toDeleteId);
            }
        }