- Home /
Question by
MichaelUnicycle · Apr 15, 2021 at 12:55 PM ·
spritespritesspriterenderer
Changing sprite doesn't put it in the same place?
I'm trying to make a system that makes tiles on my map, which are colliders, highlight by changing the sprite. However, when I hover over any of the tiles the sprite only changes on one of them which is in a fixed point. Here is my code: I appreciate any help!
public SpriteRenderer spriteRenderer;
public Sprite newSprite;
public Sprite oldSprite;
void OnMouseEnter()
{
Debug.Log("Mouse is over GameObject.");
void ChangeSprite()
{
spriteRenderer.sprite = newSprite;
}
ChangeSprite();
}
void OnMouseExit()
{
Debug.Log("Mouse is no longer on GameObject.");
void ChangeSprite2()
{
spriteRenderer.sprite = oldSprite;
}
ChangeSprite2();
}
Comment
Your answer
Follow this Question
Related Questions
Translucent sprites appear solid 0 Answers
Unity Game View won't refresh my sprites 1 Answer
How to change spriterenderer to everyone with RPC 0 Answers
How to instance custom sprite shader? 0 Answers
2 Animation Clips, 1 Sprite 0 Answers