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 frevd · Mar 21, 2015 at 08:06 PM · unity5lightmapsasset bundle

Unity5: Export Asset Bundle with Lightmaps

I used to be able to export lightmaps using the following code, but with the new Enlighten there seem to be no more lightmap assets to package.

Any idea how to do it now?

 // Bring up save panel
 string path = EditorUtility.SaveFilePanel("Save Resource", lastDir, "unnamed", "unity3d");
 if (path.Length != 0)
 {
     lastDir = System.IO.Path.GetDirectoryName(path); 
     // Build the resource file from the active selection.
     List<Object> selection = new List<Object>(Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets));
     string curScene = EditorApplication.currentScene; 
     string[] parts = curScene.Split('/', '\\'); 
     curScene = parts[parts.Length - 1].Split('.')[0]; 
     foreach (Texture2D tex in Object.FindObjectsOfTypeIncludingAssets(typeof(Texture2D)))
         if (tex.name.StartsWith("Lightmap"))
         {
             string[] p = AssetDatabase.GetAssetPath(tex).Split('/', '\\'); 
             if ((p.Length > 1) && ((p[p.Length - 2] == curScene) || (p[p.Length - 2] == "anyscene")))  // if it is a lightmap for the current (or any) scene
                 selection.Add(tex); 
         }
     BuildPipeline.BuildAssetBundle(Selection.activeObject, selection.ToArray(), path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, platform);
     Selection.objects = selection.ToArray();
 }
 


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 frevd · Mar 21, 2015 at 08:29 PM

Apparently I can get the textures directly from LightmapSettings.lightmaps and then, since they are no assets, use AssetDatabase.Create to save them as files..

Except that those textures are in an internal format and not marked as readable, so I cannot save and load or re-encode them in another format.

Does anybody have any idea how to export Lightmaps? Unity5 breaks my project for no reason.

Comment
Add comment · Show 2 · 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
avatar image eyalfx · Apr 21, 2015 at 01:24 PM 0
Share

same problem here. Looking for a solution. Did you find a work around?

avatar image eyalfx · May 06, 2015 at 02:41 PM 0
Share

yep, same here.

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

22 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How the heck can I include Lightmapping data in unity 5 asset bundles??? 3 Answers

Using the Lightmap UV texcoords in a Unity 5 Surface Shader? 1 Answer

Upgrading from 4 to 5 0 Answers

SetTexture Not Working In Unity 5 1 Answer

Problem to go to another world scene in level select lock/unlock 0 Answers


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