public static void OnSurfaceFlagButtons(Rect rect, SurfaceFlagState state, SelectedBrushSurface[] selectedBrushSurfaces) { var leftStyle = EditorStyles.miniButtonLeft; var rightStyle = EditorStyles.miniButtonRight; var tempRect = rect; { tempRect.Set(rect.x + 4, rect.y + 1, 45, 16); GUI.Label(tempRect, ContentShadows, EditorStyles.miniLabel); EditorGUI.BeginChangeCheck(); { var mixed = !state.noReceiveShadows.HasValue; var enabled = !(state.noReceiveShadows ?? (state.noRender ?? true)); EditorGUI.showMixedValue = mixed; tempRect.Set(rect.x + 53, rect.y + 1, 90 - 4, 15); state.noReceiveShadows = !GUI.Toggle(tempRect, enabled, ContentReceiveShadowsSurfaces, leftStyle); TooltipUtility.SetToolTip(ToolTipReceiveShadowsSurfaces, tempRect); } if (EditorGUI.EndChangeCheck()) { SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoReceiveShadows, state.noReceiveShadows.Value); } EditorGUI.BeginChangeCheck(); { var mixed = !state.noCastShadows.HasValue; var enabled = !(state.noCastShadows ?? true); EditorGUI.showMixedValue = mixed; tempRect.Set(rect.x + 143 - 4, rect.y + 1, 74 - 4, 15); state.noCastShadows = !GUI.Toggle(tempRect, enabled, ContentCastShadowsSurfaces, rightStyle); TooltipUtility.SetToolTip(ToolTipCastShadowsSurfaces, tempRect); } if (EditorGUI.EndChangeCheck()) { SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoCastShadows, state.noCastShadows.Value); } } { EditorGUI.BeginChangeCheck(); { var mixed = !state.noRender.HasValue; var enabled = !(state.noRender ?? true); EditorGUI.showMixedValue = mixed; tempRect.Set(rect.x + 4, rect.y + 18, 94, 15); state.noRender = !GUI.Toggle(tempRect, enabled, ContentVisibleSurfaces, leftStyle); TooltipUtility.SetToolTip(ToolTipVisibleSurfaces, tempRect); } if (EditorGUI.EndChangeCheck()) { SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoRender, state.noRender.Value); } EditorGUI.BeginChangeCheck(); { var mixed = !state.noCollision.HasValue; var enabled = !(state.noCollision ?? true); EditorGUI.showMixedValue = mixed; tempRect.Set(rect.x + 98, rect.y + 18, 112, 15); state.noCollision = !GUI.Toggle(tempRect, enabled, ContentCollisionSurfaces, rightStyle); TooltipUtility.SetToolTip(ToolTipCollisionSurfaces, tempRect); } if (EditorGUI.EndChangeCheck()) { SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoCollision, state.noCollision.Value); } } EditorGUI.showMixedValue = false; }
public static void OnSurfaceFlagButtons(SurfaceFlagState state, 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; GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty); { if (!isSceneGUI) { GUILayout.Label(ContentShadows, EditModeSurfaceGUI.largeLabelWidth); } else { GUILayout.Label(ContentShadows, EditorStyles.miniLabel, EditModeSurfaceGUI.smallLabelWidth); } EditorGUI.BeginChangeCheck(); { // TODO: implement support EditorGUI.showMixedValue = !state.noReceiveShadows.HasValue; state.noReceiveShadows = !GUILayout.Toggle(!(state.noReceiveShadows ?? (state.noRender ?? true)), ContentReceiveShadowsSurfaces, leftStyle); TooltipUtility.SetToolTip(ToolTipReceiveShadowsSurfaces); } if (EditorGUI.EndChangeCheck()) { SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoReceiveShadows, state.noReceiveShadows.Value); } EditorGUI.BeginChangeCheck(); { // TODO: implement support EditorGUI.showMixedValue = !state.noCastShadows.HasValue; state.noCastShadows = !GUILayout.Toggle(!(state.noCastShadows ?? true), ContentCastShadowsSurfaces, rightStyle); TooltipUtility.SetToolTip(ToolTipCastShadowsSurfaces); } if (EditorGUI.EndChangeCheck()) { SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoCastShadows, state.noCastShadows.Value); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty); { EditorGUI.BeginChangeCheck(); { EditorGUI.showMixedValue = !state.noRender.HasValue; state.noRender = !GUILayout.Toggle(!(state.noRender ?? true), ContentVisibleSurfaces, leftStyle); TooltipUtility.SetToolTip(ToolTipVisibleSurfaces); } if (EditorGUI.EndChangeCheck()) { SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoRender, state.noRender.Value); } EditorGUI.BeginChangeCheck(); { EditorGUI.showMixedValue = !state.noCollision.HasValue; state.noCollision = !GUILayout.Toggle(!(state.noCollision ?? true), ContentCollisionSurfaces, rightStyle); TooltipUtility.SetToolTip(ToolTipCollisionSurfaces); } if (EditorGUI.EndChangeCheck()) { SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoCollision, state.noCollision.Value); } } GUILayout.EndHorizontal(); EditorGUI.showMixedValue = false; }