- Home /
How do I Rotate a Skybox's Material
How can I rotate a skybox's material so it simulates slow movement of the sky? Does anyone have a script that does this? I have a script that can animate UV's but it won't let me apply it to a material or a skybox.
Below is the UV animation script...maybe someone can modify it to animate the UV's of a skybox?
//Scroll main texture based on time
var scrollSpeed = 0.5;
function Update() {
var offset = Time.time * scrollSpeed;
renderer.material.mainTextureOffset = Vector2 (0,offset);
renderer.material.mainTexture.wrapMode = TextureWrapMode.Repeat;
}
Any help is greatly appreciated. Thanks!
Shawn
Hey, by the way, the 10101 button up top is the code button =) thanks for attempting haha, hope you find something!
haha ya I inserted my text inside the quotes for the code...but it kept refusing to properly format...do I need to do anything specific to get them formatted properly? thanks for your help, I appreciate it
Answer by DaveA · Mar 29, 2011 at 12:11 AM
This may interest you: http://answers.unity3d.com/questions/14461/how-do-i-make-a-moving-skybox
I'm pretty sure the Asset Store has a nice plugin for doing what you want.
Thanks, but I'm not looking to spend any money. I appreciate the advice.
I didn't want to downvote you. =( This should have been an upvote. I do appreciate your help. I am sorry. It won't let me remove the downvote either. So I accepted it as a correct answer ins$$anonymous$$d. I hope you understand.
Answer by ConstantineM · May 21, 2013 at 03:01 PM
Sorry for digging up an old question that is also answered, but i would like to contribute my solution too.
What i did was to create a second camera, set the depth to be less than the depth of the main camera, at the main camera i set clear flags as "depth only" while the second camera would have clear flags set as "Skybox". then a simple script for the second camera's rotation and you get the effect that you want.
Thank you, I had no clue on how to do this until I tried your solution and it worked. I just created an account here to say thanks to you.
Great solution! Easy and works well. FYI i had to set the camera's culling mask to nothing as well.
$$anonymous$$y god constantine that's brilliant! Why can i only upvote once?!
Wonderful!
Except that I am having some issues with it while in mouselook... Trying to figure out a way to disable it moving with the main cam :)
Answer by Justin Warner · Mar 28, 2011 at 11:43 PM
Of what I've read... You have skyboxes thought out wrong... It's not as easy as just moving it... Like clouds are very complex...
http://unity3d.com/support/documentation/Components/class-Skybox.html
I recommend reading up on it...
Also, this place has some good info on it:
http://www.unifycommunity.com/wiki/index.php?search=skybox&go=Go
But yeah, I'd rather you read it than I explain it wrong, but I might be wrong, but meh.
Good luck! =).
Ya I've read all of those. I've looked everywhere. I understand Skybox's and the multiple ways to create them. I just don't know how to animate the actual textures of the skybox to simulate movement. Thanks for the links though, I appreciate it.
$$anonymous$$
http://answers.unity3d.com/questions/14461/how-do-i-make-a-moving-skybox That might help... Also, I remember reading something of a group making like, a cloud package that lets you add in moving clouds and stuff... I had it a while ago, lost it last crash though, BUT, you also have to tweak the cameras, they made it a little hard to work out, but I got it in like 20 $$anonymous$$. Just aggravating... $$anonymous$$aybe you can find it?
Answer by blueknee · Oct 03, 2016 at 06:01 AM
It's fairly simple actually.
If you are using built in "Skybox/6 Sided" shader, modify "_Rotation" property.
Skybox skybox;
void Update()
{
skybox.material.SetFloat("_Rotation", Time.time * 10);
}
If you want to do it with cubemap, copy and paste the code from built in shader "Skybox.shader" available in unity archives.
Your answer
![](https://koobas.hobune.stream/wayback/20220613115417im_/https://answers.unity.com/themes/thub/images/avi.jpg)