Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

UI Change Source Image

Discussion in 'UGUI & TextMesh Pro' started by MackaroniCheese, Dec 20, 2018.

  1. MackaroniCheese

    MackaroniCheese

    Joined:
    Oct 16, 2017
    Posts:
    5
    Hi I'm new to unity and can't seem to find an answer to this question which works for me:

    Basically, I have a button called No which has a source image called Button Not Over.

    I want to make it so that when the mouse is hovered over this button, the source image changes to one called Button Over and when the mouse is no longer over the button, the source image reverts to Button Not Over.

    Any help is greatly appreciated.
     
  2. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,244
    MouseOver image can be changed in button component in inspector.
     
  3. MackaroniCheese

    MackaroniCheese

    Joined:
    Oct 16, 2017
    Posts:
    5
    Onmouseover doesn't seem to be being run when I attach the script to the button?
     
  4. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,244
    Is it because you're overriding onMouseOver in the attached script?
     
  5. MackaroniCheese

    MackaroniCheese

    Joined:
    Oct 16, 2017
    Posts:
    5
    This is the script which I added to the button
     

    Attached Files:

  6. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,244
    Well, remove it. Use this:
    upload_2018-12-21_11-19-5.png
     
  7. MackaroniCheese

    MackaroniCheese

    Joined:
    Oct 16, 2017
    Posts:
    5
    I'm still getting nothing. I set the target graphic as the button which the component is on and I set the sprite as the highlighted sprite.