Exemplo n.º 1
0
        /// <summary>
        /// Remove a lens flare data which exist in the pool.
        /// </summary>
        /// <param name="data">The data which exist in the pool</param>
        public void RemoveData(LensFlareComponentSRP data)
        {
            Debug.Assert(Instance == this, "LensFlareCommonSRP can have only one instance");

            if (m_Data.Contains(data))
            {
                m_Data.Remove(data);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add a new lens flare component on the pool.
        /// </summary>
        /// <param name="newData">The new data added</param>
        public void AddData(LensFlareComponentSRP newData)
        {
            Debug.Assert(Instance == this, "LensFlareCommonSRP can have only one instance");

            if (!m_Data.Contains(newData))
            {
                m_Data.Add(newData);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Implement this function to make a custom inspector
        /// </summary>
        public override void OnInspectorGUI()
        {
            LensFlareComponentSRP lensFlareData = m_Intensity.serializedObject.targetObject as LensFlareComponentSRP;
            bool  attachedToLight = false;
            bool  lightIsDirLight = false;
            Light light           = null;

            if (lensFlareData != null &&
                (light = lensFlareData.GetComponent <Light>()) != null)
            {
                attachedToLight = true;
                if (light.type == LightType.Directional)
                {
                    lightIsDirLight = true;
                }
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.LabelField(Styles.generalData.text, EditorStyles.boldLabel);
            {
                EditorGUILayout.PropertyField(m_LensFlareData, Styles.lensFlareData);
                EditorGUILayout.PropertyField(m_Intensity, Styles.intensity);
                EditorGUILayout.PropertyField(m_Scale, Styles.scale);
                if (!lightIsDirLight)
                {
                    if (attachedToLight)
                    {
                        EditorGUILayout.PropertyField(m_AttenuationByLightShape, Styles.attenuationByLightShape);
                    }
                    EditorGUILayout.PropertyField(m_MaxAttenuationDistance, Styles.maxAttenuationDistance);
                    ++EditorGUI.indentLevel;
                    EditorGUILayout.PropertyField(m_DistanceAttenuationCurve, Styles.distanceAttenuationCurve);
                    --EditorGUI.indentLevel;
                    EditorGUILayout.PropertyField(m_MaxAttenuationScale, Styles.maxAttenuationScale);
                    ++EditorGUI.indentLevel;
                    EditorGUILayout.PropertyField(m_ScaleByDistanceCurve, Styles.scaleByDistanceCurve);
                    --EditorGUI.indentLevel;
                    EditorGUILayout.PropertyField(m_RadialScreenAttenuationCurve, Styles.radialScreenAttenuationCurve);
                }
            }
            EditorGUILayout.LabelField(Styles.occlusionData.text, EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(m_UseOcclusion, Styles.enableOcclusion);
            if (m_UseOcclusion.boolValue)
            {
                EditorGUILayout.PropertyField(m_OcclusionRadius, Styles.occlusionRadius);
                ++EditorGUI.indentLevel;
                EditorGUILayout.PropertyField(m_SamplesCount, Styles.sampleCount);
                --EditorGUI.indentLevel;
                EditorGUILayout.PropertyField(m_OcclusionOffset, Styles.occlusionOffset);
            }
            EditorGUILayout.PropertyField(m_AllowOffScreen, Styles.allowOffScreen);

            if (EditorGUI.EndChangeCheck())
            {
                m_LensFlareData.serializedObject.ApplyModifiedProperties();
            }
        }
Exemplo n.º 4
0
 void OnDestroy()
 {
     GameObject.Destroy(this.lightObject);
     this.lightObject         = null;
     this.skyDirectionalLight = null;
     this.hdLight             = null;
     this.timer        = null;
     this.dayFlare     = null;
     this.nightFlare   = null;
     this.volume       = null;
     this.pbsky        = null;
     this.clouds       = null;
     this.whiteBalance = null;
 }
        /// <summary>
        /// Implement this function to make a custom inspector
        /// </summary>
        public override void OnInspectorGUI()
        {
            LensFlareComponentSRP lensFlareData = m_Intensity.serializedObject.targetObject as LensFlareComponentSRP;
            bool  attachedToLight = false;
            bool  lightIsDirLight = false;
            Light light           = null;

            if (lensFlareData != null &&
                (light = lensFlareData.GetComponent <Light>()) != null)
            {
                attachedToLight = true;
                if (light.type == LightType.Directional)
                {
                    lightIsDirLight = true;
                }
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.LabelField(Styles.generalData.text, EditorStyles.boldLabel);
            {
                using (new EditorGUILayout.HorizontalScope())
                {
                    bool showCopy    = m_LensFlareData.objectReferenceValue != null;
                    int  buttonWidth = showCopy ? 45 : 60;

                    EditorGUILayout.PropertyField(m_LensFlareData, Styles.lensFlareData);
                    if (GUILayout.Button(Styles.newButton, showCopy ? EditorStyles.miniButtonLeft : EditorStyles.miniButton, GUILayout.Width(buttonWidth)))
                    {
                        // By default, try to put assets in a folder next to the currently active
                        // scene file. If the user isn't a scene, put them in root instead.
                        var actualTarget = target as LensFlareComponentSRP;
                        var targetName   = actualTarget.name + " Lens Flare (SRP)";
                        var scene        = actualTarget.gameObject.scene;
                        var asset        = LensFlareEditorUtils.CreateLensFlareDataSRPAsset(scene, targetName);
                        m_LensFlareData.objectReferenceValue = asset;
                    }
                    if (showCopy && GUILayout.Button(Styles.cloneButton, EditorStyles.miniButtonRight, GUILayout.Width(buttonWidth)))
                    {
                        // Duplicate the currently assigned profile and save it as a new profile
                        var origin = m_LensFlareData.objectReferenceValue;
                        var path   = AssetDatabase.GetAssetPath(m_LensFlareData.objectReferenceValue);

                        path = CoreEditorUtils.IsAssetInReadOnlyPackage(path)

                               // We may be in a read only package, in that case we need to clone the volume profile in an
                               // editable area, such as the root of the project.
                            ? AssetDatabase.GenerateUniqueAssetPath(Path.Combine("Assets", Path.GetFileName(path)))

                               // Otherwise, duplicate next to original asset.
                            : AssetDatabase.GenerateUniqueAssetPath(path);

                        var asset = Instantiate(origin);
                        AssetDatabase.CreateAsset(asset, path);
                        AssetDatabase.SaveAssets();
                        AssetDatabase.Refresh();

                        m_LensFlareData.objectReferenceValue = asset;
                    }
                }
                EditorGUILayout.PropertyField(m_Intensity, Styles.intensity);
                EditorGUILayout.PropertyField(m_Scale, Styles.scale);
                if (!lightIsDirLight)
                {
                    if (attachedToLight)
                    {
                        EditorGUILayout.PropertyField(m_AttenuationByLightShape, Styles.attenuationByLightShape);
                    }
                    EditorGUILayout.PropertyField(m_MaxAttenuationDistance, Styles.maxAttenuationDistance);
                    ++EditorGUI.indentLevel;
                    EditorGUILayout.PropertyField(m_DistanceAttenuationCurve, Styles.distanceAttenuationCurve);
                    --EditorGUI.indentLevel;
                    EditorGUILayout.PropertyField(m_MaxAttenuationScale, Styles.maxAttenuationScale);
                    ++EditorGUI.indentLevel;
                    EditorGUILayout.PropertyField(m_ScaleByDistanceCurve, Styles.scaleByDistanceCurve);
                    --EditorGUI.indentLevel;
                }
                EditorGUILayout.PropertyField(m_RadialScreenAttenuationCurve, Styles.radialScreenAttenuationCurve);
            }
            EditorGUILayout.LabelField(Styles.occlusionData.text, EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(m_UseOcclusion, Styles.enableOcclusion);
            if (m_UseOcclusion.boolValue)
            {
                EditorGUILayout.PropertyField(m_OcclusionRadius, Styles.occlusionRadius);
                ++EditorGUI.indentLevel;
                EditorGUILayout.PropertyField(m_SamplesCount, Styles.sampleCount);
                --EditorGUI.indentLevel;
                EditorGUILayout.PropertyField(m_OcclusionOffset, Styles.occlusionOffset);
            }
            EditorGUILayout.PropertyField(m_AllowOffScreen, Styles.allowOffScreen);

            if (EditorGUI.EndChangeCheck())
            {
                m_LensFlareData.serializedObject.ApplyModifiedProperties();
            }
        }