Ejemplo n.º 1
0
    void BlendSettingsGUI()
    {
        VPaintGUIUtility.BeginColumnView(position.width - 48);

        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.mode = (int)(Mode)EditorGUILayout.EnumPopup("Mode", (Mode)Settings.mode);
        });

        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.intensity = EditorGUILayout.Slider("Intensity", Settings.intensity, 0f, 1f);
        });

        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.layer = EditorGUILayout.Popup("Layer", Settings.layer, new string[] { "Select Layer", "All Layers" });
        });

        switch ((Mode)Settings.mode)
        {
        case Mode.Directional:
            DirectionalSettings();
            break;

        case Mode.Radial:
            RadialSettings();
            break;
        }
    }
Ejemplo n.º 2
0
    void BlendHierarchyGUI()
    {
        VPaintGUIUtility.BeginColumnView(position.width - 48);

        VPaintGUIUtility.DualSelectionGroup(
            "Blend To", blendObjects, ref blendObjectsScroll,
            "Blend From", blendTargets, ref blendTargetsScroll);
    }
    public override void OnValidatedGUI()
    {
        windowScroll = EditorGUILayout.BeginScrollView(windowScroll);

        VPaintGUIUtility.BeginColumnView(position.width - 48);

        OnSettingsGUI();

        GUILayout.Space(10);

        OnSharedSettingsGUI();

        GUILayout.FlexibleSpace();

        EditorGUILayout.EndScrollView();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        ImportButtons();
        EditorGUILayout.EndHorizontal();
    }
Ejemplo n.º 4
0
    public override void OnValidatedGUI()
    {
        VPaintGUIUtility.BeginColumnView(position.width - 48);

        GUIStyle style = new GUIStyle(GUI.skin.label);

        style.wordWrap = true;

        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

        bool doPreview = false;

        VPaintGUIUtility.DrawColumnRow(24, () => {
            GUILayout.Label("Targeted Layer: " + currentLayer.name);
        });

        EditorGUI.BeginChangeCheck();
        VertexEditorActionEditor.OnGUI(action, type);
        doPreview |= EditorGUI.EndChangeCheck();

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndScrollView();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        autoPreview = GUILayout.Toggle(autoPreview, "Auto");
        bool enabledCache = GUI.enabled;

        GUI.enabled = !autoPreview;
        if (GUILayout.Button("Preview") || (autoPreview && doPreview))
        {
            Preview();
        }
        GUI.enabled = enabledCache;
        if (GUILayout.Button("Apply"))
        {
            Apply();
        }
        EditorGUILayout.EndHorizontal();
    }
Ejemplo n.º 5
0
    void BlendAreaGUI()
    {
        VPaintGUIUtility.BeginColumnView(position.width - 48);
        VPaintGUIUtility.DrawColumnRow(24, (r) => {
            if (r.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                Settings.useBounds = !Settings.useBounds;
                Event.current.Use();
            }
            EditorGUILayout.Toggle(Settings.useBounds, GUILayout.Width(16));
            GUILayout.Label("Bounding Area:");
        });

        bool activeCache = GUI.enabled;

        GUI.enabled = Settings.useBounds;
        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.position = EditorGUILayout.Vector3Field("Position", Settings.position);
        });
        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.size = EditorGUILayout.Vector3Field("Size", Settings.size);
        });
        GUI.enabled = activeCache;
    }
