Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    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