Search Unity

How to transfer realtime lightmaps?

Discussion in 'Scripting' started by SuperUltraHyper, Mar 17, 2019.

  1. SuperUltraHyper

    SuperUltraHyper

    Joined:
    Sep 7, 2015
    Posts:
    112
    I am trying to transfer a static lightmap from an object to a duplicate object.

    I essentially have 2 objects in my scene. One that I have baked lighting on and one that is inactive when baked but it also set to static. At at run time I want to use the same realtime lightmap on this object.

    This doesn't work.

    Code (CSharp):
    1. targetRenderer.realtimeLightmapIndex = sourceRenderer.realtimeLightmapIndex;
    2. targetRenderer.realtimeLightmapScaleOffset = sourceRenderer.realtimeLightmapScaleOffset;
    In the inspector, I can see the real time lightmap on the original object but not on the duplicate. Also, blend probes is not set to off and greyed out like the original.

    Any ideas?!

    Thanks in advance!