After lots of googling have gotten my C# code to compile without any errors, but it still isn't working. ie my skybox isn't changing.
I've confirmed that my pathing is correct.
I think it must have something to do with how I am referencing the skybox. My understanding is that there are essentially 2 ways to change, update a skybox via code. One is via RenderSettings.skybox and the other is by referencing the skybox on the Main camera. I am using the former approach. The following code is on an empty Game Object. Can any Unity C# gurus help?
using UnityEngine;
using System;
using System.Collections;
public class LoadSkyBox : MonoBehaviour {
private readonly string[] skyboxTextures = {"_FrontTex", "_BackTex", "_LeftTex", "_RightTex", "_UpTex", "_DownTex"};
IEnumerator LoadImg (String skyboxName){
WWW[] www = new WWW[6];
String tempStr;
for (int i = 0;i < 6; i++)
{
tempStr ="file://"+ Application.streamingAssetsPath + "/" + skyboxName + skyboxTextures[i] + ".png";
Debug.Log("tempStr ="+tempStr);
www[i] = new WWW(tempStr);
}
//Material mat = GetComponent<Skybox>().material;
for (int i = 0;i < 6; i++)
{
// wait until the download is done
yield return www;
//mat.SetTexture(skyboxTextures[i],www[i].texture);
RenderSettings.skybox.SetTexture(skyboxTextures[i],www[i].texture);
}
}
void Start () {
StartCoroutine(LoadImg("beach"));
// Images should be named:
// "beach_FrontTex.png"
// "beach_BackTex.png"
// ...
}
}