Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Tarikm · Jan 22, 2015 at 03:41 PM · materiallerpskyboxrendersettings

Lerp RenderSettings skybox

I want to switch my skybox from a day material to a night material for this I use :

 Material night;
 int skyboxflag = 0;
 int flag = 0;
 float t;
 public float smooth = 1;
 
 void Start () {
     night = Resources.LoadAll("Night_mat",typeof(Material))[0] as Material;
 
 }
 
 void Update () {
 if (skyboxflag == 1) {
         if(flag == 0){
             t = Time.time;
             flag = 1;
         }
         RenderSettings.skybox.Lerp(RenderSettings.skybox, night,(Time.time - t)/smooth);
         if(Time.time - t > smooth){
             skyboxflag = 0;
         }
             }
 }
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.name == "Avatar") {
         skyboxflag = 1;
 
             }
     }

but nothing happens I keep having the day skybox.

what is the correct way to change the skybox smoothly from a material to another

Thank you

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by chaozz · Mar 06, 2015 at 12:35 PM

I have the same problem in Unity 5. I was using http://wiki.unity3d.com/index.php?title=SkyboxBlended in Unity 4, but that shader no longer works in Unity 5. Does anyone have an idea how to do skybox blending in Unity 5?

EDIT: Found a fix!

This Skybox Blending shader works in Unity 5. http://answers.unity3d.com/questions/371078/having-a-changing-skybox-depending-on-location-of.html

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

Answer by pronobroy · Jun 15, 2016 at 06:19 AM

using UnityEngine; using System.Collections;

public class dayknight : MonoBehaviour {

 public Material mat;
 public Material day;
 public Material skyBox;
   

 float t = 0.02f;
 float a;
 // Use this for initialization
 void Start ()
 {
        RenderSettings.skybox.Lerp(skyBox, mat, 0.5f);  //Here assaying mat matiral as default .
 }
 
 // Update is called once per frame
 void Update ()
 {
         a = (Time.time *4) % 360;

         transform.eulerAngles = new Vector3(transform.rotation.x + a , transform.rotation.y, transform.rotation.z);

       
         if(a > 25 && a < 150 )
         {
            //Changing default to day matiral skybox.
             RenderSettings.skybox.Lerp(skyBox,day,0.5f * Time.deltaTime); 
         }
          
        else if (a > 150 && a < 185)
         {
             //Changing day matiral to mat matiral
             RenderSettings.skybox.Lerp(skyBox,mat,0.5f*Time.deltaTime);
         }
 }

}

Hope that it will help you!!!!!!

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 qwert024 · Jun 20, 2016 at 12:09 PM 0
Share

@pronobroy Hi! I encounter a problem when using RenderSettings.skybox.Lerp. The link below shows the same problem with $$anonymous$$e. It seems to work only once. http://forum.unity3d.com/threads/rendersettings-skybox-lerp-not-cooperating.287566/ So now I am using Color.Lerp and then set the color to my skybox.

avatar image
0

Answer by jampakdd · Feb 09, 2020 at 01:16 AM

@Tarikm I just made a video about this because a lot of people are saying it's not possible to do in script but it definitely is!

https://www.youtube.com/watch?v=d-cq9ufhkIg&feature=youtu.be

I hope this video is helpful to people!

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

6 People are following this question.

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

Related Questions

renderer.material.lerp() doesn't work in unity 1 Answer

Skybox always black on MacOS 0 Answers

How to rotate a skybox in relation to the camera 0 Answers

Use Skybox material on Cube 0 Answers

How to lerp smoothly between two numbers? 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