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
2
Question by saldavonschwartz · Jun 05, 2015 at 01:03 AM · shaderunity5cubemap

Accessing Unity 5 Environmental Lighting Skybox from C# script

I'm trying to rotate a cube map skybox at runtime. Since the 'Skybox/Cubemap' shader already exposes a 'Rotation' uniform, I thought I could just write a script along the lines of:

 public class Clouds : MonoBehaviour {
     int step = 1;
 
     void FixedUpdate () {
         step += 1;
         step %= 360;
         Material skybox = RenderSettings.skybox;
         skybox.SetInt ("Rotation", step);
     }
 }
 

The idea being that it should be like manually moving the 'Rotation' slider for the cubemap shader from the inspector. But when doing it thru the code above, the parameter doesn't seem to update. Any thoughts on what am I doing wrong?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by jenci1990 · Jun 05, 2015 at 09:25 AM

 Material skybox = RenderSettings.skybox;
 skybox.SetInt ("Rotation", step);
 RenderSettings.skybox = skybox;
Comment
Add comment · Show 1 · 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 saldavonschwartz · Jun 06, 2015 at 10:34 PM 0
Share

That seems to do it. Thanks. But, why do I have to reassign the material? And, if it is indeed resigning the material, isn't that super inefficient? As in, the whole idea was that I could just tweak a shader uniform and now it looks like I have to constantly reassign the whole material which seems like it would entail reloading the shader program. Am I wrong?

avatar image
1

Answer by djon801 · Sep 30, 2015 at 08:50 AM

      step += 1;
      step %= 360;
      Material skybox = RenderSettings.skybox;
      skybox.SetInt ("_Rotation", step);

"Rotation" = " _Rotation"

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

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

Failed to find compatible Skybox shader 1 Answer

How to tint the specular map in Unity5 0 Answers

Need help with a shader that uses additive particle blending (worked in 4.6; broken in unity 5): 0 Answers

Control cubemap reflection amount from metallic and smoothness properties 0 Answers

Unity 5: Water Shader and Fog Not Rendering 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