- Home /
Assign skybox in script
I am creating a gameObject in code and I want to assign a camera and a skybox to it. I'm doing it like this, but I don't know how to find a skybox texture in the standard assets:
GameObject go = new GameObject("ExtraCam", typeof(Camera));
go.AddComponent<SkyBox>();
go.GetComponent<SkyBox>().material = x; // the standard cubemap material from Standard Assets?
I can't find an equivalent for something like: Material.Find();
.
Answer by Marnix · Nov 09, 2011 at 10:58 PM
I found out that you can also create materials that have a skybox. You need to use the shader of RenderFX/SkyBox
and create a simple material with the skybox attached. This can than easily be accecced with Resources.Load()
.
Answer by demize2010 · Apr 08, 2011 at 09:57 AM
You'll need Skybox.material:
http://unity3d.com/support/documentation/ScriptReference/Skybox.html
@demize: Yes I know about skybox.material, but where do I get x? How do I find a material in my complete assets folder?
Answer by Jeliel · May 24, 2012 at 05:28 PM
You can use x = Resources.Load("path");
to load the material but for this you need to create and folder called Resources in your assets folder!
Your answer
![](https://koobas.hobune.stream/wayback/20220613121535im_/https://answers.unity.com/themes/thub/images/avi.jpg)