I modified the script a bit so I didn't have to assign the lightmap mesh manually for every character in every scene. Now just create a new tag named "LightMap2D" and add it to the mesh with the light map, and it will choose it automatically.
First, copy the script I linked above and in your project create a C# script called LightMap2D, then paste the content into it.
Now, apologies if this is too basic, but I'll write it down for anyone who's interested.
Paint a lightmap which matches up with the background, the colour and brightness used will tint the character accordingly:
Make sure the texture is set to Advanced in the Inspector and that Read/Write Enabled is checked.
Now you have to create a 3D Plane in the scene, drag the lightmap texture onto it and rotate and scale the plane so it lines up with the background image:
Select the 3D Plane with the lightmap, and in the Inspector you open the Tag dropdown menu, add a new tag called LightMap2D, and make sure you choose it for the 3D Plane.
Lastly, select the sprite of your character, add a new component and select Light Map 2D. Do this with every character who should be affected by the lightmap.
Now, as long as each lightmap plane is tagged properly in each scene the lightmap should be used automatically.
Thanks for the improvement with the tag that's interesting. The only situation where it's not cool is if you want to have different lightmaps for different objects, even if in most cases it won't happen.
Could still make a mix with a default tagged lightmap but keeping an optional parameter for a "custom" lightmap. I might do that and post it here.
You are right! I actually added that to my own script an hour after posting that along with the ability to toggle using a lightmap at all, but I was hesitant to post it here because of my horrible "code". It seems to be working though so I updated the pastebin with the changes.
@ChrisIceBox: Not my code, I just made some modifications It's a mutation from the code posted previously in this thread, but I think it all originates from this Unity Answers:
@ChrisIceBox It's a nice idea as it's a common need for adventure games. We all tried to make something easy to use with the informations everyone gave here. If you find a nice way integrate it to AC that would be cool. And feel free to improve it if you have other ideas.
Comments
Thanks for the improvement with the tag that's interesting. The only situation where it's not cool is if you want to have different lightmaps for different objects, even if in most cases it won't happen.
Could still make a mix with a default tagged lightmap but keeping an optional parameter for a "custom" lightmap. I might do that and post it here.
Extracting RGB component data from a textured plane positioned below a 3D terrain