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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

lightmapIndex in prefeb always equals -1 in unity5.01f1

Discussion in 'Global Illumination' started by alexhy, Apr 14, 2015.

  1. alexhy

    alexhy

    Joined:
    Nov 21, 2013
    Posts:
    26
    1.Bake a scene object, its render component's lightmapIndex equals 0;
    2.Make it to prefeb object;
    3.Drag it from project windows to scene;
    4.Its render component's lightmapIndex equals -1.
    why?
     
  2. alexhy

    alexhy

    Joined:
    Nov 21, 2013
    Posts:
    26
  3. alexhy

    alexhy

    Joined:
    Nov 21, 2013
    Posts:
    26
  4. Deleted User

    Deleted User

    Guest

    Because, I don't know the technical reason for it, I think it's more to do with that the scene keeps track of it all and sets the object what to use rather than the object and that's why it's not tracked when prefabbed. You'd need a script on the object that stores the lightmap index and offset etc and set them on Start(). Even then that'd be scene dependant so you'd want it to track what lightmap index goes with what scene name (meaning you'd have to bake it and set it in every scene that prefab would go in). I do have a script that does that somewhere but it ended up causing weird lightmap issues after a rebake, although I think that was to do with "Generate Lightmap UVs" unchecked in the model import settings. Can't find it at the moment though, but it was basically a List of all the scene names and a List of all the lightmap indexes etc that shared the same [] index.
     
  5. alexhy

    alexhy

    Joined:
    Nov 21, 2013
    Posts:
    26
    Same operation on unity 4.xxx is correct.