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

My Buttons Are Not Working

Discussion in 'Editor & General Support' started by RyanGamingKob, Oct 27, 2019.

  1. RyanGamingKob

    RyanGamingKob

    Joined:
    Oct 27, 2019
    Posts:
    18
    I Made A Panel That Has A Text, And 2 Buttons. Everything Was Working Fine.
    I Wanted To Animate The Panel, So I Added A Fade Animation For The Panel And The Text. I Wanted To Let The Buttons Appear After 1 second of the fade animation of the panel, so I Took The Buttons out of the panel into the general canvas and I Placed Them On The Top Of It.
    I Added To The Panel Animation, An Event To Load The Buttons Using The Script Below (Very Simple)


    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3.  
    4. public class LoadPanelUI : MonoBehaviour
    5. {
    6.     public GameObject RestartButtonUI;
    7.     public GameObject MainMenuButtonUI;
    8.  
    9.     public void LoadRestartButtonUI()
    10.     {
    11.         RestartButtonUI.SetActive(true);
    12.     }
    13.  
    14.     public void LoadMenuButtonUI()
    15.     {
    16.         MainMenuButtonUI.SetActive(true);
    17.     }
    18.  
    19. }
    20.  
    Then When I Loaded The Game And Hitted An Obstacle, The Fade Animation Worked Fined, But The Buttons Changed Colors And I Cannot Click On Them ( They Were Working Fine before )
    I Was Making My First Project (I Followed Brackeys In His Cubethon ) And I'm Making An Upgraded One Based On It
    So I Need Fixes ASAP
    I Will Send The Project File If Needed

    Thank Y'All For Reading
    Th
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,120
    Often if you can't click a button, there are two main reasons:
    • You deleted the "EventSystem" object from your scene. Make sure there's an object in your scene with the EventSystem component on it.
    • You placed another object on top of your buttons which is blocking the clicks from reaching your buttons. Make sure that the panels you're using are "below" the buttons, or that you uncheck Raycast Target for the panel.
    Side note: Capitalizing the first letter is nearly every word in your sentence looks really weird and makes it hard to read.
     
  3. Rok_Slana

    Rok_Slana

    Joined:
    Oct 10, 2016
    Posts:
    3
    Try changing the order of your elements inside Canvas. Items at the bottom are rendered last - hence are on top.
     
    Last edited: Oct 27, 2019
  4. RyanGamingKob

    RyanGamingKob

    Joined:
    Oct 27, 2019
    Posts:
    18
    I Didnt Delete The event system and the buttons are on top of the canvas
    Thanks for the reply Anyways.
    I figured out ... I made the buttons a child of the panel i wanted to animate. And i made the buttons Disabled even if the panel is enable and When the event triggers, the buttons show on top and clickable
    Btw for the Capitalizing, I Always Get my finger on shift and IT's More comfy for me unless I'm in school or using my phone