- Home /
RenderSettings in AssetBundles
I've got streamed scene loaded by Application.LoadLevelAdditive function.
It works fine by I lost all RenderSetting, no SkyBox and Fog.
I've tried to create Game Object with script that contains RenderSettings info and update this after loading as here:
http://answers.unity3d.com/questions/1311/do-streamedscenes-contain-rendering-settings-data
But AssetBundles can't contain scripts and this example doesn't work.
I've tried this example too http://angryant.com/2010/01/05/downloading-the-hydra/ If I get this right I've got to create dll from my original class, so I took the class from the first example and created dll.. but what's next? I can't attach it to Game Object and can't export it to AssetBundles
Please help.
Answer by jonas-echterhoff · May 25, 2010 at 08:50 PM
While you cannot make scripts contained in an AssetBundle, what you can do is to make a script to set up your RenderSettings in Start(), and set up the parameters for that script as member variables. Then you set up a prefab GameObject, where you set up the correct parameters as an inspector. This prefab can be added to an AssetBundle just fine - or directly to the level you want to load. That way, you don't actually store the script in the AssetBundle, but the data which the script uses, which is all you need.
Answer by Oleg · May 25, 2010 at 09:27 PM
Thank you for so fast answer. Here is my script:
using UnityEngine;
public class RenderSettingsController : MonoBehaviour { public bool fog; public Color fogColor; public float fogDensity; public Color ambientLight; public float haloStrength; public float flareStrength; public Material skybox;
void Start()
{
RenderSettings.fog = fog;
RenderSettings.fogColor = fogColor;
RenderSettings.fogDensity = fogDensity;
RenderSettings.ambientLight = ambientLight;
RenderSettings.haloStrength = haloStrength;
RenderSettings.flareStrength = flareStrength;
RenderSettings.skybox = skybox;
}
}
I created an Empty GameObject, and attached this script. Then assigned all variables, added an Empty Prefab and dragged the GameObject to it.
Now I use BuildPipeline.BuildPlayer to export all scene to AssetBundles and Application.LoadLevelAdditive to load it:
WWW stream = new WWW("url"); AssetBundle ab = stream.assetBundle; Application.LoadLevelAdditive("Scene_name");
After that I see my RenderSettings GameObject with all variables assigned but it looks like Start() function never works and my RenderSettings never get changes.
Do a Debug.Log() to see if Start really hasn't been called - that would be sort of strange, though. Have you tried putting the GameObject directly into the scene you are loading?
Your answer
Follow this Question
Related Questions
Loading game objects dinamycaly 1 Answer
Building asset bundles with dependencies in the player build? 2 Answers
How do i define BuildPlayerOptions.assetBundleManifestPath without a custom script? 0 Answers
Why is my AssetBundle causing "Exception: WWW download had an error:Invalid Unity Web File" 0 Answers
Webplayer displays garbage on Application.LoadLevel 0 Answers