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.

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.

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.

The script should be in both scenes.

Resolved.