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 Zeko_Aliraqi2012 · Nov 13, 2014 at 06:04 PM · javascriptmaterialchangeskybox

change skybox via script help ?

Hey i'm trying to change the skybox material via javascript . i make this(down below) script and for some reason it's not working !! can anyone help me plz ! this is the script that i'v made ------------------------------------------------------------------------->

 #pragma strict
 
 var dayMaterial:Material; 
 var nightMaterial:Material;
 var Timer : float = 20.0;
 RenderSettings.skybox = dayMaterial;
 
 function update()
 {
 Timer = Time.deltaTime;
 if(Timer <=20.0)
  {
 RenderSettings.skybox = dayMaterial;
  }
 
 if(Timer <=10.0)
  {
  RenderSettings.skybox = nightMaterial;
  }
 }
 

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

Answer by MrSoad · Nov 13, 2014 at 06:06 PM

This will do roughly what you want, its is cut down version of your script and will change from your current skybox to the one selected in this script(in the inspector box for the material var) after 10 seconds. I have fixed all your errors and you should be able to build upon this for your specific needs. I've left the Timer var as public so you can see what is happening to it in the inspector window when running.

 #pragma strict
 
 public var mNight_Sky : Material; 
 public var Timer : float = 10f;
 
 function Update() {
 
     if (Timer > 0) {
         Timer = Timer - Time.deltaTime;
     }
     
     if (Timer <= 0f) {
         RenderSettings.skybox = mNight_Sky;
     }
 }
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 Zeko_Aliraqi2012 · Nov 14, 2014 at 10:36 AM

Wow it's really working thnx bro (MrSoad) ! if anyone want the new script for changing the sky box here it is ! Dose anyone know how to fade it like when it change not like booom it's changed > i want to fade it like bring down the skybox opacity with time !

 #pragma strict
 
  public var Night_Sky: Material;
  public var Day_Sky: Material;  
  public var Timer : float = 20f;
  
  function Update() {
  
      if (Timer > 0) {
          Timer = Timer - Time.deltaTime;
      }
      
      if (Timer <= 10f) {
          RenderSettings.skybox = Day_Sky;
      } 

      
      if (Timer <= 0f) {
          RenderSettings.skybox = Night_Sky;
      }
  }

 

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 MrSoad · Nov 14, 2014 at 11:23 AM 0
Share

That is quite a lot harder, but if you don't $$anonymous$$d having a go at C# then take a look at this series of Video Tutorials that I found recommended on a post here when I was looking for the same thing :

http://www.youtube.com/watch?v=FTfv9JhkmIA

http://www.youtube.com/watch?v=Fmbi5uE7Bb4

These are vid's 3 and 4 which should show how to do this if I remember right(you are prob best starting form vid 1 though), think you also have to do some shader editing if I remember right.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

change a material from multiple materials 1 Answer

how do you change a skybox material by name 1 Answer

Help Changing Materials On Button Click 0 Answers

Changing materials with array 0 Answers

Change Material in other Scene by Scripting 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