コード例 #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;
        }
    }
コード例 #2
0
    void MultiInfoPanel(VPaintObjectInfo[] grp)
    {
        VPaintGUIUtility.DrawColumnRow(24, () => {
            GUILayout.Label("Colors:");
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Clear Selected Layer"))
            {
                VPaint.Instance.PushUndo("Clear Colors");
                foreach (var info in grp)
                {
                    if (currentLayer != null)
                    {
                        currentLayer.Remove(info.vpaintObject);
                    }
                }
                VPaint.Instance.BuildObjectInfo();
            }
            if (GUILayout.Button("Clear All Layers"))
            {
                VPaint.Instance.PushUndo("Clear Colors");
                foreach (var info in grp)
                {
                    foreach (var layer in VPaint.Instance.layerStack.layers)
                    {
                        layer.Remove(info.vpaintObject);
                    }
                }
                VPaint.Instance.BuildObjectInfo();
            }
        });

        if (grp.Length != 1)
        {
            bool meshesValid  = true;
            bool allInstanced = true;
            foreach (var info in grp)
            {
                meshesValid &= info.vpaintObject.originalMesh;
                if (!meshesValid)
                {
                    allInstanced = false;
                    break;
                }
                allInstanced &= !EditorUtility.IsPersistent(info.vpaintObject.originalMesh);
            }
            VPaintGUIUtility.DrawColumnRow(24, () => {
                GUILayout.Label("Instancing:");
                GUILayout.FlexibleSpace();
                GUI.enabled = meshesValid && !allInstanced;
                if (GUILayout.Button("Break Instances"))
                {
                    foreach (var info in grp)
                    {
                        VPaint.Instance.BreakInstance(info.vpaintObject);
                    }
                }
                GUI.enabled = true;
            });
        }
    }
コード例 #3
0
    public override void OnSettingsGUI()
    {
        GUIStyle style = new GUIStyle(GUI.skin.label);

        style.wordWrap = true;

        VPaintGUIUtility.DrawColumnRow(24, () => {
            GUILayout.Label("Texture Settings", style);
        });

        VPaintGUIUtility.DrawColumnRow(24, () => {
            texture = EditorGUILayout.ObjectField("Texture", texture, typeof(Texture2D), false) as Texture2D;

            EditorGUILayout.BeginVertical();
            tile   = EditorGUILayout.Vector2Field("Tile", tile);
            offset = EditorGUILayout.Vector2Field("Offset", offset);
            GUILayout.Space(10);
            EditorGUILayout.EndVertical();
        });

        VPaintGUIUtility.DrawColumnRow(24, () => {
            uvType = (UVType)EditorGUILayout.EnumPopup("UV Channel", uvType);
        });

        GUILayout.Space(10);
    }
コード例 #4
0
 void ErrorTitle(string title)
 {
     VPaintGUIUtility.DrawColumnRow(24, () => {
         GUIStyle style         = new GUIStyle(GUI.skin.label);
         style.normal.textColor = Color.red;
         GUILayout.Label(title, style);
     });
 }
コード例 #5
0
 void SingleInfoPanel(VPaintObjectInfo info)
 {
     VPaintGUIUtility.DrawColumnRow(24, () => {
         GUILayout.Label("Mesh Reference:");
         GUILayout.FlexibleSpace();
         if (!info.vpaintObject.originalMesh)
         {
             GUILayout.Label("MISSING");
         }
         else
         {
             bool isPersistent = EditorUtility.IsPersistent(info.vpaintObject.originalMesh);
             if (isPersistent)
             {
                 GUILayout.Label("Instanced");
                 if (GUILayout.Button("Break Instance"))
                 {
                     VPaint.Instance.BreakInstance(info.vpaintObject);
                 }
             }
             else
             {
                 GUILayout.Label("Unique");
                 GUI.enabled = false;
                 GUILayout.Button("Break Instance");
                 GUI.enabled = true;
             }
         }
     });
     VPaintGUIUtility.DrawColumnRow(24, () => {
         GUILayout.Label("Mesh Vertices:");
         GUILayout.FlexibleSpace();
         if (info.errors.Contains(VPaintObjectError.MissingMesh))
         {
             GUILayout.Label("MISSING");
         }
         else
         {
             GUILayout.Label(info.vpaintObject.GetMeshInstance().vertices.Length.ToString());
         }
     });
     VPaintGUIUtility.DrawColumnRow(24, () => {
         GUILayout.Label("Cached Vertices:");
         GUILayout.FlexibleSpace();
         if (info.vertexCache == null)
         {
             GUILayout.Label("None");
         }
         else
         {
             GUILayout.Label(info.vertexCache.vertices.Length.ToString());
         }
     });
 }
