Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice
Dismiss Notice
Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.

[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 ThundThund like this.