Esempio n. 1
0
        void OnEnable()
        {
            m_Analytics            = Analytics.Renderer2DAnalytics.instance;
            m_ModifiedLights       = new HashSet <Light2D>();
            m_SortingLayerDropDown = new SortingLayerDropDown();

            m_LightType             = serializedObject.FindProperty("m_LightType");
            m_LightColor            = serializedObject.FindProperty("m_Color");
            m_LightIntensity        = serializedObject.FindProperty("m_Intensity");
            m_UseNormalMap          = serializedObject.FindProperty("m_UseNormalMap");
            m_ShadowIntensity       = serializedObject.FindProperty("m_ShadowIntensity");
            m_ShadowVolumeIntensity = serializedObject.FindProperty("m_ShadowVolumeIntensity");
            m_ApplyToSortingLayers  = serializedObject.FindProperty("m_ApplyToSortingLayers");
            m_VolumetricAlpha       = serializedObject.FindProperty("m_LightVolumeOpacity");
            m_BlendStyleIndex       = serializedObject.FindProperty("m_BlendStyleIndex");
            m_FalloffIntensity      = serializedObject.FindProperty("m_FalloffIntensity");
            m_PointZDistance        = serializedObject.FindProperty("m_PointLightDistance");
            m_LightOrder            = serializedObject.FindProperty("m_LightOrder");
            m_AlphaBlendOnOverlap   = serializedObject.FindProperty("m_AlphaBlendOnOverlap");

            // Point Light
            m_PointInnerAngle   = serializedObject.FindProperty("m_PointLightInnerAngle");
            m_PointOuterAngle   = serializedObject.FindProperty("m_PointLightOuterAngle");
            m_PointInnerRadius  = serializedObject.FindProperty("m_PointLightInnerRadius");
            m_PointOuterRadius  = serializedObject.FindProperty("m_PointLightOuterRadius");
            m_PointLightCookie  = serializedObject.FindProperty("m_LightCookieSprite");
            m_PointLightQuality = serializedObject.FindProperty("m_PointLightQuality");

            // Shape Light
            m_ShapeLightParametricRadius      = serializedObject.FindProperty("m_ShapeLightParametricRadius");
            m_ShapeLightFalloffSize           = serializedObject.FindProperty("m_ShapeLightFalloffSize");
            m_ShapeLightParametricSides       = serializedObject.FindProperty("m_ShapeLightParametricSides");
            m_ShapeLightParametricAngleOffset = serializedObject.FindProperty("m_ShapeLightParametricAngleOffset");
            m_ShapeLightFalloffOffset         = serializedObject.FindProperty("m_ShapeLightFalloffOffset");
            m_ShapeLightSprite = serializedObject.FindProperty("m_LightCookieSprite");

            m_AnyBlendStyleEnabled = false;
            var blendStyleIndices = new List <int>();
            var blendStyleNames   = new List <string>();

            var rendererData = Light2DEditorUtility.GetRenderer2DData();

            if (rendererData != null)
            {
                for (int i = 0; i < rendererData.lightBlendStyles.Length; ++i)
                {
                    blendStyleIndices.Add(i);

                    ref var blendStyle = ref rendererData.lightBlendStyles[i];
                    if (blendStyle.enabled)
                    {
                        blendStyleNames.Add(blendStyle.name);
                        m_AnyBlendStyleEnabled = true;
                    }
                    else
                    {
                        blendStyleNames.Add(blendStyle.name + " (Disabled)");
                    }
                }
            }
Esempio n. 2
0
        void OnEnable()
        {
            m_Analytics            = Analytics.Renderer2DAnalytics.instance;
            m_ModifiedLights       = new HashSet <Light2D>();
            m_SortingLayerDropDown = new SortingLayerDropDown();

            m_BlendingSettingsFoldout   = new SavedBool($"{target.GetType()}.2DURPBlendingSettingsFoldout", false);
            m_ShadowsSettingsFoldout    = new SavedBool($"{target.GetType()}.2DURPShadowsSettingsFoldout", false);
            m_VolumetricSettingsFoldout = new SavedBool($"{target.GetType()}.2DURPVolumetricSettingsFoldout", false);
            m_NormalMapsSettingsFoldout = new SavedBool($"{target.GetType()}.2DURPNormalMapsSettingsFoldout", false);

            m_LightType                    = serializedObject.FindProperty("m_LightType");
            m_LightColor                   = serializedObject.FindProperty("m_Color");
            m_LightIntensity               = serializedObject.FindProperty("m_Intensity");
            m_UseNormalMap                 = serializedObject.FindProperty("m_UseNormalMap");
            m_ShadowIntensity              = serializedObject.FindProperty("m_ShadowIntensity");
            m_ShadowIntensityEnabled       = serializedObject.FindProperty("m_ShadowIntensityEnabled");
            m_ShadowVolumeIntensity        = serializedObject.FindProperty("m_ShadowVolumeIntensity");
            m_ShadowVolumeIntensityEnabled = serializedObject.FindProperty("m_ShadowVolumeIntensityEnabled");
            m_ApplyToSortingLayers         = serializedObject.FindProperty("m_ApplyToSortingLayers");
            m_VolumetricIntensity          = serializedObject.FindProperty("m_LightVolumeIntensity");
            m_VolumetricIntensityEnabled   = serializedObject.FindProperty("m_LightVolumeIntensityEnabled");
            m_BlendStyleIndex              = serializedObject.FindProperty("m_BlendStyleIndex");
            m_FalloffIntensity             = serializedObject.FindProperty("m_FalloffIntensity");
            m_NormalMapZDistance           = serializedObject.FindProperty("m_NormalMapDistance");
            m_NormalMapQuality             = serializedObject.FindProperty("m_NormalMapQuality");
            m_LightOrder                   = serializedObject.FindProperty("m_LightOrder");
            m_OverlapOperation             = serializedObject.FindProperty("m_OverlapOperation");

            // Point Light
            m_PointInnerAngle            = serializedObject.FindProperty("m_PointLightInnerAngle");
            m_PointOuterAngle            = serializedObject.FindProperty("m_PointLightOuterAngle");
            m_PointInnerRadius           = serializedObject.FindProperty("m_PointLightInnerRadius");
            m_PointOuterRadius           = serializedObject.FindProperty("m_PointLightOuterRadius");
            m_DeprecatedPointLightSprite = serializedObject.FindProperty("m_DeprecatedPointLightCookieSprite");

            // Shape Light
            m_ShapeLightParametricRadius = serializedObject.FindProperty("m_ShapeLightParametricRadius");
            m_ShapeLightFalloffSize      = serializedObject.FindProperty("m_ShapeLightFalloffSize");
            m_ShapeLightParametricSides  = serializedObject.FindProperty("m_ShapeLightParametricSides");
            m_ShapeLightSprite           = serializedObject.FindProperty("m_LightCookieSprite");

            m_AnyBlendStyleEnabled = false;
            var blendStyleIndices = new List <int>();
            var blendStyleNames   = new List <string>();

            var rendererData = Light2DEditorUtility.GetRenderer2DData();

            if (rendererData != null)
            {
                for (int i = 0; i < rendererData.lightBlendStyles.Length; ++i)
                {
                    blendStyleIndices.Add(i);

                    ref var blendStyle = ref rendererData.lightBlendStyles[i];
                    blendStyleNames.Add(blendStyle.name);
                    m_AnyBlendStyleEnabled = true;
                }
            }
Esempio n. 3
0
        static void UpgradeMaterial(Material mat)
        {
            Renderer2DData data = Light2DEditorUtility.GetRenderer2DData();

            if (data != null)
            {
                Material defaultMat = data.GetDefaultMaterial(DefaultMaterialType.Sprite);

                if (mat.shader.name == "Sprites/Default")
                {
                    mat.shader = defaultMat.shader;
                }
            }
        }
Esempio n. 4
0
        static void UpgradeGameObject(GameObject go)
        {
            Renderer[]     spriteRenderers = go.GetComponentsInChildren <Renderer>(true);
            Renderer2DData data            = Light2DEditorUtility.GetRenderer2DData();

            if (data != null)
            {
                Material defaultMat = data.GetDefaultMaterial(DefaultMaterialType.Sprite);

                bool upgraded = false;
                foreach (Renderer renderer in spriteRenderers)
                {
                    int        materialCount = renderer.sharedMaterials.Length;
                    Material[] newMaterials  = new Material[materialCount];

                    for (int i = 0; i < materialCount; i++)
                    {
                        Material mat = renderer.sharedMaterials[i];

                        if (mat != null && mat.shader.name == "Sprites/Default")
                        {
                            newMaterials[i] = defaultMat;
                            upgraded        = true;
                        }
                        else
                        {
                            newMaterials[i] = renderer.sharedMaterials[i];
                        }
                    }

                    if (upgraded)
                    {
                        renderer.sharedMaterials = newMaterials;
                    }
                }

                if (upgraded)
                {
                    Debug.Log(go.name + " was upgraded.", go);
                    EditorSceneManager.MarkSceneDirty(go.scene);
                }
            }
        }
Esempio n. 5
0
 static bool CreateLightValidation()
 {
     return(Light2DEditorUtility.IsUsing2DRenderer());
 }
 static bool UpgradeProjectTo2DRendererValidation()
 {
     return(Light2DEditorUtility.IsUsing2DRenderer());
 }