Unity Tutorial: Open Panel on Button Click

Sdílet
Vložit
  • čas přidán 5. 08. 2024
  • This is an answer to a request for Unity game development, on how to open a UI Panel when a Button is clicked.
    I show this example and also how to toggle the visibility of the Panel.
    See my social profiles here
    G+: plus.google.com/+JayAnAm
    Twitter: / jayanamgames
    Facebook: / jayanamgames
    Patreon: / jayanam
    Indiegogo: / jayanamgames
    Production Music courtesy of Epidemic Sound: www.epidemicsound.com

Komentáře • 198

  • @AobaSanJin
    @AobaSanJin Před 5 lety +58

    Some people trying to help but they made my mind more complicated. But you are amazing with brief and perfect telling, thank you so much.

  • @husseinal-faiz1533
    @husseinal-faiz1533 Před 3 lety +2

    I have been searching through various CZcams tutorials regarding this problem and finally I found this video .Simple and concise. Thank you Guru!!!!

  • @JacobLofgreen
    @JacobLofgreen Před 3 lety +4

    THANK YOU!!! Simple, easy, exactly what I needed.

  • @TalahuhnToGo
    @TalahuhnToGo Před 4 lety +21

    for anyone who use that for a pause menu and want freeze time u have to add under Panel.SetActive(true);
    Time.timeScale = 0f;

  • @samarthrao3793
    @samarthrao3793 Před 4 lety

    thank you for the brief helpful tutorial, just what I needed

  • @imdublin4431
    @imdublin4431 Před 3 lety

    i love you bro! i've been watching a couple videos and none of em work, but yours does !

  • @kevinburgess1019
    @kevinburgess1019 Před 5 lety +2

    Super helpful with an excellent teaching style. SUBSCRIBED!! Please make many more!

  • @hemanthc1166
    @hemanthc1166 Před 3 lety

    Waah sir, i have been searching for this simce 2 dayss, Finally i found it❤️❤️

  • @Bonsaiwurzel
    @Bonsaiwurzel Před 3 lety +1

    Thanks, simple and easy! As a beginner this helped me a lot :)

  • @imvincible1391
    @imvincible1391 Před 3 lety

    Great Tutorial! Super simple and useful!

  • @holgerchristensen4021
    @holgerchristensen4021 Před 5 lety

    Quick and simple. Thanks man!

  • @allancabilestoc6235
    @allancabilestoc6235 Před 2 lety

    thank you.. this tutorial is easy to follow and very helpful

  • @Manuel_S
    @Manuel_S Před 4 lety

    Thank you for this men, so simple and well explained

  • @lyth4082
    @lyth4082 Před 4 lety

    Thank you! Saved me multiple minutes/hours!

  • @zandmunimdesignanddevelopm8061

    So simple for toggling panels my code was all working but this is nice and clean switched all them now lol

  • @hafeezurramlee3276
    @hafeezurramlee3276 Před 3 lety

    Amazing work!

  • @TechnoPhiliaa
    @TechnoPhiliaa Před 4 lety +1

    can you please help me . i just imported the obj to unity . Now what is want is that ..thr is a picture on a wall and i want a button next to it and on click it should display a popup with some text.

  • @damdakos
    @damdakos Před 5 lety

    Many thanks. I like that it is very simple. Very good

  • @rickmasterKKK
    @rickmasterKKK Před 3 lety

    Very nice, thank you for this tutorial

  • @nurzaniliyanaabdulrani9798

    great tutorial! just want to ask, is that possible to add video onto this panel? cause i'm facing some problem with the video player panel on a canvas. thank you.

  • @ernesto_schz
    @ernesto_schz Před 4 lety

    your tutorial helped me a lot thnks man

  • @fga55
    @fga55 Před 5 lety

    Can I do the same steps if I’m using vuforia and the button only opens when an image target gets detected?

  • @pollyanewertonewerton1499

    Thanks. Helped me a lot.

  • @wanainnabila2311
    @wanainnabila2311 Před 3 lety

    thank you so much for the great tutorial

  • @timaging
    @timaging Před 2 lety

    how do you set up multiple buttons to show and hide multiple panels? Can you add animation to those panels?

  • @ImInDaSkies
    @ImInDaSkies Před 5 lety

    Great tutorial

  • @jackal963
    @jackal963 Před rokem

    Awesome man, very clever !

  • @EVHlivesforever
    @EVHlivesforever Před 5 lety

    Thanks so much for the tutorial this saved my skin!!

  • @caron10130
    @caron10130 Před 5 lety

    Thanks this helped a lot!

  • @rinaldifarhan3717
    @rinaldifarhan3717 Před 5 lety

    Thank youuuu so much for the tutorial

  • @NabilMajid
    @NabilMajid Před 5 lety

    I need in one app, one button, when i press this button, it enable another button in another app. Example both app are open in 2 diferent cellphone. Then when i press the button in the fisrt app, in the other app appear one button, then when i press that button. the button from my app disapear.
    How can i do that, is possible?

  • @jaydeepbhoite5829
    @jaydeepbhoite5829 Před 4 lety

    Hey there great video.
    I'm trying to make two buttons to display two different tiles , facing some issues with the code so needed help.
    Thanks !

  • @exet208
    @exet208 Před 3 lety

    it can be used to any other things like button of category of gameobject?

  • @Dorbellprod
    @Dorbellprod Před 4 lety

    Thank you so much for teaching me SetActive, epic

  • @PositronicDiscombobulator

    Thank you so so much....many blessings to you.

  • @lora6938
    @lora6938 Před 3 lety

    Hello, can you tell me how to smoothly disable and enable buttons or panels, well, in general, UI elements?

  • @aiilascosse
    @aiilascosse Před 5 lety

    How I do this in object, for exemple a cube instead of a button?

  • @shivamhire9869
    @shivamhire9869 Před 5 lety

    can i use the same implementation for a VR game ??

  • @misal-isahabe5281
    @misal-isahabe5281 Před 3 lety

    was so beneficial. thanks.

  • @timotimepiipponen3274
    @timotimepiipponen3274 Před 3 lety

    Clear and useful, thank you!

  • @wanhui6826
    @wanhui6826 Před 3 lety

    May I know why my panel will initially shown before button on click ?

  • @AbieAqbarrizqy06
    @AbieAqbarrizqy06 Před 3 lety

    Thanks !! Amazing video :)

  • @zero33z
    @zero33z Před 5 lety +3

    and how can i close this panel?

  • @bmwlux8706
    @bmwlux8706 Před 2 lety +1

    Everyone tries to make their video longer with like 1000 annoying steps but your a pro, unlike them.

  • @kevdoesart8996
    @kevdoesart8996 Před 5 lety

    Perfect. Thank you.

  • @awesomefacts9785
    @awesomefacts9785 Před 4 lety

    hi sir...............short and nice video,
    i have a doubt that i was planning to develop a 4 option quiz game in unity, i want to display the questions facts and uses in the other panel when the user presses the right or wrong answer, for this do i have to make different panels for each question...

  • @micheleguardabasso8162

    Can you please tell me as i can oper and close with key press? Keyboard

  • @deathseeker9525
    @deathseeker9525 Před 5 lety

    is it possible to show one panel while the other is hide when clicking a button?help..

  • @mediamermaid333
    @mediamermaid333 Před 2 měsíci +1

    Thank you!!

  • @denysuhendraproject5251

    Thank you for the knowledge !

  • @Haxor1021
    @Haxor1021 Před 4 lety

    Ok, How to do it to the Button(Clone)? I need to do it but Setactive is not working

  • @hemanthteja9996
    @hemanthteja9996 Před 4 lety

    Hi sir,
    I have created two buttons and added panel to it
    When i press button 1 it open panel and when i click second button it's still showing 1st button panel on
    How to hide previous panel automatically when we are in 2nd button panel

  • @IcelandicCello
    @IcelandicCello Před rokem

    The video is so clear. However, when I try even the first step, I seem to be able to click the button, but then the panel does not appear. I have Event Systems in my hierarchy, my canvas has a graphic ray caster, and I do exactly what is explained here. I'm a bit desperate at this point, would anyone have advice?

  • @StyshaLatip
    @StyshaLatip Před 5 lety

    Awesome! Thank you

  • @achikarif1098
    @achikarif1098 Před 2 lety

    why when I do drag the scripts into button inspector the panel for game object doesn't appear .. I'm currently using unity 2021.1.21f1 .. I can't figure this problem out can somebody help me??

  • @shaansingh7629
    @shaansingh7629 Před 3 lety +1

    Hey mate I'm wondering if a panel is open how can I stop another panel from appearing? Also really great tutorial!

  • @freeju2001
    @freeju2001 Před 4 lety +5

    this one fixed my issue like "BAM"!!!

    • @JayAnAm
      @JayAnAm  Před 4 lety +3

      BAM... that's great!

  • @koshinnn
    @koshinnn Před rokem

    does it work for canvas as well?

  • @thilosapp5300
    @thilosapp5300 Před 3 lety +1

    Thank you! Soo helpful!

  • @itzquizie9007
    @itzquizie9007 Před 2 lety

    with what program do you script

  • @franciscofimbres3328
    @franciscofimbres3328 Před 4 lety

    how do I stop overlapping can you please explain in depth thanks for the trouble.

  • @ankitsharma-se2vv
    @ankitsharma-se2vv Před 2 lety

    this tutorial helped me in unity game development. Now i am trying to open a panel automatically when a prefab is spawned in runtime, any idea how to do it.

  • @ephemerlab
    @ephemerlab Před 4 lety

    Thank you :) Is there a way to make the panel fade in rather than just suddenly appearing? Would this have to be done through animation or tween or is there an easier way?

    • @AlexGorskov
      @AlexGorskov Před 2 lety

      someone please reply to this one :)

  • @moonhope3638
    @moonhope3638 Před 5 lety +1

    Nice! Thanks, this was straightforward and useful. :) Any chance you can talk about having it disappear upon answering a question right. I added true and false buttons that appear alongside the panel on button press. But, I want it to stay upon getting the question wrong and disappear upon getting the question right. Any tips would be much appreciated.

  • @sitinurfatihah1928
    @sitinurfatihah1928 Před 4 lety +1

    thankssss it works!

  • @kareem5340
    @kareem5340 Před 2 lety

    Thank you so much

  • @KaLeeLIU-zd8eh
    @KaLeeLIU-zd8eh Před rokem

    Hi I wanna ask how can I change the button to click on E

  • @wearwolf4202
    @wearwolf4202 Před 3 lety

    How do you do this with a prefab?

  • @LegendeSiMituri
    @LegendeSiMituri Před 3 lety

    2021 still teaching people

  • @vijayanand2783
    @vijayanand2783 Před 3 lety

    Nice video.Keep uploading videos..

  • @skyeparker5822
    @skyeparker5822 Před 2 lety

    The way all tutorials should be

  • @samuelnavarro1134
    @samuelnavarro1134 Před 4 lety

    It doesn't have the place where I can drag the panel on the script.... Please help me ASAP

  • @mrdonnki119
    @mrdonnki119 Před 3 lety

    using this for fnaf fangame. thank you:)

  • @jeffreydmason2878
    @jeffreydmason2878 Před 3 lety

    does it work for 3d objects?

  • @TheNamesJT
    @TheNamesJT Před 4 lety +1

    I have a question : So i have 2 panels and right now they both open and overlap was wondering what would i need to do to this code for it to open 1 panel at a time and if you try to open the next panel it will close the other one so they don't overlap? hatebin.com/hqqsmtgiir

    • @ygkhii3077
      @ygkhii3077 Před 4 lety

      make sure the the other panel isnt a child of the panel being activated

  • @damocles2x267
    @damocles2x267 Před 4 lety

    how can i add buttons in the panel

  • @dmmarch7185
    @dmmarch7185 Před 2 lety

    OMG thank you!!

  • @plasmarade
    @plasmarade Před 4 lety +2

    Would this work with keyboard keys? (Example: press E to open the panel)

  • @Rhys-gv3ir
    @Rhys-gv3ir Před 3 lety

    is GameObject a data type?

  • @pinkviagra4831
    @pinkviagra4831 Před 3 lety

    the Panel default wouldnt appear in the Inspector wouldnt appear underneath the Button script;(

  • @julio1192
    @julio1192 Před 2 lety

    Thank you!

  • @MrISIDOROS
    @MrISIDOROS Před 5 lety

    This is amazing.... Quite exactly what i needed. Question, coz i m newb in unity, would it be possible to add animation in the "toggle" button (ex. opening slowing from the center of the screen)? I going to work towards this :D. How do i go about making a custom animation.

    • @ratboyOwO
      @ratboyOwO Před 4 lety

      look up simple UI animation. Unity has a keyframe tool similar to a video editor or flash animator if youve ever used something like that.

  • @mulagraphics
    @mulagraphics Před 2 lety

    Thanks from the future😀😀

  • @umiumairah2733
    @umiumairah2733 Před 4 lety

    Hi, may i know if i want to close the panel but i want to click on different button for example x button, is there need to have new coding? Please notice this comment shortly! Thanks!!!

    • @embaunton6555
      @embaunton6555 Před 3 lety

      Hi! currently doing this. Did you manage to do it?

  • @cyberkonco
    @cyberkonco Před 2 lety

    thank you so much sir...

  • @gaelpic1120
    @gaelpic1120 Před 5 lety

    thank you so much

  • @arvindnishad1362
    @arvindnishad1362 Před 4 lety

    I have used the same method but it's not working in Vuforia.

  • @yogeshkhandelwal4626
    @yogeshkhandelwal4626 Před 2 lety +1

    Sir when we click to gameobject old gameobject want off and new gameobject on sir pls reply 😅😅😅🙏🙏🙏🙏🙏😩😩😩😖😖😖

  • @remconet
    @remconet Před 3 lety

    Okay I've tried this but it's not working... Can't figure out what I'm doing wrong.
    Update: it IS working but it was not very clear as to WHERE to uncheck the panel. I unchecked the wrong one. Fixed it now and it's working.

  • @YaTa1234
    @YaTa1234 Před 3 lety +1

    can we make it for 2D?

  • @gorilyawarfare485
    @gorilyawarfare485 Před 5 lety

    the closing dont work boss what could I be doing wrong

  • @ParpleYt
    @ParpleYt Před 4 měsíci

    This was amazing, but i have on question how do I close the panel?

  • @chungcu681
    @chungcu681 Před 5 lety

    Thank you

  • @rocknrm99
    @rocknrm99 Před rokem

    thanks!

  • @grafidystudios6582
    @grafidystudios6582 Před 2 lety

    thankyouuuuu!

  • @murdermystery9740
    @murdermystery9740 Před 7 měsíci

    thank you!! :]]

  • @venmen5282
    @venmen5282 Před 2 lety

    Thank you!!!!!!!!!!!

  • @asonlove2350
    @asonlove2350 Před 2 lety

    Thank you!!!!

  • @rwc6930
    @rwc6930 Před 3 lety

    Sir why the button gets disabled on click?

  • @ivogamito5750
    @ivogamito5750 Před 5 lety

    I'm doing the exact same code and I get this error from the script: Type `GameObject' does not contain a definition for `SetActive' and no extension method `SetActive' of type `GameObject' could be found. Are you missing an assembly reference? I'm using the version 2018.2 16f1 Is this a version problem?

    • @JayAnAm
      @JayAnAm  Před 5 lety

      No, please send the code in which you call SetActive. Did you include the line using UnityEngine;

    • @ivogamito5750
      @ivogamito5750 Před 5 lety

      @@JayAnAm Yes. It's solved after I used Panel.gameObject.activeSelf , instead of Panel.activeSelf

    • @JayAnAm
      @JayAnAm  Před 5 lety

      @@ivogamito5750 How is you Panel member variable defined?