- Home /
Question by
Iceblitzyt · Aug 26, 2013 at 04:42 PM ·
c# dll
How can i load resources with a path?? c#
So im trying to load resources with a certain path.
I'm currently doing this: using UnityEngine; using System.Collections;
public abstract class SpellDataBase {
private string TexturePath = "GameArt/SpellIcons/";
public Texture2D icon;
private PlayerHUD owner;
public abstract void Cast();
public class FireBall : SpellDataBase
{
public FireBall(PlayerHUD owner)
{
this.owner = owner;
this.icon = Resources.Load(TexturePath + "FireBall") as Texture2D;
}
public override void Cast()
{
Debug.Log("FireBall casted...");
}
}
}
But I get no luck, can someone please assist me. I tried looking on the forums, but the fixes don't work.
Comment
Also curious about this, only way I could get Resources.Load to work was to have the assets in a folder at the root level called "Resources".
I answered the duplicate question here. @incendy that is the solution. Resources.load only loads from that folder
Best Answer
Answer by wiiarethesound · Aug 27, 2013 at 12:21 AM
Resources.Load() will ONLY look at folders named Resources. The Resources folder doesn't have to be at the root (Assets/Resources), but I always find it to be a best practice to keep it there.