public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); LightUIUtilities.DrawSplitter(); property.FindPropertyRelative("orientationParameters.yAxis").isExpanded = LightUIUtilities.DrawHeaderFoldout("Orientation", property.FindPropertyRelative("orientationParameters.yAxis").isExpanded); EditorGUI.indentLevel++; if (property.FindPropertyRelative("orientationParameters.yAxis").isExpanded) { EditorGUILayout.PropertyField(property.FindPropertyRelative("orientationParameters.yAxis")); EditorGUILayout.PropertyField(property.FindPropertyRelative("orientationParameters.lattitude")); EditorGUILayout.PropertyField(property.FindPropertyRelative("orientationParameters.timeOfDay"), GUILayout.MaxWidth(EditorGUIUtility.labelWidth + 250 + EditorGUIUtility.fieldWidth)); if (property.FindPropertyRelative("lightParameters.lightCookie").objectReferenceValue != null) { EditorGUILayout.PropertyField(property.FindPropertyRelative("orientationParameters.Roll")); } } EditorGUI.indentLevel--; LightUIUtilities.DrawSplitter(); property.FindPropertyRelative("lightParameters.intensity").isExpanded = LightUIUtilities.DrawHeaderFoldout("Light", property.FindPropertyRelative("lightParameters.intensity").isExpanded); EditorGUI.indentLevel++; if (property.FindPropertyRelative("lightParameters.intensity").isExpanded) { EditorGUILayout.PropertyField(property.FindPropertyRelative("intensityCurve")); EditorGUILayout.PropertyField(property.FindPropertyRelative("colorGradient")); EditorGUILayout.PropertyField(property.FindPropertyRelative("lightParameters.useColorTemperature")); EditorGUILayout.PropertyField(property.FindPropertyRelative("lightParameters.colorTemperature")); EditorGUILayout.PropertyField(property.FindPropertyRelative("lightParameters.intensity")); EditorGUILayout.PropertyField(property.FindPropertyRelative("lightParameters.mode"), new GUIContent("Light mode / Indirect Intensity"), GUILayout.MaxWidth(EditorGUIUtility.labelWidth + 80)); var modeRect = GUILayoutUtility.GetLastRect(); var indirectRect = new Rect(modeRect.x + EditorGUIUtility.labelWidth + 100, modeRect.y, position.xMax * 0.3f, EditorGUIUtility.singleLineHeight); EditorGUI.PropertyField(indirectRect, property.FindPropertyRelative("lightParameters.indirectIntensity"), GUIContent.none); EditorGUILayout.PropertyField(property.FindPropertyRelative("lightParameters.lightCookie")); if (property.FindPropertyRelative("lightParameters.lightCookie").objectReferenceValue != null) { EditorGUILayout.PropertyField(property.FindPropertyRelative("lightParameters.cookieSize")); } LightUIUtilities.LightLayerMaskDrawer(new GUIContent("Light Layers"), property.FindPropertyRelative("lightParameters.lightLayers")); } EditorGUI.indentLevel--; LightUIUtilities.DrawSplitter(); property.FindPropertyRelative("lightParameters.shadows").boolValue = LightUIUtilities.DrawHeader("Shadows", property.FindPropertyRelative("lightParameters.shadows").boolValue); EditorGUI.indentLevel++; if (property.FindPropertyRelative("lightParameters.shadows").boolValue) { EditorGUILayout.PropertyField(property.FindPropertyRelative("lightParameters.shadowResolution")); EditorGUILayout.PropertyField(property.FindPropertyRelative("lightParameters.viewBiasScale")); EditorGUILayout.PropertyField(property.FindPropertyRelative("lightParameters.normalBias")); EditorGUILayout.PropertyField(property.FindPropertyRelative("lightParameters.contactShadows")); } EditorGUI.indentLevel--; EditorGUI.EndProperty(); }
// Draw the property inside the given rect public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { // Using BeginProperty / EndProperty on the parent property means that // prefab override logic works on the entire property. EditorGUI.BeginProperty(position, label, property); EditorGUI.indentLevel--; LightUIUtilities.DrawSplitter(); LightUIUtilities.DrawHeader("Light"); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(property.FindPropertyRelative("intensity")); EditorGUILayout.PropertyField(property.FindPropertyRelative("colorFilter")); EditorGUILayout.PropertyField(property.FindPropertyRelative("type")); EditorGUILayout.PropertyField(property.FindPropertyRelative("mode"), new GUIContent("Light mode")); EditorGUILayout.PropertyField(property.FindPropertyRelative("range")); EditorGUILayout.PropertyField(property.FindPropertyRelative("indirectIntensity")); EditorGUILayout.PropertyField(property.FindPropertyRelative("lightCookie")); if (property.FindPropertyRelative("lightCookie").objectReferenceValue != null) { EditorGUILayout.PropertyField(property.FindPropertyRelative("cookieSize")); } // Draw label EditorGUILayout.Space(); EditorGUI.indentLevel--; LightUIUtilities.DrawSplitter(); LightUIUtilities.DrawHeader("Shape"); EditorGUI.indentLevel++; if (property.FindPropertyRelative("type").enumValueIndex == 0) //if spotlight { EditorGUILayout.PropertyField(property.FindPropertyRelative("lightAngle")); EditorGUILayout.PropertyField(property.FindPropertyRelative("innerSpotPercent")); EditorGUILayout.PropertyField(property.FindPropertyRelative("maxSmoothness")); } // Draw label EditorGUILayout.Space(); EditorGUI.indentLevel--; LightUIUtilities.DrawSplitter(); property.FindPropertyRelative("shadows").boolValue = LightUIUtilities.DrawHeader("Shadows", property.FindPropertyRelative("shadows").boolValue); EditorGUI.indentLevel++; // Draw fields if (property.FindPropertyRelative("shadows").boolValue != false) { EditorGUILayout.PropertyField(property.FindPropertyRelative("ShadowNearClip")); EditorGUILayout.PropertyField(property.FindPropertyRelative("shadowResolution")); EditorGUILayout.PropertyField(property.FindPropertyRelative("shadowStrength"), new GUIContent("Shadow Dimmer")); EditorGUILayout.PropertyField(property.FindPropertyRelative("viewBiasMin")); EditorGUILayout.PropertyField(property.FindPropertyRelative("viewBiasScale")); EditorGUILayout.PropertyField(property.FindPropertyRelative("normalBias")); } cullingMask = property.FindPropertyRelative("cullingMask"); // Draw label EditorGUILayout.Space(); EditorGUI.indentLevel--; LightUIUtilities.DrawSplitter(); cullingMask.isExpanded = LightUIUtilities.DrawHeaderFoldout("Additional settings", cullingMask.isExpanded); EditorGUI.indentLevel++; if (cullingMask.isExpanded) { EditorGUILayout.PropertyField(property.FindPropertyRelative("affectDiffuse")); EditorGUILayout.PropertyField(property.FindPropertyRelative("affectSpecular")); } EditorGUI.EndProperty(); }
public override void OnInspectorGUI() { if (m_SerializedShadowCasterTransform != null && cineLight.shadowCasterGO == null) { m_SerializedShadowCasterTransform = null; } serializedObject.Update(); m_SerializedLight.Update(); m_SerializedLightTransform.Update(); m_SerializedLightParentPitchTransform.Update(); m_SerializedLightParentYawTransform.Update(); m_SerializedAdditionalLightData.Update(); m_SerializedAdditionalShadowData.Update(); if (cineLight.shadowCasterGO != null) { m_SerializedShadowCasterTransform.Update(); } EditorGUILayout.Space(); EditorGUILayout.PropertyField(displayName); LightUIUtilities.DrawSplitter(); //EditorGUI.indentLevel--; yaw.isExpanded = LightUIUtilities.DrawHeaderFoldout("Rig", yaw.isExpanded); EditorGUI.indentLevel++; if (yaw.isExpanded) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(yaw); if (EditorGUI.EndChangeCheck()) { lightParentYawLocalRotation.quaternionValue = Quaternion.Euler(0, yaw.floatValue, 0); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(pitch); if (EditorGUI.EndChangeCheck()) { lightParentPitchLocalRotation.quaternionValue = Quaternion.Euler(-pitch.floatValue, 0, 0); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(roll); if (EditorGUI.EndChangeCheck()) { lightRotation.quaternionValue = Quaternion.Euler(0, 180, roll.floatValue + 180); } EditorGUILayout.PropertyField(distance, new GUIContent("Distance")); EditorGUILayout.PropertyField(lightParentYawLocalPosition, new GUIContent("Offset")); } LightUIUtilities.DrawSplitter(); EditorGUI.indentLevel--; color.isExpanded = LightUIUtilities.DrawHeaderFoldout("Light", color.isExpanded); EditorGUI.indentLevel++; if (color.isExpanded) { EditorGUILayout.PropertyField(useColorTemperature); if (useColorTemperature.boolValue) { EditorGUILayout.PropertyField(colorTemperature); } EditorGUILayout.PropertyField(color); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(intensity); //if (EditorGUI.EndChangeCheck()) //{ // m_SerializedAdditionalLightData.ApplyModifiedProperties(); // additionalLightData.ConvertPhysicalLightIntensityToLightIntensity(); //} EditorGUILayout.PropertyField(bounceIntensity); EditorGUILayout.PropertyField(range); EditorGUILayout.PropertyField(lightmapping); EditorGUILayout.PropertyField(cookie); if (cookie.objectReferenceValue != null) { EditorGUILayout.PropertyField(cookieSize); } } LightUIUtilities.DrawSplitter(); EditorGUI.indentLevel--; spotAngle.isExpanded = LightUIUtilities.DrawHeaderFoldout("Shape", spotAngle.isExpanded); EditorGUI.indentLevel++; if (spotAngle.isExpanded) { EditorGUILayout.Slider(spotAngle, 0, 180); EditorGUILayout.Slider(innerSpotPercent, 0, 100); EditorGUILayout.Slider(maxSmoothness, 0, 1); } LightUIUtilities.DrawSplitter(); EditorGUI.indentLevel--; shadowsType.isExpanded = LightUIUtilities.DrawHeaderFoldout("Shadows", shadowsType.isExpanded); EditorGUI.indentLevel++; if (shadowsType.isExpanded) { EditorGUILayout.PropertyField(shadowsType); if (shadowsType.enumValueIndex > 0) { //EditorGUILayout.PropertyField(shadowsQuality); EditorGUILayout.PropertyField(shadowResolution); EditorGUILayout.PropertyField(shadowsNearPlane); EditorGUILayout.PropertyField(viewBiasMin); EditorGUILayout.PropertyField(viewBiasScale); EditorGUILayout.PropertyField(normalBiasMin); normalBiasMax = normalBiasMin; //EditorGUILayout.PropertyField(bakedShadowRadius); //EditorGUILayout.PropertyField(bakedShadowAngle); } } LightUIUtilities.DrawSplitter(); EditorGUI.indentLevel--; drawGizmo.isExpanded = LightUIUtilities.DrawHeaderFoldout("Additional Settings", drawGizmo.isExpanded); EditorGUI.indentLevel++; if (drawGizmo.isExpanded) { EditorGUILayout.PropertyField(drawGizmo); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(showEntities); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); cineLight.ApplyShowFlags(showEntities.boolValue); } EditorGUILayout.PropertyField(cullingMask); EditorGUILayout.PropertyField(affectDiffuse); EditorGUILayout.PropertyField(affectSpecular); EditorGUILayout.PropertyField(shadowDimmer); EditorGUILayout.PropertyField(fadeDistance); EditorGUILayout.PropertyField(shadowFadeDistance); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(useShadowCaster); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); cineLight.ApplyShadowCaster(); } if (useShadowCaster.boolValue) { if (m_SerializedShadowCasterTransform == null) { InitShadowCasterSerializedObject(); } EditorGUI.BeginChangeCheck(); EditorGUILayout.LabelField("Shadow Caster", EditorStyles.boldLabel); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); cineLight.ApplyShadowCaster(); m_SerializedShadowCasterTransform.ApplyModifiedProperties(); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(shadowsCasterSize); EditorGUILayout.PropertyField(shadowsCasterDistance); EditorGUILayout.PropertyField(shadowsCasterOffset); if (EditorGUI.EndChangeCheck()) { if (cineLight.shadowCasterGO != null) { m_SerializedShadowCasterTransform.ApplyModifiedProperties(); shadowCasterLocalPosition.vector3Value = new Vector3(shadowsCasterOffset.vector2Value.x, shadowsCasterOffset.vector2Value.y, -shadowsCasterDistance.floatValue); shadowCasterLocalScale.vector3Value = new Vector3(shadowsCasterSize.vector2Value.x, shadowsCasterSize.vector2Value.y, 1); } } } } serializedObject.ApplyModifiedProperties(); m_SerializedLight.ApplyModifiedProperties(); m_SerializedLightTransform.ApplyModifiedProperties(); m_SerializedLightParentPitchTransform.ApplyModifiedProperties(); m_SerializedLightParentYawTransform.ApplyModifiedProperties(); m_SerializedAdditionalLightData.ApplyModifiedProperties(); m_SerializedAdditionalShadowData.ApplyModifiedProperties(); if (cineLight.shadowCasterGO != null) { m_SerializedShadowCasterTransform.ApplyModifiedProperties(); } }