Search Unity

Attach Skybox to gameComponent

Discussion in 'Scripting' started by dansav, Apr 22, 2008.

  1. dansav

    dansav

    Joined:
    Sep 22, 2005
    Posts:
    510
    I have a universal script worldsetup.js attached to a gameObject called CSB. There is nothing in the gameObject. This container CSB represents the world.

    I have found the command this.gameObject that refers to the object that the script is attached to, that is helping. I still don't know how to change the skybox material though.

    The new code is
    csb=this.gameObject;
    csb.addComponent(Skybox);
    myskybox=csb.GetComponent(Skybox);
    myskybox.material = "Sunset";


    Thanks,

    Dan
     
  2. JavaChilly

    JavaChilly

    Joined:
    Mar 8, 2008
    Posts:
    33
    Each Scene in Unity can have a different skybox.

    Its in the Render Settings, under the Edit menu.

    Via script, its accessed like 'RenderSettings.skybox = Material';