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?
Answer by lschurbuch · Feb 02, 2018 at 04:05 PM
I got it my friends:
The problem was, the png was in "Assets/Player.png". Not in "Assets/Resources/Player.png".
Your answer
Follow this Question
Related Questions
Resources.Load doesn't work 1 Answer
Use getPixel on a resource. 0 Answers
OpenGL textures always show up black 0 Answers
How to draw a texture on another texture 0 Answers
How to get rgb from Texture2D faster? 0 Answers