Search Unity

  1. We have added a sub-forum for DOTS Graphics. Please use the new space for related discussions.
    Dismiss Notice
  2. The 2021.2 beta is now available. To find out what's new, have a look at our 2021.2 beta blog post.
    Dismiss Notice
  3. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  4. Dismiss Notice

DOTS: Odd error, cannot find ANY ref: Unity.Rendering.LightMaps.CopyToTextureArray

Discussion in 'DOTS Graphics' started by JamesWjRose, Feb 10, 2021.

  1. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    505
    I have the following script to convert child objects to entities:
    Code (CSharp):
    1. using Unity.Entities;
    2. using UnityEngine;
    3.  
    4. public class GameObjectToEntityConversion : MonoBehaviour
    5. {
    6.     private EntityManager entityManager;
    7.     private GameObjectConversionSettings conversionSettings;
    8.  
    9.     void Start()
    10.     {
    11.         entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
    12.         conversionSettings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, new BlobAssetStore());
    13.  
    14.         ConvertChildren(this.transform);
    15.  
    16.         Cleanup();
    17.     }
    18.  
    19.     private void ConvertChildren(Transform transform)
    20.     {
    21.         foreach (Transform child in transform)
    22.         {
    23.             ConvertGameObject(child.gameObject);
    24.  
    25.             ConvertChildren(child);
    26.         }
    27.     }
    28.     private void ConvertGameObject(GameObject gameObject)
    29.     {
    30.         Entity prefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(gameObject, conversionSettings);
    31.         var entity = entityManager.Instantiate(prefab);
    32.     }
    33.  
    34.     private void Cleanup()
    35.     {
    36.         conversionSettings.BlobAssetStore.Dispose();
    37.     }
    38. }
    Currently there are 33 child objects, each a basic cliff/rock with the same material that is set to "Enable GPU Instancing" and when that code runs I get 33 instances of the following error:

    -------------------------------------------------------------------
    NullReferenceException
    Unity.Rendering.LightMaps.CopyToTextureArray (System.Collections.Generic.List`1[T] source) (at Library/PackageCache/com.unity.rendering.hybrid@0.11.0-preview.42/Unity.Rendering.Hybrid/LightMaps.cs:52)
    Unity.Rendering.LightMaps.ConstructLightMaps (System.Collections.Generic.List`1[T] inColors, System.Collections.Generic.List`1[T] inDirections, System.Collections.Generic.List`1[T] inShadowMasks) (at Library/PackageCache/com.unity.rendering.hybrid@0.11.0-preview.42/Unity.Rendering.Hybrid/LightMaps.cs:67)
    Unity.Rendering.LightMapConversionContext.ProcessLightMapsForConversion () (at Library/PackageCache/com.unity.rendering.hybrid@0.11.0-preview.42/Unity.Rendering.Hybrid/RenderMeshConversionContext.cs:188)
    Unity.Rendering.RenderMeshConversionContext.ProcessLightMapsForConversion () (at Library/PackageCache/com.unity.rendering.hybrid@0.11.0-preview.42/Unity.Rendering.Hybrid/RenderMeshConversionContext.cs:328)
    Unity.Rendering.MeshRendererConversion.OnUpdate () (at Library/PackageCache/com.unity.rendering.hybrid@0.11.0-preview.42/Unity.Rendering.Hybrid/MeshRendererConversion.cs:41)
    Unity.Entities.ComponentSystem.Update () (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ComponentSystem.cs:114)
    Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ComponentSystemGroup.cs:472)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    Unity.Entities.Conversion.JournalingUnityLogger:LogException(Exception, Object) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities.Hybrid/GameObjectConversion/JournalingUnityLogger.cs:50)
    UnityEngine.Debug:LogException(Exception)
    Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/Stubs/Unity/Debug.cs:19)
    Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ComponentSystemGroup.cs:477)
    Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ComponentSystemGroup.cs:417)
    Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities/ComponentSystem.cs:114)
    Unity.Entities.GameObjectConversionUtility:Convert(World) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities.Hybrid/GameObjectConversion/GameObjectConversionUtility.cs:152)
    Unity.Entities.GameObjectConversionUtility:ConvertGameObjectHierarchy(GameObject, GameObjectConversionSettings) (at Library/PackageCache/com.unity.entities@0.17.0-preview.41/Unity.Entities.Hybrid/GameObjectConversion/GameObjectConversionUtility.cs:277)
    GameObjectToEntityConversion:ConvertGameObject(GameObject) (at Assets/Virtual Tolkien/Scripts/GameObjectToEntityConversion.cs:30)
    GameObjectToEntityConversion:ConvertChildren(Transform) (at Assets/Virtual Tolkien/Scripts/GameObjectToEntityConversion.cs:23)
    GameObjectToEntityConversion:Start() (at Assets/Virtual Tolkien/Scripts/GameObjectToEntityConversion.cs:14)

    -------------------------------------------------------------------

    So.. what dumbass thing am I doing wrong?

    Thanks kindly.
     
  2. RecursiveEclipse

    RecursiveEclipse

    Joined:
    Sep 6, 2018
    Posts:
    285
    Use IConvertGameObjectToEntity?
     
  3. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    505
    Do you have an example on how to do so?

    Thanks
     
  4. RecursiveEclipse

    RecursiveEclipse

    Joined:
    Sep 6, 2018
    Posts:
    285
  5. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    505
unityunity