示例#1
0
        public static void OnSurfaceFlagButtons(SelectedBrushSurface[] selectedBrushSurfaces, bool isSceneGUI = false)
        {
            var leftStyle   = isSceneGUI ? EditorStyles.miniButtonLeft  : GUI.skin.button;
            var middleStyle = isSceneGUI ? EditorStyles.miniButtonMid   : GUI.skin.button;
            var rightStyle  = isSceneGUI ? EditorStyles.miniButtonRight : GUI.skin.button;

            var canDiscard        = false;
            var canMakeShadowOnly = false;
            var canMakeVisible    = false;

            if (selectedBrushSurfaces.Length > 0)
            {
                for (var i = 0; i < selectedBrushSurfaces.Length; i++)
                {
                    var brush        = selectedBrushSurfaces[i].brush;
                    var surfaceIndex = selectedBrushSurfaces[i].surfaceIndex;
                    if (surfaceIndex >= brush.Shape.Surfaces.Length)
                    {
                        Debug.Log("surface_index >= brush.Shape.Surfaces.Length");
                        continue;
                    }
                    var texGenIndex = brush.Shape.Surfaces[surfaceIndex].TexGenIndex;
                    if (texGenIndex >= brush.Shape.TexGens.Length)
                    {
                        Debug.Log("texGen_index >= brush.Shape.TexGens.Length");
                        continue;
                    }

                    var texGenFlags = brush.Shape.TexGenFlags[texGenIndex];
                    if ((texGenFlags & TexGenFlags.Discarded) == TexGenFlags.Discarded)
                    {
                        canMakeVisible    = true;
                        canMakeShadowOnly = true;
                    }
                    else
                    if ((texGenFlags & TexGenFlags.ShadowOnly) == TexGenFlags.ShadowOnly)
                    {
                        canDiscard     = true;
                        canMakeVisible = true;
                    }
                    else
                    {
                        canDiscard        = true;
                        canMakeShadowOnly = true;
                    }
                }
            }


            GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
            {
                EditorGUI.BeginDisabledGroup(!canDiscard);
                {
                    if (GUILayout.Button(ContentDiscardSurfaces, leftStyle))
                    {
                        SurfaceUtility.DiscardSurfaces(selectedBrushSurfaces);
                    }
                    TooltipUtility.SetToolTip(ToolTipDiscardSurfaces);
                }
                EditorGUI.EndDisabledGroup();
                EditorGUI.BeginDisabledGroup(!canMakeShadowOnly);
                {
                    if (GUILayout.Button(ContentShadowOnlySurfaces, middleStyle))
                    {
                        SurfaceUtility.MakeSurfacesShadowOnly(selectedBrushSurfaces);
                    }
                    TooltipUtility.SetToolTip(ToolTipShadowOnlySurfaces);
                }
                EditorGUI.EndDisabledGroup();
                EditorGUI.BeginDisabledGroup(!canMakeVisible);
                {
                    if (GUILayout.Button(ContentVisibleSurfaces, rightStyle))
                    {
                        SurfaceUtility.MakeSurfacesVisible(selectedBrushSurfaces);
                    }
                    TooltipUtility.SetToolTip(ToolTipVisibleSurfaces);
                }
                EditorGUI.EndDisabledGroup();
            }
            GUILayout.EndHorizontal();
        }