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
1
Question by Xyex Development · Jun 11, 2014 at 06:14 AM · lighting bughorrorlightmapsindie

Can you remove lightmaps at runtime through scripts?

I am scripting a scene in my game where when the player enters a trigger all the lights go out. The script works, but rather than the room becoming completely black, you can see the light dim, but the lightmaps are left behind. Is there a way to remove these lightmaps at runtime to actually kill the lights upon reaching the trigger?

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
2
Best Answer

Answer by HarshadK · Jun 11, 2014 at 06:15 AM

What you are looking for is Renderer.lightmapIndex

The documentation states that

The index refers to lightmaps array in LightmapSettings class. A value of 255 means no lightmap has been assigned, which is the default.

So you can set the lightmapIndex to be 255 when you want to turn off the lightmaps.

Comment
Add comment · Show 7 · 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 Xyex Development · Jun 12, 2014 at 05:09 AM 0
Share

Could you possibly explain this? I read up on it but I don't quite understand how I am supposed to use it.

avatar image HarshadK · Jun 12, 2014 at 05:28 AM 0
Share

This forum post about Turn "Use Lightmaps" off via script? has the explanation and code required by you.

Also check for the code by @fenderrio which uses the method of setting the data of lightmaps to null.

avatar image Xyex Development · Jun 12, 2014 at 05:31 AM 0
Share

The problem is that it references level.Renderer.lightmapIndex, without explaining that game object which is tied to "level".

avatar image HarshadK · Jun 12, 2014 at 05:54 AM 0
Share

The game object named level is one of the objects which is assigned the lightmap.

But in the code below from the same forum:

 function TurnLight$$anonymous$$apsOff (){
     var children = level.GetComponentsInChildren (Renderer);
     for (var child: Renderer in children){
         originalLight$$anonymous$$apIndex = child.renderer.lightmapIndex;
         Debug.Log (child.renderer.lightmapIndex);
         child.renderer.lightmapIndex = -1;
     }
 }

It looks like all the game objects that have light map are children of an empty game object named level.

avatar image iwaldrop · Jun 12, 2014 at 06:09 AM 1
Share

Fenderrio's method would be my preferred approach.

Show more comments

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How to make a image flash infront of the camera 1 Answer

Transforming Lightmaps at Runtime 1 Answer

How to import the object from server to unity 2 Answers

Material doesn't have a color property '_Color' 4 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