unity3d - Unity C#- dynamic skyboxes, get no errors but doesn't work -
after lots of googling have gotten c# code compile without errors, still isn't working. ie skybox isn't changing.
i've confirmed pathing correct.
think must have how referencing skybox. understanding there 2 ways change, update skybox via code. 1 via rendersettings.skybox , other referencing skybox on main camera. using former approach. following code on empty game object. can 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; (int = 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; (int = 0;i < 6; i++) { // wait until download 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 named: // "beach_fronttex.png" // "beach_backtex.png" // ... } }
Comments
Post a Comment