static Rect DoGUILayout(SerializedShadowResolutionSettingValue self, GUIContent label) { var rect = GUILayoutUtility.GetRect(0, float.Epsilon, 0, EditorGUIUtility.singleLineHeight); var contentRect = EditorGUI.PrefixLabel(rect, label); // Render the enum popup const int k_EnumWidth = 70; // Magic number?? const int k_EnumOffset = 30; var enumRect = new Rect(contentRect); enumRect.x -= k_EnumOffset; enumRect.width = k_EnumWidth + k_EnumOffset; var(level, useOverride) = LevelFieldGUI(enumRect, self.level.intValue, self.useOverride.boolValue); self.useOverride.boolValue = useOverride; self.level.intValue = level; // Return the rect fo user can render the field there var fieldRect = new Rect(contentRect); fieldRect.x = enumRect.x + enumRect.width + 2 - k_EnumOffset; fieldRect.width = contentRect.width - (fieldRect.x - enumRect.x) + k_EnumOffset; return(fieldRect); }
public static void LevelAndIntGUILayout <T>(this SerializedShadowResolutionSettingValue self, GUIContent label, T @default) where T : struct, IValueGetter <int> { var fieldRect = DoGUILayout(self, label); if (self.useOverride.boolValue) { [email protected] = EditorGUI.IntField(fieldRect, [email protected]); } else { EditorGUI.LabelField(fieldRect, $"{@default.GetValue(self.level.intValue)} ({@default.sourceDescription})"); } }
public static void LevelAndIntGUILayout(this SerializedShadowResolutionSettingValue self, GUIContent label) { LevelAndIntGUILayout(self, label, new NoopGetter <int>()); }