Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

[11.0.0^] Point light has weird light texture source

Discussion in '2D Experimental Preview' started by Creta_Park, Apr 9, 2021.

  1. Creta_Park

    Creta_Park

    Joined:
    Mar 11, 2016
    Posts:
    76
    11.0.0 bug before.gif 11.0.0 bug.gif

    I just tried to update 2021.1.2f1, I see that URP goes from 10.4.0 to 11.0.0 and I got some weird point light bug that seems like does sprite light.

    Left : 10.4.0
    Right : 11.0.0

    This also cannot reproduce at vanilla, I'll report it with Unity bug report later (last one too).
    Is anyone had like this problem?
     
  2. Creta_Park

    Creta_Park

    Joined:
    Mar 11, 2016
    Posts:
    76
    I have got reply from bug report.
    Support says it's cause deprecated light cookie field of point light contains sprite.

    I tried to fix it myself, so here's I did automated macro to remove sprites from these field in point type 2D lights.

    Gist : https://gist.github.com/Creta5164/92af723389a2867a814eb1c31a53e884
    Code (CSharp):
    1. using System.Linq;
    2. using UnityEditor;
    3. using UnityEngine;
    4. using UnityEngine.Experimental.Rendering.Universal;
    5.  
    6. public static class RefactorCookies {
    7.  
    8.     [MenuItem("Tools/RefactorAllCookies")]
    9.     public static void RefactorAll() {
    10.      
    11.         var allLights = GameObject.FindObjectsOfType<Light2D>();
    12.         Debug.Log($"Gathered {allLights.Length} lights.");
    13.      
    14.         var pointLights = allLights.Where(component => component.lightType == Light2D.LightType.Point)
    15.             .Select(light => new SerializedObject(light))
    16.             .ToList();
    17.      
    18.         Debug.Log($"Gathered {pointLights.Count} point lights.");
    19.      
    20.         int fixedCount = 0;
    21.      
    22.         foreach (var lightCookie in pointLights) {
    23.          
    24.             lightCookie.Update();
    25.          
    26.             if (lightCookie.FindProperty("m_DeprecatedPointLightCookieSprite") is SerializedProperty depLightCookieProp) {
    27.              
    28.                 if (depLightCookieProp.objectReferenceValue) {
    29.                  
    30.                     depLightCookieProp.objectReferenceValue = null;
    31.                     fixedCount++;
    32.                 }
    33.             }
    34.          
    35.             lightCookie.ApplyModifiedProperties();
    36.         }
    37.      
    38.         //Based on : https://twitter.com/AdaRoseCannon/status/1380881598409740292
    39.         Debug.Log($"Query OK, {fixedCount} Light2Ds affected.");
    40.     }
    41. }
     
    Last edited: May 2, 2021
  3. Creta_Park

    Creta_Park

    Joined:
    Mar 11, 2016
    Posts:
    76
    Also, you can fix it manually.
    Enable Debug view in Inspector and find Deprecated Point Light Cookie field and remove sprite value to solve it.

    fix manually.gif
     
    Mr-kim and AlexVillalba like this.