AssetBundle Instancing Question

Dumb question - So I’ve created a C# script called ResourceLoader which handles all the WWW stuff to load in an AssetBundle from anywhere outside of the game’s own resources when something dawned on me about how I was using this script.

Basically, this script has turned into a spawn point of sorts, I place an empty game object somewhere in the scene, attach this script and fill in the name of the resource to load, upon running the game the resource is loaded in, scripts attached, game starts, yay.

My question is though, often times I will have multiple of the same loaded resource out in the scene, where I’ve created like 3 or 5 spawn points with this script attached but all have been instructed to load the same resource - is Unity aware that while all of them were loaded externally that they are the same thus instancing these? Or are each of these loaded objects taking up memory and thus redundant duplicates?

If these are redundant, is there any suggestions about how I might keep that from happening so that if I place 20 of these spawn points it will still only load the resource identified once and instance it for each?

So, assuming that these resources are redundant, I’ve started creating a resource loader script of static methods that I can call LoadResource on which will check a list to see if the resource named has already been loaded, if so it returns a new instance otherwise it loads the resource then returns a new instance.

But I am having problems with this so far, Unity hates the idea of creating a class that doesn’t extend Monobehaviour but wants to use StartCoroutine and stuff. I’ve tried making it extend Monobehavior but it still complains about the StartCoroutines, if I make the functions non static it shuts up, but I really need this stuff to just sit there statically, not have to attach it to game objects. The errors I keep getting are “UnityEngine.MonoBehavior.StartCoroutine(System.Collections.IEnumerator): An object reference is required for the nonstatic field, method or property”

Code below - Is this an error I have in my C# or a Unity no no - any ideas would be very helpful???

using UnityEngine;
using System.Collections;

public class Bundle
{
	public string Name;
	private AssetBundle assetBundle = null;
	
	public Bundle()
	{}
	
	public GameObject GetNewInstance()
	{
		// Create an instance of this
		// resource and return it
		Object o = assetBundle.mainAsset;
		
		if(o)
		{
			GameObject NewInstance = (GameObject)MonoBehaviour.Instantiate(o);
			Debug.Log("ResourceManager: Created new instance of `" + Name + "`.");
			return NewInstance;
		}
		
		Debug.Log("ResourceManager: Could not instantiate `" + Name + "`!");
		return null;
	}
}

public class ResourceManager
{
	public static string ResourcesLocation = "http://thewebsite.com/resources/";
	
	private static ArrayList Bundles = new ArrayList();
	private static WWW BundleLoader = null;

	public static GameObject GetInstanceOf(string ResourceName)
	{
		// First check to see if this resource has already been
		// loaded, if so, return a new instance of it, otherwise
		// kick off a load, then get an instance and return that.
		foreach(Bundle bndle in Bundles)
		{
			if(bndle.Name == ResourceName)
				return bndle.GetNewInstance();
		}
		
		// If we got here, the resource
		// has not yet been loaded.
		Debug.Log("ResourceManager: `" + ResourceName + "` not found, starting load.");
		
		Bundle newBundle = new Bundle();
		newBundle.Name = ResourceName;
		Bundles.Add(newBundle);
		MonoBehaviour.StartCoroutine(ResourceManager.LoadResource(newBundle));
		Debug.Log("Load done!");
		return newBundle.GetNewInstance();
	}
	
	public static IEnumerator LoadResource(Bundle bndle)
	{
		yield return MonoBehaviour.StartCoroutine(ResourceManager.IEnumLoadResource(bndle));
	}
	
	public static IEnumerator IEnumLoadResource(Bundle bndle)
	{
		BundleLoader = new WWW(ResourcesLocation + bndle.Name + ".unity3d");
		yield return BundleLoader;
	}
}