Rotate sprite when mouse hover

I want to make the trashcan open and enlarge a bit when the mouse hover over it, how do I do it?152927-open.png

If this is a sprite in the game world, you can put conditions to change/enlarge the sprite with the functions OnMouseEnter() and OnMouseExit() *link to info/examples

If it’s a canvas UI image, you’ll have to use OnPointer events to achieve the same effect: *info/examples

To actually make the changes to the sprite, you’ll either reference the sprite renderer or the image.sprite and replace it / change its values to whatever you want.

So, if your trashcan is a canvas object, your code will probably look something like this

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;// Required when using Event data.

public class ExampleClass : MonoBehaviour, IPointerEnterHandler,  IPointerExitHandler // required interface when using the OnPointerEnter method.
{
    //Do this when the cursor enters the rect area of this selectable UI object.
    public void OnPointerEnter(PointerEventData eventData)
    {
        Debug.Log("The cursor entered the selectable UI element.");
    }
    //Do this when the cursor exits the rect area of this selectable UI object.
    public void OnPointerExit(PointerEventData eventData)
    {
        Debug.Log("The cursor exited the selectable UI element.");
    }
}

or else, again, if it’s a gamespace sprite you’ll use the mouseover/exit stuff.