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

How to create a image button?

Discussion in 'Project Tiny' started by wowthebob, Jun 15, 2019.

  1. wowthebob

    wowthebob

    Joined:
    Aug 3, 2017
    Posts:
    2
    Hello,I want to create a image button in Tiny Project.How to do?
    Thank you.
     
  2. AlexMasse

    AlexMasse

    Joined:
    Jun 29, 2014
    Posts:
    19
    In version 0.15.3 (C#), take a look at the TimerButton sample.

    In short, setup your button entity like this:

    upload_2019-6-15_14-17-13.png

    StartTimerButton is a custom Component created for that specific button.
    To perform an action when user clicks it:

    Code (CSharp):
    1. Entities.ForEach((Entity entity, ref StartTimerButton startButton, ref PointerInteraction pointerInteraction) =>
    2. {
    3.     if (pointerInteraction.clicked)
    4.     {
    5.         // Do your button actions here:
    6.         // ...
    7.     }
    8. });
    Note that your button has to be under a UICanvas and have a RectTransform component to detect clicks and pointer interactions.
     
  3. wowthebob

    wowthebob

    Joined:
    Aug 3, 2017
    Posts:
    2
    thank you