How would I hardcode a cursor image to my Texture2D variable?

Whilst trying to do the challenge for this one, I made the assumption that I would need to swap out what the walkCursor was using as the image rather than creating three separate variable references for it.

So instead of:
[SerializeField] Texture2D walkCursor = null;

I would want something like:
`Texture2D walkCursor = “Walk.PSD”;

This isn’t quite right however - can anyone confirm how I could hardcode the solution?

Thanks in advance.

This is not how Unity is designed to work and is not the best way to do it but just to satisfy your curiosity here is how I managed to do it.

m_walkCursor = (Texture2D) Resources.Load("Unknown");

In this case you need to have a Folder named “Resources” (that’s how Resources.Load works) and copy your psd there. Then you can specify the name of the psd you want to set and that’s it. In this case I hard-coded the unknown cursor to the walkCursor.

Still, I would not recommend this implementation.

1 Like

Thanks for this.
It was more out of curiosity and the notion that perhaps it could be something I would need to better understand in the future.

1 Like

Privacy & Terms