Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by VoxGuy · Jul 30, 2013 at 02:11 PM · lightmaploadleveladditive

LoadLevelAdditiveAsync + Lightmap index

Hi guys,

I have 2 Levels. A level is a group of scene. A level is loaded using LoadLevelAdditiveAsync() for each scene in the level. When one level is completely loaded, I unload the previous level by using Destroy() on the Root GameObject of each scene in the level.

Most scenes have lightmap generated by the tools in unity (Window > lightmapping).

When I launch the game, level 1 is loaded, everything is fine. LightmapSettings.lightmaps.Length equals 11 and if I look at renderer.lightmapIndex for an object it says 6. I load level 2, each scenes of level 1 are destroyed (they do not appears in the Hierarchy anymore). LightmapSettings.lightmaps.Length equals 9x wich is ok, LightmapSettings.lightmaps should now contains all my lightmap.

The problem is when I load level 1 again. Level 2 is destroyed fine (again, no scene from the level 2 appears in the Hierarchy). But LightmapSettings.lightmaps.Length is now equals 101 and my object wich had a lightmapIndex of 6 has now a lightmapIndex of 96.

To put it simply, each time I load a level, the LightmapSettings.lightmaps array is growing and when the length reach 255, my objects have a lightmapIndex of -1.

I tried to clear the Lightmap array but it kinda broke the lightmapIndex of my objects.

I don't know if I just unload my level incorrectly or I should just manage the Lightmap array and the lightmapIndex of all my objects manually (hopefully not).

I searched for a similar problem and the closer I found was this post but there's no solution. http://forum.unity3d.com/threads/92169-LoadLevelAdditive-and-Beast-lightmapping

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by mrekuc · Sep 12, 2013 at 02:43 PM

http://answers.unity3d.com/questions/130316/removing-unused-lightmaps-after-level-unload.html

LightmapSettings.lightmaps = new LightmapData[0]; Resources.UnloadUnusedAssets();

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Removing unused lightmaps after level unload 2 Answers

Unity light mapping does't output any map 1 Answer

How to bake several objects into one lightmap with beast? 0 Answers

cast shadow - export lightmap from 3ds max to unity 2 Answers

How to import existing lightmaps for use with Beast? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges