Пример #1
0
        public override void OnInspectorGUI()
        {
            // Styling and icons.
            GUIStyle helpBoxStyle = new GUIStyle(EditorStyles.helpBox);

            helpBoxStyle.richText = true;
            Texture2D helpIconImage = EditorGUIUtility.FindTexture("console.infoicon.sml");
            GUIStyle  helpIconStyle = new GUIStyle();

            helpIconStyle.normal.background    = helpIconImage;
            helpIconStyle.onNormal.background  = helpIconImage;
            helpIconStyle.active.background    = helpIconImage;
            helpIconStyle.onActive.background  = helpIconImage;
            helpIconStyle.focused.background   = helpIconImage;
            helpIconStyle.onFocused.background = helpIconImage;

            serializedObject.Update();
            DS_HazeLightVolume lightVolume        = target as DS_HazeLightVolume;
            SerializedProperty samples            = serializedObject.FindProperty("m_Samples");
            SerializedProperty scatter            = serializedObject.FindProperty("m_Scattering");
            SerializedProperty secondScatter      = serializedObject.FindProperty("m_SecondaryScattering");
            SerializedProperty scatterDir         = serializedObject.FindProperty("m_ScatteringDirection");
            SerializedProperty densityTex         = serializedObject.FindProperty("m_DensityTexture");
            SerializedProperty densityTexScale    = serializedObject.FindProperty("m_DensityTextureScale");
            SerializedProperty densityTexContrast = serializedObject.FindProperty("m_DensityTextureContrast");
            SerializedProperty animateDir         = serializedObject.FindProperty("m_AnimateDirection");
            SerializedProperty animateSp          = serializedObject.FindProperty("m_AnimateSpeed");
            SerializedProperty startFade          = serializedObject.FindProperty("m_StartFade");
            SerializedProperty endFade            = serializedObject.FindProperty("m_EndFade");
            SerializedProperty farClip            = serializedObject.FindProperty("m_FarClip");

            if (lightVolume.LightTypeChanged())
            {
                lightVolume.UpdateLightType();
            }
            else if (lightVolume.ProxyMeshRequiresRebuild())
            {
                // Changing the light type always updates the proxy, so only need to trigger a specific update if the light shape changed.
                lightVolume.RebuildProxyMesh();
            }

            if (lightVolume.ShadowModeChanged())
            {
                lightVolume.UpdateShadowMode();
            }

            EditorGUILayout.BeginVertical();
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Performance:", EditorStyles.boldLabel);
                m_HelpTxtPerfExpanded = EditorGUILayout.Toggle(m_HelpTxtPerfExpanded, helpIconStyle, GUILayout.Width(helpIconImage.width));
                EditorGUILayout.EndHorizontal();
                if (m_HelpTxtPerfExpanded)
                {
                    EditorGUILayout.TextArea(m_HelpTxtPerf, helpBoxStyle);
                }

                EditorGUILayout.PropertyField(samples);
                EditorGUILayout.PropertyField(startFade);
                EditorGUILayout.PropertyField(endFade);

                GUI.enabled = lightVolume.Type == LightType.Spot;
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(farClip);
                if (EditorGUI.EndChangeCheck())
                {
                    lightVolume.RebuildProxyMesh();
                }
                GUI.enabled = true;
                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Scattering:", EditorStyles.boldLabel);
                m_HelpTxtScatterExpanded = EditorGUILayout.Toggle(m_HelpTxtScatterExpanded, helpIconStyle, GUILayout.Width(helpIconImage.width));
                EditorGUILayout.EndHorizontal();
                if (m_HelpTxtScatterExpanded)
                {
                    EditorGUILayout.TextArea(m_HelpTxtScatter, helpBoxStyle);
                }
                EditorGUILayout.PropertyField(scatter);
                EditorGUILayout.PropertyField(secondScatter);

                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(scatterDir);
                GUI.enabled = true;
                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Density:", EditorStyles.boldLabel);
                m_HelpTxtDensityExpanded = EditorGUILayout.Toggle(m_HelpTxtDensityExpanded, helpIconStyle, GUILayout.Width(helpIconImage.width));
                EditorGUILayout.EndHorizontal();
                if (m_HelpTxtDensityExpanded)
                {
                    EditorGUILayout.TextArea(m_HelpTxtDensity, helpBoxStyle);
                }
                EditorGUILayout.PropertyField(densityTex);

                if (densityTex.objectReferenceValue == null)
                {
                    GUI.enabled = false;
                }
                EditorGUILayout.PropertyField(densityTexScale);
                EditorGUILayout.PropertyField(densityTexContrast);
                EditorGUILayout.PropertyField(animateDir);
                EditorGUILayout.PropertyField(animateSp);
                GUI.enabled = true;
            }
            EditorGUILayout.EndVertical();
            serializedObject.ApplyModifiedProperties();
        }
Пример #2
0
        private void Update()
        {
            DS_HazeLightVolume dsHazeLightVolume = this;

            dsHazeLightVolume.m_DensityOffset = Vector3.op_Subtraction(dsHazeLightVolume.m_DensityOffset, Vector3.op_Multiply(Vector3.op_Multiply(Vector3.op_Multiply(this.m_AnimateDirection, this.m_AnimateSpeed), Time.get_deltaTime()), 0.1f));
        }
Пример #3
0
 public void AddLightVolume(DS_HazeLightVolume lightVolume)
 {
     this.RemoveLightVolume(lightVolume);
     this.m_LightVolumes.Add(lightVolume);
 }
Пример #4
0
 public void RemoveLightVolume(DS_HazeLightVolume lightVolume)
 {
     this.m_LightVolumes.Remove(lightVolume);
 }
Пример #5
0
 /// <summary>
 /// Add a volumetric light component to render this frame.
 /// </summary>
 /// <param name="lightVolume"></param>
 public void AddLightVolume(DS_HazeLightVolume lightVolume)
 {
     RemoveLightVolume(lightVolume);
     m_LightVolumes.Add(lightVolume);
 }