Search Unity

Lightmap Trouble

Discussion in 'Editor & General Support' started by MathiasStarcke, Dec 18, 2017.

  1. MathiasStarcke

    MathiasStarcke

    Joined:
    Dec 14, 2017
    Posts:
    1
    Hi! I am having trouble copying lightmapIndex and lightmapScaleOffset from one gameobject to another, and making the settings stay there. The gameobjects are exact copies of each other with the same UV's.
    The game is a VR store, and the function of the objects are to simulate pulling the groceries forward, so they are all aligned nice and even along the shelf edge.
    So I have 3 objects of the same object to make this happen:
    A gameobject(#1) which you click on.
    A gameobject(#2) which is slightly moved forward. This object can't be baked with the main lightmap, as the geo overlaps #1. It was turned off when the lightmap was baked.
    And a gameobject(#3) which #2 copies it's lightmap index and offset from, since it is already aligned to the edge to the right of #2, and have a lightmap baked on to it.

    They function like this:
    When the game starts, it will find all objects like #2 and find it's closest object to gather lightmap info from (#3's). It will then copy the data from #3 to #2, and turn #2's mesh renderer off, so it is invicible. When the player click on #1, then #2's mesh renderer turns on and #1 is destroyed.

    This actually works fine on PC, but when we build it to an android phone, #2 gets black spots on it and looks really broken. I don't know, if it is because the build unable the ability to transfer lightmap info ingame, by baking something together?

    I thought, that maybe if I copy the info before the game start, it would keep it. So I basically made an Editor script that runs the lightmap finding and copying function, in the editor. Which works until you start the game, then #2 reverts back to having no lightmap info.

    Can anyone help me?!