Resources.load "object reference not set to an instance of an object unity",Resources.Load doesnt load 2d texture

Hey,

I try to load a simple png (“Assets/Player.png”) and paste it in a sprite which I’ll then spawn in the world.

When I use Texture2d.whiteTexture everything works fine. But as I want to give the player a skin I tried this:

Texture2D tex = Resources.Load("Player") as Texture2D;
playerSprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.0f, 0.0f));

The error is happening in tex.width and tex.height. If I change it to “1f” for example, I don’t get an error, but there is still nothing happening.

Any clues?

I got it my friends:

The problem was, the png was in “Assets/Player.png”. Not in “Assets/Resources/Player.png”.