示例#1
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();
    }