Loading External Levels

Hello wise and benevolent ones;

I would like to be able to load externally residing levels for the sake of easy expansion and updates. Thus the Application.LoadLevel doesn’t seem like the tool for me, since all levels have to be defined before the build process. Currently, I am trying to use the Resources folder and Resources.Load() to load a prefab file I create in a seperate unity project:

GameObject currentLevel = (GameObject)Instantiate(Resources.Load( levelPrefabPath );

The Level’s GameObject Hierarchy gets loaded properly, but all the components (meshes, textures, scripts, etc) are missing.

Is there any way to properly load a prefab, unityPackage or other something at runtime?

Any alternative approaches to what I’m doing?

Thanks so much!

Anyone? Unity Gurus?

Sorry for the trouble

Hey, thanks podperson =). The documentation doesn’t exactly address my need, but I really appreciate the gesture!

Some possibly interesting info: When I run the following block of code:

		string levelPrefabPath = "Levels/" + folderName;// + "/level";
		UnityEngine.Object[] prefabAssets = Resources.LoadAll( levelPrefabPath );

		int tempIndex = 0;	
		UnityEngine.Object levelObject = null;
		foreach( UnityEngine.Object obj in prefabAssets )
		{
			Debug.Log("Object: " + tempIndex + " " + obj + " " + obj.GetType() );	
			if( obj is UnityEngine.GameObject  levelObject == null )
			{
				levelObject = obj;	
			}
			tempIndex++;
		}

		if( levelObject != null )
		{
			Debug.Log("Level found: " + levelObject );	
			currentLevel = (GameObject)Instantiate( levelObject ); 
		}
		else
		{
			Debug.Log("Error: Level Not Found!");		
		}

It actually prints out each of the items that I load and I know what kind of item it is (Texture2D, GameObject, etc) AND each item is listed IN THE SAME ORDER as it is in the folder. And I’m able to successfully load my prefab (the first GameObject in the list by design), but all the components are still missing. Too bad- we know everything about everything we load except the relationships between them! I suppose I could manually reassign each component based on where I know it is in the folder, but that is so fragile and arduous, I think I’ll pass and wait for dynamic scene loading support from the Unity Pros.

In the mean time, I’m going to write a simple launcher in C# to handle the loading of different Unity projects. It’s a little unfortunate since there will definitely be some redundant asset use, but otherwise it should make game expansions easy to implement.

Cheers and thanks for your time!