public int GetSchemaLevelCount() { var schema = ScalableSettingSchema.GetSchemaOrNull(new ScalableSettingSchemaId(schemaId.stringValue)) ?? ScalableSettingSchema.GetSchemaOrNull(ScalableSettingSchemaId.With3Levels); return(schema.levelCount); }
public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) { var value = parameter.value; if (value.propertyType != SerializedPropertyType.Integer) { return(false); } var o = parameter.GetObjectRef <ScalableSettingLevelParameter>(); var(level, useOverride) = o.levelAndOverride; var rect = GUILayoutUtility.GetRect(0, float.Epsilon, 0, EditorGUIUtility.singleLineHeight); // Magic number for padding rect.x += 3; rect.y += 2; rect.width -= 3; o.levelAndOverride = SerializedScalableSettingValueUI.LevelFieldGUI( rect, title, ScalableSettingSchema.GetSchemaOrNull(ScalableSettingSchemaId.With3Levels), level, useOverride ); return(true); }
public override bool OnGUI(SerializedDataParameter parameter, GUIContent title) { var value = parameter.value; if (value.propertyType != SerializedPropertyType.Integer) { return(false); } var o = parameter.GetObjectRef <ScalableSettingLevelParameter>(); var(level, useOverride) = o.levelAndOverride; var rect = EditorGUILayout.GetControlRect(); var levelAndOverride = SerializedScalableSettingValueUI.LevelFieldGUI( rect, title, ScalableSettingSchema.GetSchemaOrNull(ScalableSettingSchemaId.With3Levels), level, useOverride ); value.intValue = ScalableSettingLevelParameter.GetScalableSettingLevelParameterValue(levelAndOverride.level, levelAndOverride.useOverride); return(true); }
public void LevelNamesWorks() { var schema = ScalableSettingSchema.GetSchemaOrNull(ScalableSettingSchemaId.With3Levels); Assert.AreEqual(3, schema.levelCount); Assert.AreEqual(3, schema.levelNames.Length); Assert.AreEqual("Low", schema.levelNames[0].text); Assert.AreEqual("Medium", schema.levelNames[1].text); Assert.AreEqual("High", schema.levelNames[2].text); }
public void GetSchemaOrNullWorks() { { var schema = ScalableSettingSchema.GetSchemaOrNull(ScalableSettingSchemaId.With3Levels); Assert.IsNotNull(schema); Assert.AreEqual(3, schema.levelCount); Assert.AreEqual(3, schema.levelNames.Length); } { ScalableSettingSchemaId?id = ScalableSettingSchemaId.With3Levels; var schema = ScalableSettingSchema.GetSchemaOrNull(id); Assert.IsNotNull(schema); Assert.AreEqual(3, schema.levelCount); Assert.AreEqual(3, schema.levelNames.Length); } }
/// <summary> /// Draw the scalable setting as a single line field with multiple values. /// /// There will be one value per level. /// </summary> /// <typeparam name="T">The type of the scalable setting.</typeparam> /// <param name="self">The scalable setting to draw.</param> /// <param name="label">The label of the field.</param> public static void ValueGUI <T>(this SerializedScalableSetting self, GUIContent label) where T : struct { var schema = ScalableSettingSchema.GetSchemaOrNull(new ScalableSettingSchemaId(self.schemaId.stringValue)) ?? ScalableSettingSchema.GetSchemaOrNull(ScalableSettingSchemaId.With3Levels); EditorGUI.showMixedValue = self.values.hasMultipleDifferentValues; var count = schema.levelCount; if (self.values.arraySize != count) { self.values.arraySize = count; } LevelValuesFieldGUI <T>(label, self, count, schema); EditorGUI.showMixedValue = false; }
/// <summary> /// Draw the scalable setting as a single line field with multiple values. /// /// There will be one value per level. /// </summary> /// <typeparam name="T">The type of the scalable setting.</typeparam> /// <param name="self">The scalable setting to draw.</param> /// <param name="label">The label of the field.</param> public static void ValueGUI <T>(this SerializedScalableSetting self, GUIContent label) where T : struct { var schema = ScalableSettingSchema.GetSchemaOrNull(new ScalableSettingSchemaId(self.schemaId.stringValue)) ?? ScalableSettingSchema.GetSchemaOrNull(ScalableSettingSchemaId.With3Levels); var rect = GUILayoutUtility.GetRect(0, float.Epsilon, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight); // Magic Number !! rect.x += 3; rect.width -= 6; // Magic Number !! var contentRect = EditorGUI.PrefixLabel(rect, label); EditorGUI.showMixedValue = self.values.hasMultipleDifferentValues; var count = schema.levelCount; if (self.values.arraySize != count) { self.values.arraySize = count; } if (typeof(T) == typeof(bool)) { LevelValuesFieldGUI <bool>(contentRect, self, count, schema); } else if (typeof(T) == typeof(int)) { LevelValuesFieldGUI <int>(contentRect, self, count, schema); } else if (typeof(T) == typeof(float)) { LevelValuesFieldGUI <float>(contentRect, self, count, schema); } else if (typeof(T).IsEnum) { LevelValuesFieldGUI <T>(contentRect, self, count, schema); } EditorGUI.showMixedValue = false; }
int GetMinimumMaxLoDValue(HDRenderPipelineAsset asset) { int minimumMaxLoD = int.MaxValue; var maxLoDs = asset.currentPlatformRenderPipelineSettings.maximumLODLevel; var schema = ScalableSettingSchema.GetSchemaOrNull(maxLoDs.schemaId); for (int lod = 0; lod < schema.levelCount; ++lod) { if (maxLoDs.TryGet(lod, out int maxLoD)) { minimumMaxLoD = Mathf.Min(minimumMaxLoD, maxLoD); } } if (minimumMaxLoD != int.MaxValue) { return(minimumMaxLoD); } else { return(0); } }