// 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();
        }
예제 #2
0
        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();
            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.intensity = intensity.floatValue;
                }
                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(shadowResolution);
                    EditorGUILayout.PropertyField(shadowsNearPlane);
                    EditorGUILayout.PropertyField(viewBiasMin);
                    EditorGUILayout.PropertyField(viewBiasScale);
                    EditorGUILayout.PropertyField(normalBiasMin);
                    normalBiasMax = normalBiasMin;
                }
            }

            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();
            }
        }