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

[Unity Questions] Fading Text and Clickable Field behind Buttons

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

  1. Vunoo


    Mar 14, 2018
    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:

    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


    Apr 19, 2016
    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.