consecutive Resources.Load("asset") problematic ?

Just a quick question:

considering i want to load a Prefab from the resources folder. Is consecutive use of Resources.Load( myasset ) problematic and should i take care that i call it only once. Or does the function care for itself that resources are only loaded once ?

any chance for some quick thought or insight please :smile:

thx

I don’t think the function takes care by itself if you load twice the same resource.

But that should be an easy workaround by just checking if you already did it.

I needed to know, so I did this :

class CEntity
{
	[...]
	internal string m_Model;
	internal UnityEngine.Object m_Obj;

	internal UnityEngine.Object GetObj()
	{
		if (m_Obj == null)
		{
			m_Obj = Resources.Load("Models/" + m_Model, typeof(GameObject));
			Debug.Log("Loaded '" + m_Model + "' at " + m_Obj.GetInstanceID());
		}

		return m_Obj;
	}

Called it twice with 2 different entities using the same model and got the same ID for m_Obj, so Unity likely handles correctly this internally and doesn’t load the resource twice.