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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Beginner Question: Make image appear with event trigger?

Discussion in 'Scripting' started by woy, Jun 15, 2015.

  1. woy

    woy

    Joined:
    Jun 15, 2015
    Posts:
    5
    Hi guys,

    im pretty new in unity but need some quick help.

    I want to have a button which when i hover with the mouse over it a image appears and disappears when I leave the button with the mouse. I have a event trigger on the button with "pointer enter". Which function do i have to use to get what i want. Do I have to writte a script for this? Im also new to c#.

    Thank you for your help
     
  2. SubZeroGaming

    SubZeroGaming

    Joined:
    Mar 4, 2013
    Posts:
    1,008
    check out the new interfaces for the UI system.

    Create an image UI component, and using OnPointerEnter and OnPointerExit you can create logic to have a UI image swap sprites between something and nothing (make it transparent)
     
  3. woy

    woy

    Joined:
    Jun 15, 2015
    Posts:
    5
    Thanks for your help, but i want to hover over my button and a image should appear. The image and the button are two different things and have not the same position and size.
     
  4. SubZeroGaming

    SubZeroGaming

    Joined:
    Mar 4, 2013
    Posts:
    1,008
    That's fine.


    UI image component.
    - this image will become a picture of you when you hover over some other image button.


    UI Image Button
    - I have a handle to the UI image, and when OnPointerEnter is called, I'm going to use that handle to change the sprite of the UI Image to the image i want it to be.


    This is very simple logic. You need to watch the Unity provided training on the new UI system if you're having simple issues like this.
     
  5. woy

    woy

    Joined:
    Jun 15, 2015
    Posts:
    5
    Sorry but i dont understand. I saw the UI Beginner tutorials. But I think the problem is that i dont know which function i have to put on the event trigger on my button. I got "point enter" and the image is selcted in the event trigger(on the button) but i dont know which function i have to use. Can you give me more informations please. That would be great :)