Quantcast
Channel: UGUI & TextMesh Pro
Viewing all articles
Browse latest Browse all 23263

I cannot change the sprite the of the image with script

$
0
0
I have been trying to change the image when a button is pressed, but it always says:

NullReferenceException: Object reference not set to an instance of an object

I already added a sprite to the public Sprite variable but it is still the same.

***This object is an object I created as an empty game object and added the script to it. It also has an image as a child.***

This is my code:

Code (csharp):
  1.  
  2. public Sprite firstImage; // Already added sprite to this in the game
  3. public...


I cannot change the sprite the of the image with script

Viewing all articles
Browse latest Browse all 23263

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>