Ejemplo n.º 6
0
    public override void OnValidatedGUI()
    {
        VPaintGUIUtility.BeginColumnView(position.width - 24);

        VPaintGUIUtility.DrawColumnRow(24, () => {
            GUILayout.Label("Import Ambient Occlusion");
        });

        VPaintGUIUtility.BeginColumnView(position.width - 48);

        mainScroll = EditorGUILayout.BeginScrollView(mainScroll);

        GUILayout.Space(20);

        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.samples = EditorGUILayout.IntField("Samples:", Settings.samples);
        });
        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.radius = EditorGUILayout.FloatField("Radius: ", Settings.radius);
        });
        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.intensity = EditorGUILayout.FloatField("Intensity:", Settings.intensity);
        });

        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.lightColor = EditorGUILayout.ColorField("Light Color:", Settings.lightColor);
        });

        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.darkColor = EditorGUILayout.ColorField("Dark Color:", Settings.darkColor);
        });

        GUILayout.FlexibleSpace();

        VPaintGUIUtility.SelectionGroup("Objects:", targetObjects, ref targetObjectsScroll);

        GUILayout.Space(20);

        EditorGUILayout.EndScrollView();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Preview"))
        {
            var layer = CalculateAmbientOcclusion(targetObjects.ToArray(), Settings.radius, Settings.intensity, Settings.samples, Settings.darkColor, Settings.lightColor);
            if (layer != null)
            {
                VPaint.Instance.LoadLayer(layer);
            }
        }
        if (GUILayout.Button("Import"))
        {
            var layer = CalculateAmbientOcclusion(targetObjects.ToArray(), Settings.radius, Settings.intensity, Settings.samples, Settings.darkColor, Settings.lightColor);
            if (layer != null)
            {
                VPaint.Instance.layerStack.layers.Add(layer);
                VPaint.Instance.ReloadLayers();
                VPaint.Instance.MarkDirty();
            }
        }
        EditorGUILayout.EndHorizontal();
    }