コード例 #6
0
    public override void OnSettingsGUI()
    {
        GUIStyle style = new GUIStyle(GUI.skin.label);

        style.wordWrap = true;

        VPaintGUIUtility.DrawColumnRow(24, () => {
            GUILayout.Label("The light intensity to import the lightmap at. Default is 8.", style);
        });
        VPaintGUIUtility.DrawColumnRow(24, () => {
            lightmapIntensity = EditorGUILayout.IntField("Import Intensity:", lightmapIntensity);
        });
    }
コード例 #7
0
 void DirectionalSettings()
 {
     VPaintGUIUtility.DrawColumnRow(24, () => {
         Settings.direction = EditorGUILayout.Vector3Field("Direction", Settings.direction);
     });
     VPaintGUIUtility.DrawColumnRow(24, () => {
         Settings.offset = EditorGUILayout.Vector3Field("Offset", Settings.offset);
     });
     VPaintGUIUtility.DrawColumnRow(24, () => {
         Settings.directionalPower = EditorGUILayout.FloatField("Falloff", Settings.directionalPower);
     });
     VPaintGUIUtility.DrawColumnRow(24, () => {
         Settings.directionalDistance = EditorGUILayout.FloatField("Distance", Settings.directionalDistance);
     });
 }
コード例 #8
0
    void MissingMeshFilterPanel(VPaintObjectInfo[] grp)
    {
        ErrorTitle("MISSING MESH FILTER");

        VPaintGUIUtility.DrawColumnRow(24, () => {
            GUILayout.Label("Objects are missing a mesh filter.");
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Fix"))
            {
                foreach (var obj in grp)
                {
                    obj.vpaintObject.gameObject.AddComponent <MeshFilter>();
                }
                VPaint.Instance.BuildObjectInfo();
            }
        });
    }
コード例 #9
0
    void MissingMeshPanel(VPaintObjectInfo[] grp)
    {
        ErrorTitle("MISSING MESH");

        VPaintGUIUtility.DrawColumnRow(24, () => {
            fixMesh     = EditorGUILayout.ObjectField("Assign Mesh:", fixMesh, typeof(Mesh), false) as Mesh;
            GUI.enabled = fixMesh;
            if (GUILayout.Button("Fix", GUILayout.Width(40)))
            {
                foreach (var obj in grp)
                {
                    obj.vpaintObject.originalMesh = fixMesh;
                    obj.vpaintObject.ResetInstances();
                }
                VPaint.Instance.BuildObjectInfo();
            }
        });
    }
コード例 #10
0
    void SettingsPanel()
    {
        VPaintGUIUtility.DrawColumnRow(24, () => {
            List <string> names = new List <string>();
            names.Add("Current Layer");                         //0
            names.Add("Merged Layer");                          //1

            copyLayer = EditorGUILayout.Popup("Copy Layer: ", copyLayer, names.ToArray());
        });

        VPaintGUIUtility.DrawColumnRow(24, () => {
            List <string> names = new List <string>();
            names.Add("Current Layer");                         //0
            names.Add("New Layer");                             //1

            pasteLayer = EditorGUILayout.Popup("Paste To Layer: ", pasteLayer, names.ToArray());
        });
    }
コード例 #11
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();
    }
コード例 #12
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;
    }
