void RenderProbeFieldsGUI() { bool isDeferredRenderingPath = ChiselEditorUtility.IsUsingDeferredRenderingPath(); bool isDeferredReflections = isDeferredRenderingPath && ChiselEditorUtility.IsDeferredReflections(); bool areLightProbesAllowed = AreLightProbesAllowed(); RenderLightProbeUsage(areLightProbesAllowed); RenderLightProbeProxyVolumeWarningNote(); RenderReflectionProbeUsage(isDeferredRenderingPath, isDeferredReflections); RenderProbeAnchor(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); // Draw label position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Keyboard), label); // Don't make child fields be indented var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; bool prevShowMixedValue = EditorGUI.showMixedValue; bool deferredRenderingPath = ChiselEditorUtility.IsUsingDeferredRenderingPath(); EditorGUI.showMixedValue = prevShowMixedValue || property.hasMultipleDifferentValues; try { var surfaceFlags = (SurfaceFlags)property.intValue; bool isTextureLocked = (surfaceFlags & SurfaceFlags.TextureIsInWorldSpace) == 0; EditorGUI.BeginChangeCheck(); { isTextureLocked = EditorGUI.ToggleLeft(position, kTextureLockedContent, isTextureLocked); } if (EditorGUI.EndChangeCheck()) { if (isTextureLocked) { surfaceFlags &= ~SurfaceFlags.TextureIsInWorldSpace; } else { surfaceFlags |= SurfaceFlags.TextureIsInWorldSpace; } property.intValue = (int)surfaceFlags; } } catch (ExitGUIException) { } catch (Exception ex) { Debug.LogException(ex); } // Set indent back to what it was EditorGUI.indentLevel = indent; EditorGUI.showMixedValue = prevShowMixedValue; EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); bool prevShowMixedValue = EditorGUI.showMixedValue; bool deferredRenderingPath = ChiselEditorUtility.IsUsingDeferredRenderingPath(); EditorGUI.showMixedValue = prevShowMixedValue || property.hasMultipleDifferentValues; try { var layerUsage = (LayerUsageFlags)property.intValue; bool isRenderable = (layerUsage & LayerUsageFlags.Renderable) != 0; bool isCastShadows = (layerUsage & LayerUsageFlags.CastShadows) != 0; bool isReceiveShadows = (layerUsage & LayerUsageFlags.ReceiveShadows) != 0; bool isCollidable = (layerUsage & LayerUsageFlags.Collidable) != 0; // Draw label position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Keyboard), label); EditorGUI.BeginChangeCheck(); { // Don't make child fields be indented var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; var toggleStyle = EditorStyles.label; var halfWidth = position.width / 2.0f; var textWidthRight = toggleStyle.CalcSize(ReceiveShadowsContent).x; var textWidthLeft = toggleStyle.CalcSize(CollidableContent).x; var offset = (position.width - (textWidthRight + textWidthLeft)) / 2; if (offset < 0) { textWidthRight = position.width - textWidthLeft; } else { textWidthLeft += offset; textWidthRight += offset; } var button1 = position; var button2 = position; button1.height = button2.height = EditorGUIUtility.singleLineHeight; button1.width = textWidthLeft; button2.width = textWidthRight; button2.x += button1.width; var button3 = button1; var button4 = button2; button3.y += button1.height; button4.y += button2.height; isRenderable = EditorGUI.ToggleLeft(button1, VisibleContent, isRenderable, toggleStyle); EditorGUI.BeginDisabledGroup(deferredRenderingPath || !isRenderable); if (!isRenderable) { EditorGUI.ToggleLeft(button2, ReceiveShadowsContent, false, toggleStyle); } else if (deferredRenderingPath) { EditorGUI.ToggleLeft(button2, ReceiveShadowsContent, true, toggleStyle); } else { isReceiveShadows = EditorGUI.ToggleLeft(button2, ReceiveShadowsContent, isReceiveShadows, toggleStyle); } EditorGUI.EndDisabledGroup(); isCollidable = EditorGUI.ToggleLeft(button3, CollidableContent, isCollidable, toggleStyle); isCastShadows = EditorGUI.ToggleLeft(button4, CastShadowsContent, isCastShadows, toggleStyle); // Set indent back to what it was EditorGUI.indentLevel = indent; } if (EditorGUI.EndChangeCheck()) { if (isRenderable) { layerUsage |= LayerUsageFlags.Renderable; } else { layerUsage &= ~LayerUsageFlags.Renderable; } if (isCastShadows) { layerUsage |= LayerUsageFlags.CastShadows; } else { layerUsage &= ~LayerUsageFlags.CastShadows; } if (isReceiveShadows) { layerUsage |= LayerUsageFlags.ReceiveShadows; } else { layerUsage &= ~LayerUsageFlags.ReceiveShadows; } if (isCollidable) { layerUsage |= LayerUsageFlags.Collidable; } else { layerUsage &= ~LayerUsageFlags.Collidable; } property.intValue = (int)layerUsage; } } catch (ExitGUIException) { } catch (Exception ex) { Debug.LogException(ex); } EditorGUI.showMixedValue = prevShowMixedValue; EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); bool visible = true; // Draw label if (label != null) { EditorGUI.BeginChangeCheck(); visible = SessionState.GetBool(property.propertyPath, false); var foldOutPosition = position; foldOutPosition.height = EditorGUI.GetPropertyHeight(SerializedPropertyType.Generic, GUIContent.none); visible = EditorGUI.Foldout(foldOutPosition, visible, label); if (EditorGUI.EndChangeCheck()) { SessionState.SetBool(property.propertyPath, visible); } position.yMin += foldOutPosition.height; } if (visible) { position.xMin += EditorGUIUtility.labelWidth; // Don't make child fields be indented var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; var leftStyle = EditorStyles.miniButtonLeft; var rightStyle = EditorStyles.miniButtonRight; var middleStyle = EditorStyles.miniButtonMid; bool prevShowMixedValue = EditorGUI.showMixedValue; bool deferredRenderingPath = ChiselEditorUtility.IsUsingDeferredRenderingPath(); EditorGUI.showMixedValue = prevShowMixedValue || property.hasMultipleDifferentValues; try { SerializedProperty ValueProp = property.FindPropertyRelative(nameof(SmoothingGroup.value)); var smoothingGroup = (uint)ValueProp.intValue; EditorGUI.BeginChangeCheck(); { var startPosition = position; position.width /= kBitsWide; position.height = EditorGUI.GetPropertyHeight(SerializedPropertyType.Boolean, GUIContent.none); for (int y = 0, i = 0; y < kBitsHigh; y++) { position.x = startPosition.x; for (int x = 0; x < kBitsWide; x++, i++) { var toggleStyle = (x == 0) ? leftStyle : (x == kBitsWide - 1) ? rightStyle : middleStyle; var bit = (1u << i); var enabled = GUI.Toggle(position, (smoothingGroup & bit) != 0, kBits[i], toggleStyle); if (enabled) { smoothingGroup = (smoothingGroup | bit); } else { smoothingGroup = (smoothingGroup & ~bit); } position.x += position.width; } position.y += position.height + kSpacing; } } if (EditorGUI.EndChangeCheck()) { ValueProp.intValue = (int)smoothingGroup; } } catch (ExitGUIException) { } catch (Exception ex) { Debug.LogException(ex); } // Set indent back to what it was EditorGUI.indentLevel = indent; EditorGUI.showMixedValue = prevShowMixedValue; } EditorGUI.EndProperty(); }