Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Boo] Skybox not change

Discussion in 'Scripting' started by Kurt1996, Dec 3, 2012.

  1. Kurt1996

    Kurt1996

    Joined:
    Nov 30, 2012
    Posts:
    3
    Hi guys, I have variable name is sayi. This is sayi variable type to int. Simple if control. But skybox material isn't change. My code;

    PHP:
    import UnityEngine
    import System
    .Collections

    class Gokyuzu (MonoBehaviour): 

        
    def Start ():
            
    as int 0
            gok 
    as Skybox
            gok
    .enabled true
            
    if == 0:
                
    gok.material("Sunny1 Skybox")
            else:
                
    gok.material("DawnDusk Skybox")
        
        
    def Update ():
            
    pass
    How do you change skybox material? Thank you advanced for interest, now.

    Good work..
     
  2. shinriyo_twitter

    shinriyo_twitter

    Joined:
    Aug 12, 2011
    Posts:
    328
    Hi Kurt1996

    Boo is great language.

    I guess you didn't assign to gok, did you?
     
  3. Kurt1996

    Kurt1996

    Joined:
    Nov 30, 2012
    Posts:
    3
    Hi shinriyo,
    I want change Edit->Render Settings->Skybox Material
     
  4. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
  5. Kurt1996

    Kurt1996

    Joined:
    Nov 30, 2012
    Posts:
    3
    But How do I script control?
     
  6. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    The same way you have above I presume.

    The component will just give you something to reference
     
  7. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    Here's a c# version I just wrote and tested. Dont know boo though, so you can either just have a c# script in your project or convertit.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5.  
    6.  
    7. public class SkyController : MonoBehaviour {
    8.  
    9.     int index = 0;
    10.     Skybox _skybox;
    11.     public List<Material> SkyBoxes;
    12.     // Use this for initialization
    13.     void Start () {
    14.         _skybox = (Skybox)GetComponent(typeof(Skybox));
    15.        
    16.         InvokeRepeating("NewSky", 10,10);
    17.     }
    18.    
    19.     void NewSky()
    20.     {
    21.         if(_skybox == null || SkyBoxes == null)
    22.             return;
    23.        
    24.         if(SkyBoxes.Count == 0)
    25.             return;
    26.        
    27.         index++;
    28.         if(index == SkyBoxes.Count)
    29.             index = 0;
    30.        
    31.         _skybox.material = SkyBoxes[index];
    32.     }
    33. }
    34.