コード例 #13
0
    void OnSharedSettingsGUI()
    {
        GUIStyle style = new GUIStyle(GUI.skin.label);

        style.wordWrap = true;

        VPaintGUIUtility.DrawColumnRow(24, () => {
            GUILayout.Label("The transparency value to apply to the imported colors.", style);
        });
        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.importOpacity = EditorGUILayout.Slider("Import Transparency", Settings.importOpacity, 0f, 1f);
        });

        GUILayout.Space(10);

        VPaintGUIUtility.DrawColumnRow(24, () => {
            GUILayout.Label("Pixel radius to sample from for each vertex.", style);
        });
        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.sampleRadius = EditorGUILayout.IntField("Pixel Sample Radius:", Settings.sampleRadius);
        });

        GUILayout.Space(10);

        VPaintGUIUtility.DrawColumnRow(24, () => {
            GUILayout.Label("Post-process blur on the imported colors.", style);
        });
        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.blurRadius = EditorGUILayout.FloatField("Blur Radius", Settings.blurRadius);
        });
        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.blurThreshhold = EditorGUILayout.Slider("Blur Threshhold", Settings.blurThreshhold, 0f, 1f);
        });

        GUILayout.Space(10);

        VPaintGUIUtility.DrawColumnRow(24, () => {
            GUILayout.Label("Channel Assignments", style);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Reset"))
            {
                Settings.swizzleR = 0;
                Settings.swizzleG = 1;
                Settings.swizzleB = 2;
                Settings.swizzleA = 3;
            }

            GUILayout.Space(5);
        });

        Func <GUIContent, int, int> getSwizzle = (s, c) => {
            return(EditorGUILayout.Popup(s, c + 1,
                                         new GUIContent[] {
                new GUIContent("Disabled"),
                new GUIContent("Red"),
                new GUIContent("Green"),
                new GUIContent("Blue"),
                new GUIContent("Alpha")
            }
                                         ) - 1);
        };

        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.swizzleR = getSwizzle(new GUIContent("Red"), Settings.swizzleR);
        });
        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.swizzleG = getSwizzle(new GUIContent("Green"), Settings.swizzleG);
        });
        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.swizzleB = getSwizzle(new GUIContent("Blue"), Settings.swizzleB);
        });
        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.swizzleA = getSwizzle(new GUIContent("Alpha"), Settings.swizzleA);
        });

        GUILayout.Space(10);

        VPaintGUIUtility.DrawColumnRow(24, () => {
            Settings.targetLayer =
                EditorGUILayout.Popup("Target Layer", Settings.targetLayer,
                                      new string[] { "New Layer", "Selected Layer" });
        });
    }
コード例 #14
0
    void InvalidVertexCountPanel(VPaintObjectInfo[] grp)
    {
        ErrorTitle("INVALID VERTEX COUNT");

        bool hasVertexCache = true;

        foreach (var info in grp)
        {
            hasVertexCache &= info.vertexCache != null;
        }
        bool   validTransfer = true;
        string err           = "";

        VPaintGUIUtility.DrawColumnRow(24, () => {
            EditorGUILayout.BeginVertical();
            vertexTransferType = (VertexTransferType)EditorGUILayout.EnumPopup("Fix:", vertexTransferType);
            if (!hasVertexCache)
            {
                err           = "Some or all objects are missing vertex cache data. Cannot transfer color data.";
                validTransfer = false;
                return;
            }
            switch (vertexTransferType)
            {
            case VertexTransferType.NearestVert:
                break;

            case VertexTransferType.RadialSample:
                radialSampleRadius  = EditorGUILayout.FloatField("Sample Radius:", radialSampleRadius);
                radialSampleFalloff = EditorGUILayout.FloatField("Sample Falloff:", radialSampleFalloff);
                break;
            }
            if (validTransfer)
            {
                vertexTransferOffset = EditorGUILayout.Vector3Field("Offset:", vertexTransferOffset);
                vertexTransferRotate = EditorGUILayout.Vector3Field("Rotate:", vertexTransferRotate);
                vertexTransferScale  = EditorGUILayout.Vector3Field("Scale:", vertexTransferScale);
            }
            EditorGUILayout.EndVertical();
        });
        VPaintGUIUtility.DrawColumnRow(24, () => {
            GUI.enabled = validTransfer;

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label(err);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Transfer"))
            {
                VPaint.Instance.PushUndo("Transfer Old Colors");
                switch (vertexTransferType)
                {
                case VertexTransferType.NearestVert:
                    foreach (var info in grp)
                    {
                        NearestVertTransfer(info);
                    }
                    break;

                case VertexTransferType.RadialSample:
                    foreach (var info in grp)
                    {
                        RadialSampleTransfer(info, radialSampleRadius, radialSampleFalloff);
                    }
                    break;
                }
                VPaint.Instance.RefreshObjects();
                VPaint.Instance.ReloadLayers();
            }
            EditorGUILayout.EndHorizontal();

            GUI.enabled = true;
        });
    }
コード例 #15
0
 void RadialSettings()
 {
     VPaintGUIUtility.DrawColumnRow(24, () => {
         Settings.radius = EditorGUILayout.FloatField("Radius", Settings.radius);
     });
 }
コード例 #16
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;
        }
    }
コード例 #17
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();
    }
コード例 #18
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);
    }
コード例 #19
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();
    }
コード例 #20
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();
    }