Ejemplo n.º 7
0
    public override void OnValidatedGUI()
    {
        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

        VPaintGUIUtility.BeginColumnView(position.width - 24);

        VPaintGUIUtility.DrawColumnRow(24, () =>
        {
            GUILayout.Label("VPaint Hotkey Editor");
        });

        var wordWrapStyle = new GUIStyle(GUI.skin.label);

        wordWrapStyle.wordWrap = true;
        VPaintGUIUtility.DrawColumnRow(24, () =>
        {
            GUILayout.Label("Use this window to modify hotkeys in VPaint. Although it cannot be guarenteed that every hotkey combination will work (the Unity Editor overrides many of them for its own purposes) this should help avoid conflicts with other tools.", wordWrapStyle);
        });
        VPaintGUIUtility.DrawColumnRow(24, () =>
        {
            EditorGUILayout.BeginVertical();
            GUILayout.Label("To disable a hotkey, simply clear the text. Hotkeys are parsed with Unity KeyCode - see the Unity documentation for all avialable options. Use the below notation to indicate modifier keys for your hotkey.", wordWrapStyle);
            EditorGUILayout.LabelField("\tShift:", "#");
            EditorGUILayout.LabelField("\tAlt:", "&");
            EditorGUILayout.LabelField("\tCommand:", "%");
            EditorGUILayout.EndVertical();
        });

        VPaintGUIUtility.DrawColumnRow(24, () =>
        {
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Reset All"))
            {
                foreach (var hotkey in VPaintHotkeys.Hotkeys)
                {
                    hotkey.Parse(hotkey.defaultValue);
                    EditorPrefs.DeleteKey(hotkey.editorPref);
                }
            }
        });

        foreach (var hotkey in VPaintHotkeys.Hotkeys)
        {
            VPaintGUIUtility.DrawColumnRow(24, () => {
                EditorGUILayout.BeginVertical();
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(hotkey.label);
                GUILayout.FlexibleSpace();
                if (hotkey.isValid)
                {
                    GUILayout.Label(hotkey.GetLabel());
                }
                else
                {
                    GUILayout.Label("[INVALID]");
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                string newHotkey = EditorGUILayout.TextField("", hotkey.value);
                if (newHotkey != hotkey.value)
                {
                    hotkey.Parse(newHotkey);
                    EditorPrefs.SetString(hotkey.editorPref, newHotkey);
                }
                GUI.enabled = newHotkey != hotkey.defaultValue;
                if (GUILayout.Button("Reset To Default", GUILayout.Width(140)))
                {
                    hotkey.Parse(hotkey.defaultValue);
                    EditorPrefs.DeleteKey(hotkey.editorPref);
                }
                GUI.enabled = true;
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
            });
        }

        EditorGUILayout.EndScrollView();
    }
Ejemplo n.º 8
0
    public override void OnValidatedGUI()
    {
        float width = position.width - 24;

        VPaintGUIUtility.BeginColumnView(width);

        VPaintGUIUtility.DrawColumnRow(24, () => {
            GUILayout.FlexibleSpace();
            GUILayout.Label("VPaint Clipboard");
            GUILayout.FlexibleSpace();
        });

        SettingsPanel();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(8);

        EditorGUILayout.BeginVertical(GUILayout.Width(width * 0.4f));

        Rect upperLeft = EditorGUILayout.BeginVertical();

        GUI.Box(upperLeft, GUIContent.none);

        UpperLeftPanel();

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndVertical();


        Rect lowerLeft = EditorGUILayout.BeginVertical();

        GUI.Box(lowerLeft, GUIContent.none);

        EditorGUILayout.BeginHorizontal(GUILayout.Height(72));
        EditorGUILayout.BeginVertical();
        LowerLeftPanel();
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.EndVertical();

        EditorGUILayout.EndVertical();



        EditorGUILayout.BeginVertical(GUILayout.Width(width * 0.2f));
        GUILayout.FlexibleSpace();

        CenterPanel();

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndVertical();



        EditorGUILayout.BeginVertical(GUILayout.Width(width * 0.4f));

        Rect upperRight = EditorGUILayout.BeginVertical();

        GUI.Box(upperRight, GUIContent.none);

        UpperRightPanel();

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndVertical();


        Rect lowerRight = EditorGUILayout.BeginVertical();

        GUI.Box(lowerRight, GUIContent.none);

        EditorGUILayout.BeginHorizontal(GUILayout.Height(72));
        EditorGUILayout.BeginVertical();
        LowerRightPanel();
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.EndVertical();

        EditorGUILayout.EndVertical();



        EditorGUILayout.EndHorizontal();

        GUILayout.Space(5);
    }
Ejemplo n.º 9
0
    public override void OnValidatedGUI()
    {
        base.OnValidatedGUI();

        selectionChanged = false;

        Rect r;

        float totalWidth = position.width - 20;
        float width;

        VPaintGUIUtility.BeginColumnView(totalWidth);
        VPaintGUIUtility.DrawColumnRow(24, () => {
            GUILayout.Label("VPaint Group Maintenance");
        });

        VPaintGUIUtility.DrawColumnRow(24, () => {
            if (GUILayout.Button("Add Objects"))
            {
                var menu = new GenericMenu();

                menu.AddItem(new GUIContent("Add Selected"), false, () => {
                    VPaint.Instance.PushUndo("Add Selected");
                    foreach (var go in Selection.gameObjects)
                    {
                        var vp = go.GetComponent <VPaintObject>();
                        if (!vp)
                        {
                            if (go.GetComponent <MeshFilter>() && go.GetComponent <MeshRenderer>())
                            {
                                vp = go.AddComponent <VPaintObject>();
                            }
                        }
                        if (vp)
                        {
                            VPaint.Instance.layerCache.AddColorer(vp);
                        }
                    }
                    VPaint.Instance.RefreshObjects();
                    selection.Clear();
                    selectionChanged = true;
                });
                menu.AddItem(new GUIContent("Add Selected + Children"), false, () => {
                    VPaint.Instance.PushUndo("Add Selected + Children");
                    foreach (var go in Selection.gameObjects)
                    {
                        var all = go.GetComponentsInChildren <Transform>();
                        foreach (var tr in all)
                        {
                            var vp = tr.GetComponent <VPaintObject>();
                            if (!vp)
                            {
                                if (tr.GetComponent <MeshFilter>() && tr.GetComponent <MeshRenderer>())
                                {
                                    vp = tr.gameObject.AddComponent <VPaintObject>();
                                }
                            }
                            if (vp)
                            {
                                VPaint.Instance.layerCache.AddColorer(vp);
                            }
                        }
                    }
                    VPaint.Instance.RefreshObjects();
                    selection.Clear();
                    selectionChanged = true;
                });

                menu.ShowAsContext();
            }
            if (GUILayout.Button("Remove Objects"))
            {
                var menu = new GenericMenu();

                menu.AddItem(new GUIContent("Remove Selected"), false, () => {
                    VPaint.Instance.PushUndo("Remove Selected");
                    foreach (var go in Selection.gameObjects)
                    {
                        VPaint.Instance.layerCache.RemoveColorer(go.GetComponent <VPaintObject>());
                    }
                    VPaint.Instance.RefreshObjects();
                    selection.Clear();
                    selectionChanged = true;
                });
                menu.AddItem(new GUIContent("Remove Selected + Children"), false, () => {
                    VPaint.Instance.PushUndo("Remove Selected + Children");
                    foreach (var go in Selection.gameObjects)
                    {
                        foreach (var vc in go.GetComponentsInChildren <VPaintObject>())
                        {
                            VPaint.Instance.layerCache.RemoveColorer(vc);
                        }
                    }
                    VPaint.Instance.RefreshObjects();
                    selection.Clear();
                    selectionChanged = true;
                });

                menu.ShowAsContext();
            }
        });

        VPaintGUIUtility.DrawColumnRow(24,
                                       () => {
            GUILayout.Label("Filter:");
        }, () => {
            GUILayout.Label("Errors:");
            GUILayout.FlexibleSpace();
            showOnlyErrors = GUILayout.Toggle(showOnlyErrors, GUIContent.none);
        }, () => {}, () => {});

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        width = totalWidth * 0.4f;
        r     = EditorGUILayout.BeginVertical(GUILayout.Width(width));
        GUI.Box(r, GUIContent.none);

        LeftPanel(width);

        EditorGUILayout.EndVertical();

        GUILayout.Space(2);

        width = totalWidth * 0.6f;
        r     = EditorGUILayout.BeginVertical(GUILayout.Width(width));
        GUI.Box(r, GUIContent.none);

        RightPanel(width);

        EditorGUILayout.EndVertical();

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        GUILayout.Space(10);

        if (Event.current.type == EventType.keyDown && Event.current.control && Event.current.keyCode == KeyCode.A)
        {
            selectionChanged = true;
            selection.Clear();
            for (int i = 0; i < VPaint.Instance.objectInfo.Length; i++)
            {
                selection.Add(i);
            }
            Event.current.Use();
        }

        if (selectionChanged)
        {
            var selectionInfo = new GameObject[selection.Count];
            for (int i = 0; i < selectionInfo.Length; i++)
            {
                var si = VPaint.Instance.objectInfo[selection[i]];
                if (!si.vpaintObject)
                {
                    continue;
                }
                selectionInfo[i] = si.vpaintObject.gameObject;
            }
            Selection.objects = selectionInfo;
        }
    }
Ejemplo n.º 10
0
    public void RightPanel(float width)
    {
        rightPanelScroll = EditorGUILayout.BeginScrollView(rightPanelScroll);

        GUILayout.Space(5);

        if (selection.Count == 0)
        {
            GUILayout.Label(" ");
        }
        else
        {
            EditorGUILayout.BeginHorizontal();

            string title = "";

            VPaintObjectInfo[] selectionInfo = new VPaintObjectInfo[selection.Count];
            Dictionary <VPaintObjectError, List <VPaintObjectInfo> > errors = new Dictionary <VPaintObjectError, List <VPaintObjectInfo> >();

            for (int i = 0; i < selection.Count; i++)
            {
                var index = selection[i];
                var info  = VPaint.Instance.objectInfo[index];
                selectionInfo[i] = info;

                foreach (var err in info.errors)
                {
                    if (!errors.ContainsKey(err))
                    {
                        errors.Add(err, new List <VPaintObjectInfo>());
                    }
                    errors[err].Add(info);
                }

                if (i == 0)
                {
                    title = info.Name;
                }
                else
                {
                    title += ", " + info.Name;
                }
            }

            GUIStyle style = new GUIStyle(GUI.skin.label);
            style.fontSize = 20;

            var titleSize = style.CalcSize(new GUIContent(title));
            if (width - 42 < titleSize.x)
            {
                title = title.Substring(0, (int)(title.Length * ((width - 42) / titleSize.x))) + "...";
            }

            GUILayout.Label(title, style);

            EditorGUILayout.EndHorizontal();

            VPaintGUIUtility.BeginColumnView(width - 24);

            GUILayout.Space(10);

            if (selection.Count != 0)
            {
                MultiInfoPanel(selectionInfo);
            }

            GUILayout.Space(10);

            if (selection.Count == 1)
            {
                SingleInfoPanel(selectionInfo[0]);
            }

            GUILayout.Space(10);

            if (errors.Count != 0)
            {
                GUILayout.Label("The selected objects contain the following errors:");
                GUILayout.Space(10);
                foreach (var kvp in errors)
                {
                    var panel = GetErrorPanel(kvp.Key);
                    if (panel != null)
                    {
                        panel(kvp.Value.ToArray());
                    }
                    GUILayout.Space(10);
                }
            }
        }

        EditorGUILayout.EndScrollView();
    }
Ejemplo n.º 11
0
    public override void OnValidatedGUI()
    {
        GUI.enabled = Selection.gameObjects.Length != 0;
        VPaintGUIUtility.BeginColumnView(position.width - 24);
        VPaintGUIUtility.DrawColumnRow(24,
                                       () => {
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Mask Selected"))
            {
                for (int i = 0; i < currentEditingContentsMask.Length; i++)
                {
                    var vc = VPaint.Instance.currentEditingContents[i];
                    currentEditingContentsMask[i] = Selection.gameObjects.Contains(vc.gameObject);
                }
            }
            if (GUILayout.Button("Mask Selected + Children"))
            {
                var vcs = new List <VPaintObject>();
                foreach (var go in Selection.gameObjects)
                {
                    vcs.AddRange(go.GetComponentsInChildren <VPaintObject>());
                }
                for (int i = 0; i < currentEditingContentsMask.Length; i++)
                {
                    currentEditingContentsMask[i] = vcs.Contains(VPaint.Instance.currentEditingContents[i]);
                }
            }
            GUILayout.FlexibleSpace();
        });
        VPaintGUIUtility.DrawColumnRow(24,
                                       () => {
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Invert Selection"))
            {
                for (int i = 0; i < currentEditingContentsMask.Length; i++)
                {
                    currentEditingContentsMask[i] = !currentEditingContentsMask[i];
                }
            }
            if (GUILayout.Button("Mask None"))
            {
                for (int i = 0; i < currentEditingContentsMask.Length; i++)
                {
                    currentEditingContentsMask[i] = false;
                }
            }
            if (GUILayout.Button("Mask All"))
            {
                for (int i = 0; i < currentEditingContentsMask.Length; i++)
                {
                    currentEditingContentsMask[i] = true;
                }
            }
            GUILayout.FlexibleSpace();
        });
        GUI.enabled = true;

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        EditorGUILayout.BeginVertical(GUILayout.Width(position.width - 24));

        VPaintGUIUtility.BeginColumnView(position.width - 32);

        bool allMasked = true;

        foreach (var b in currentEditingContentsMask)
        {
            allMasked &= b;
        }
        VPaintGUIUtility.DrawColumnRow(24, () => {
            bool masked = EditorGUILayout.Toggle(allMasked, GUILayout.Width(16));
            if (masked != allMasked)
            {
                SetAll(masked);
            }
            GUILayout.Label("Objects:");
        });

        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

        VPaintGUIUtility.columnViewBoxCount = 0;

        for (int i = 0; i < VPaint.Instance.currentEditingContents.Length; i++)
        {
            var obj = VPaint.Instance.currentEditingContents[i];

            Rect r = EditorGUILayout.BeginHorizontal();

            currentEditingContentsMask[i] = EditorGUILayout.Toggle(currentEditingContentsMask[i], GUILayout.Width(16));

            EditorGUIUtility.AddCursorRect(r, MouseCursor.Link);
            if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && r.Contains(Event.current.mousePosition))
            {
                EditorGUIUtility.PingObject(obj.transform);
                Event.current.Use();
            }

            GUILayout.Label(obj.name);
            EditorGUILayout.EndHorizontal();
        }

        VPaintGUIUtility.columnViewBoxCount = 1;

        EditorGUILayout.EndScrollView();

        EditorGUILayout.EndVertical();
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
    }