private void MaskSettings(Rect Area, DynamicDecalSettings Settings)
        {
            GUI.BeginGroup(Area);

            //Header
            EditorGUI.DrawRect(new Rect(0, 0, Area.width, 24), LlockhamEditorUtility.HeaderColor);
            EditorGUI.LabelField(new Rect(8, 4, Area.width - 32, 16), "Masking", EditorStyles.boldLabel);

            //Reset
            Rect Reset = new Rect(Area.width - 20, 6, 12, 12);

            if (Event.current.type == EventType.mouseDown && Event.current.button == 0 && Reset.Contains(Event.current.mousePosition))
            {
                Undo.RecordObject(Settings, "Reset Masking");
                Settings.ResetMasking();
                Event.current.Use();
            }
            GUI.DrawTexture(Reset, LlockhamEditorUtility.Reset);

            //Draw Background
            EditorGUI.DrawRect(new Rect(0, 24, Area.width, Area.height - 24), LlockhamEditorUtility.MidgroundColor);

            //Begin Layout Area
            GUILayout.BeginArea(new Rect(4, 32, Area.width - 20, Area.height - 32));

            //Generate layer options
            for (int i = 0; i < Settings.Layers.Length; i++)
            {
                EditorGUI.BeginChangeCheck();

                EditorGUILayout.BeginHorizontal();
                string layerName = EditorGUILayout.TextField(new GUIContent(""), Settings.Layers[i].name, GUILayout.Width(Area.width - 200));
                GUILayout.FlexibleSpace();
                LayerMask layerMask = EditorGUILayout.MaskField(new GUIContent(""), InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Settings.Layers[i].layers), InternalEditorUtility.layers, GUILayout.Width(160));
                EditorGUILayout.EndHorizontal();

                if (EditorGUI.EndChangeCheck())
                {
                    //Record state for undo
                    Undo.RecordObject(Settings, "Layer name");

                    //Change layer name
                    Settings.Layers[i].name   = layerName;
                    Settings.Layers[i].layers = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(layerMask);

                    //Recalculate passes
                    Settings.CalculatePasses();
                }
            }
            EditorGUILayout.Space();

            GUILayout.EndArea();
            GUI.EndGroup();
        }
Exemple #2
0
        private void UndoRedo()
        {
            //Grab our settings
            DynamicDecalSettings settings = DynamicDecals.System.Settings;

            //Recalculate passes
            settings.CalculatePasses();

            //Update renderers
            DynamicDecals.System.UpdateRenderers();

            //Repaint the window to show changes immediately
            Repaint();
        }
        private void LayerMasking(Rect Area, DynamicDecalSettings Settings)
        {
            if (Settings.UseMaskLayers)
            {
                //Begin Layout area
                GUILayout.BeginArea(Area);

                //Header
                if (Settings.maskMethod == DecalMaskMethod.Both)
                {
                    EditorGUILayout.LabelField(layers, EditorStyles.boldLabel);
                }

                //Generate layer options
                for (int i = 0; i < Settings.Layers.Length; i++)
                {
                    EditorGUI.BeginChangeCheck();

                    EditorGUILayout.BeginHorizontal();
                    string layerName = EditorGUILayout.TextField(new GUIContent(""), Settings.Layers[i].name, GUILayout.Width(Area.width - 180));
                    GUILayout.FlexibleSpace();
                    LayerMask layerMask = EditorGUILayout.MaskField(new GUIContent(""), InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Settings.Layers[i].layers), InternalEditorUtility.layers, GUILayout.Width(160));
                    EditorGUILayout.EndHorizontal();

                    if (EditorGUI.EndChangeCheck())
                    {
                        //Record state for undo
                        Undo.RecordObject(Settings, "Layer name");

                        //Change layer name
                        Settings.Layers[i].name   = layerName;
                        Settings.Layers[i].layers = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(layerMask);

                        //Recalculate passes
                        Settings.CalculatePasses();
                    }
                }
                GUILayout.EndArea();
            }
        }