Changing lightmap index of objects

I really need to change the lightmap index of my objects in my scene, but it seems that it’s impossible in Unity 5, is there anyway to change this value?
[https://drive.google.com/file/d/0BwsPPskcQl7BVmtkWktjaWZBdG8/view?usp=sharing

](https://drive.google.com/file/d/0BwsPPskcQl7BVmtkWktjaWZBdG8/view?usp=sharing)

any ideas?

You get the rendering component of the gameObject and then just set it to whatever you want, for example:

MeshRenderer rend = GetComponent<MeshRenderer>();
rend.lightmapIndex = 2;

I’ve found it hit and miss though in Unity 5 as re-baking would usually mess it up for me (obviously), but ah well, that’s how you’d do it anyway.

Could you describe the steps?
I created a Csharp script and attached to the object, it didn’t work?

Are you putting it in Awake()? Apparently doesn’t work if you put it in there (I wasn’t aware of this, I always had it in Start() though)

Here is what I am writing:

using UnityEngine;
using System.Collections;

public class NewBehaviourScript1 : MonoBehaviour {

// Use this for initialization
void Start () {
MeshRenderer rend = GetComponent();
rend.lightmapIndex = 2;

}

// Update is called once per frame
void Update () {

}
}

Are there any error messages in the Console log? Here’s some slightly different code. After you’ve updated the code, inside the inspector drag and drop the MeshRenderer component into the slot of the script that says “rend” that you want to change the lightmap index of. Also note it can only be changed in Baked and Mixed modes, although going by your screenshot I assume that’s the case due to the value of lightmapindex for baked.

If this doesn’t work then I honestly don’t know, it’s the classic excuse of “well it’s working on mine” so starting to run out of answers. Although, you’re not just adding the script and checking to see if it has worked right? Because this would change it when you run the game. If you want it to change it inside the editor without playing then that’d require extra code…

using UnityEngine;
using System.Collections;

public class NewBehaviourScript1 : MonoBehaviour 
{
    public MeshRenderer rend = null;

    // Use this for initialization
    void Start ()
    {
        if (rend != null)
        {
            rend.lightmapIndex = 2;
        }
    }

    // Update is called once per frame
    void Update () {
    }
}

I get this error message when I drag the script to the objects.
"couldn’t add the script because the script class could not be found…
Yes, I really need this to work in the editor window.

I am also having the same issue, all I need is to manually set the lightmap index of an object. Please tell me that somebody found a solution?

This might be of use… Problems with instantiating baked prefabs - Unity Engine - Unity Discussions

couldn’t make it work…
Is that a script that selects a bunch of objects and put them in lightmap X?

the script posted in that post works half of the time and only at runtime.
All I need is a script that assigns manually objectX to lightmapX

Anyone solved this?

Have assigned the lightmaps using the SetLightmapsManually.cs but this info is lost on play and on build.