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 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); }
protected virtual LightingExplorerTableColumn[] GetHDLightColumns() { return(new[] { new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Name, HDStyles.Name, null, 200), // 0: Name new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, HDStyles.On, "m_Enabled", 25), // 1: Enabled new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Enum, HDStyles.Type, "m_Type", 60), // 2: Type new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Enum, HDStyles.Mode, "m_Lightmapping", 60), // 3: Mixed mode new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Enum, HDStyles.Range, "m_Range", 60), // 4: Range new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, HDStyles.ColorTemperatureMode, "m_UseColorTemperature", 100), // 5: Color Temperature Mode new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Color, HDStyles.Color, "m_Color", 60), // 6: Color new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, HDStyles.ColorTemperature, "m_ColorTemperature", 100, (r, prop, dep) => // 7: Color Temperature { if (prop.serializedObject.FindProperty("m_UseColorTemperature").boolValue) { prop = prop.serializedObject.FindProperty("m_ColorTemperature"); prop.floatValue = EditorGUI.FloatField(r, prop.floatValue); } }), new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, HDStyles.Intensity, "m_Intensity", 60, (r, prop, dep) => // 8: Intensity { Light light = prop.serializedObject.targetObject as Light; if (light == null || lightDataPairing[light].hdAdditionalLightData == null) { EditorGUI.LabelField(r, "null"); return; } float intensity = lightDataPairing[light].hdAdditionalLightData.intensity; EditorGUI.BeginChangeCheck(); intensity = EditorGUI.FloatField(r, intensity); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(lightDataPairing[light].hdAdditionalLightData, "Changed light intensity"); lightDataPairing[light].hdAdditionalLightData.intensity = intensity; } }), new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, HDStyles.Unit, "m_Intensity", 60, (r, prop, dep) => // 9: Unit { Light light = prop.serializedObject.targetObject as Light; if (light == null || lightDataPairing[light].hdAdditionalLightData == null) { EditorGUI.LabelField(r, "null"); return; } LightUnit unit = lightDataPairing[light].hdAdditionalLightData.lightUnit; EditorGUI.BeginChangeCheck(); unit = (LightUnit)EditorGUI.EnumPopup(r, unit); if (EditorGUI.EndChangeCheck()) { lightDataPairing[light].hdAdditionalLightData.lightUnit = unit; } }), new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, HDStyles.IndirectMultiplier, "m_BounceIntensity", 90), // 10: Indirect multiplier new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, HDStyles.Shadows, "m_Shadows.m_Type", 60, (r, prop, dep) => // 11: Shadows { EditorGUI.BeginChangeCheck(); bool shadows = EditorGUI.Toggle(r, prop.intValue != (int)LightShadows.None); if (EditorGUI.EndChangeCheck()) { prop.intValue = shadows ? (int)LightShadows.Soft : (int)LightShadows.None; } }), new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Custom, HDStyles.ContactShadowsSource, "m_Shadows.m_Type", 100, (r, prop, dep) => // 12: Contact Shadows { Light light = prop.serializedObject.targetObject as Light; if (light == null || lightDataPairing[light].hdAdditionalLightData == null) { EditorGUI.LabelField(r, "null"); return; } var value = lightDataPairing[light].hdAdditionalLightData.useContactShadow; EditorGUI.BeginChangeCheck(); var(level, useOverride) = SerializedScalableSettingValueUI.LevelFieldGUI(r, GUIContent.none, value.level, value.useOverride); if (EditorGUI.EndChangeCheck()) { value.level = level; value.useOverride = useOverride; } }), new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, HDStyles.ContactShadowsValue, "m_Shadows.m_Type", 100, (r, prop, dep) => // 12: Contact Shadows { Light light = prop.serializedObject.targetObject as Light; if (light == null || lightDataPairing[light].hdAdditionalLightData == null) { EditorGUI.LabelField(r, "null"); return; } var value = lightDataPairing[light].hdAdditionalLightData.useContactShadow; if (value.useOverride) { value.@override = EditorGUI.Toggle(r, value.@override); } else { var hdrp = GraphicsSettings.currentRenderPipeline as HDRenderPipelineAsset; var defaultValue = HDAdditionalLightData.ScalableSettings.UseContactShadow(hdrp); var enabled = GUI.enabled; GUI.enabled = false; EditorGUI.Toggle(r, defaultValue[value.level]); GUI.enabled = enabled; } }), new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Enum, HDStyles.ShadowResolutionSource, "m_Intensity", 60, (r, prop, dep) => // 14: Shadow Resolution Source { Light light = prop.serializedObject.targetObject as Light; if (light == null || lightDataPairing[light].hdAdditionalLightData == null) { EditorGUI.LabelField(r, "null"); return; } var shadowResolution = lightDataPairing[light].hdAdditionalLightData.shadowResolution; EditorGUI.BeginChangeCheck(); var(level, useOverride) = SerializedShadowResolutionSettingValueUI.LevelFieldGUI(r, shadowResolution.level, shadowResolution.useOverride); if (EditorGUI.EndChangeCheck()) { shadowResolution.level = level; shadowResolution.useOverride = useOverride; } }), new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Int, HDStyles.ShadowResolutionValue, "m_Intensity", 60, (r, prop, dep) => // 15: Shadow resolution value { var hdrp = GraphicsSettings.currentRenderPipeline as HDRenderPipelineAsset; Light light = prop.serializedObject.targetObject as Light; if (light == null || lightDataPairing[light].hdAdditionalLightData == null || hdrp == null) { EditorGUI.LabelField(r, "null"); return; } var shadowResolution = lightDataPairing[light].hdAdditionalLightData.shadowResolution; if (shadowResolution.useOverride) { shadowResolution.@override = EditorGUI.IntField(r, shadowResolution.@override); } else { var lightShape = SerializedHDLight.ResolveLightShape(lightDataPairing[light].hdAdditionalLightData.lightTypeExtent, light.type); var defaultValue = HDLightUI.ScalableSettings.ShadowResolution(lightShape, hdrp); EditorGUI.LabelField(r, defaultValue[shadowResolution.level].ToString()); } }), new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, HDStyles.AffectDiffuse, "m_Intensity", 90, (r, prop, dep) => // 16: Affect Diffuse { Light light = prop.serializedObject.targetObject as Light; if (light == null || lightDataPairing[light].hdAdditionalLightData == null) { EditorGUI.LabelField(r, "null"); return; } bool affectDiffuse = lightDataPairing[light].hdAdditionalLightData.affectDiffuse; EditorGUI.BeginChangeCheck(); affectDiffuse = EditorGUI.Toggle(r, affectDiffuse); if (EditorGUI.EndChangeCheck()) { lightDataPairing[light].hdAdditionalLightData.affectDiffuse = affectDiffuse; } }), new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Checkbox, HDStyles.AffectSpecular, "m_Intensity", 90, (r, prop, dep) => // 17: Affect Specular { Light light = prop.serializedObject.targetObject as Light; if (light == null || lightDataPairing[light].hdAdditionalLightData == null) { EditorGUI.LabelField(r, "null"); return; } bool affectSpecular = lightDataPairing[light].hdAdditionalLightData.affectSpecular; EditorGUI.BeginChangeCheck(); affectSpecular = EditorGUI.Toggle(r, affectSpecular); if (EditorGUI.EndChangeCheck()) { lightDataPairing[light].hdAdditionalLightData.affectSpecular = affectSpecular; } }), new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, HDStyles.FadeDistance, "m_Intensity", 60, (r, prop, dep) => // 18: Fade Distance { Light light = prop.serializedObject.targetObject as Light; if (light == null || lightDataPairing[light].hdAdditionalLightData == null) { EditorGUI.LabelField(r, "null"); return; } float fadeDistance = lightDataPairing[light].hdAdditionalLightData.fadeDistance; EditorGUI.BeginChangeCheck(); fadeDistance = EditorGUI.FloatField(r, fadeDistance); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(lightDataPairing[light].hdAdditionalLightData, "Changed light fade distance"); lightDataPairing[light].hdAdditionalLightData.fadeDistance = fadeDistance; } }), new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Float, HDStyles.ShadowFadeDistance, "m_Intensity", 60, (r, prop, dep) => // 19: Shadow Fade Distance { Light light = prop.serializedObject.targetObject as Light; if (light == null || lightDataPairing[light].hdAdditionalLightData == null) { EditorGUI.LabelField(r, "null"); return; } float shadowFadeDistance = lightDataPairing[light].hdAdditionalLightData.shadowFadeDistance; EditorGUI.BeginChangeCheck(); shadowFadeDistance = EditorGUI.FloatField(r, shadowFadeDistance); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(lightDataPairing[light].hdAdditionalLightData, "Changed light shadow fade distance"); lightDataPairing[light].hdAdditionalLightData.shadowFadeDistance = shadowFadeDistance; } }), new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Custom, HDStyles.LightLayer, "m_RenderingLayerMask", 80, (r, prop, dep) => // 20: Light Layer { using (new EditorGUI.DisabledScope(!(GraphicsSettings.renderPipelineAsset as HDRenderPipelineAsset).currentPlatformRenderPipelineSettings.supportLightLayers)) { HDEditorUtils.LightLayerMaskPropertyDrawer(r, prop); } }), new LightingExplorerTableColumn(LightingExplorerTableColumn.DataType.Custom, HDStyles.IsPrefab, "m_Intensity", 60, (r, prop, dep) => // 21: Prefab { Light light = prop.serializedObject.targetObject as Light; if (light == null) { EditorGUI.LabelField(r, "null"); return; } bool isPrefab = lightDataPairing[light].isPrefab; if (isPrefab) { EditorGUI.ObjectField(r, lightDataPairing[light].prefabRoot, typeof(GameObject), false); } }), }); }