Search Unity

[Unity Questions] Fading Text and Clickable Field behind Buttons

Discussion in 'Getting Started' started by Vunoo, May 27, 2018.

  1. Vunoo

    Vunoo

    Joined:
    Mar 14, 2018
    Posts:
    6
    Hey guys! I've been sttrugling to do 2 things, and perhaps you could enlighten me on what I'm doing wrong. Anyway, here are the questions:


    1) Im trying to create a fading Text for my game where it slowly changes its alpha value as it slides up in my canvas (opening space for other texts). Here are 2 print of both the code and my layout:



    https://imgur.com/Xs9lO1e
    https://imgur.com/Xs9lO1e

    2) When I click on "Plant" Button, it opens a new panel where I can choose which type of tree to plant and it's working as itended BUT when I click on another button it does it's own ActionEvent but also plant a tree behind the Button's location. How can I make it so that when I click on a button my ray that was traced collides with the button (from camera perspective) and not the terrain behind it? Cause if I get the gameObject it collided with it gives me Terrain as answer..


    Thanks for helping me out! I hope I could explain things properly :(
     
  2. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    377
    Normally you put an invisible pane or images behind all clickable UI objects. Make that object accept raycasts. This will 'eat' all mouse click events and block any clicked objects behind it.

    The UI buttons have their own onClick event handlers. You should be using them.