Unity Tutorial: Open Panel on Button Click

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ม.ค. 2025

ความคิดเห็น • 201

  • @AobaSanJin
    @AobaSanJin 5 ปีที่แล้ว +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.

  • @TalahuhnToGo
    @TalahuhnToGo 4 ปีที่แล้ว +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;

    • @JayAnAm
      @JayAnAm  4 ปีที่แล้ว +3

      Alright, thx for pointing this out.

    • @TalahuhnToGo
      @TalahuhnToGo 4 ปีที่แล้ว

      @@JayAnAm np

    • @Cac_you
      @Cac_you 3 หลายเดือนก่อน

      i really spent 2 hours looking for that and there we are.😞

  • @husseinal-faiz1533
    @husseinal-faiz1533 4 ปีที่แล้ว +2

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

    • @JayAnAm
      @JayAnAm  4 ปีที่แล้ว

      Thx, glad it helped

  • @imdublin4431
    @imdublin4431 3 ปีที่แล้ว

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

    • @JayAnAm
      @JayAnAm  3 ปีที่แล้ว +1

      Glad I could help

  • @JacobLofgreen
    @JacobLofgreen 3 ปีที่แล้ว +4

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

  • @kevinburgess1019
    @kevinburgess1019 5 ปีที่แล้ว +2

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

    • @JayAnAm
      @JayAnAm  5 ปีที่แล้ว

      Thx m8, will do

  • @hemanthc1166
    @hemanthc1166 3 ปีที่แล้ว

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

  • @bmwlux8706
    @bmwlux8706 3 ปีที่แล้ว +1

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

  • @Bonsaiwurzel
    @Bonsaiwurzel 4 ปีที่แล้ว +1

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

  • @skyeparker5822
    @skyeparker5822 3 ปีที่แล้ว

    The way all tutorials should be

  • @samarthrao3793
    @samarthrao3793 5 ปีที่แล้ว

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

  • @freeju2001
    @freeju2001 4 ปีที่แล้ว +5

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

    • @JayAnAm
      @JayAnAm  4 ปีที่แล้ว +3

      BAM... that's great!

  • @zandmunimdesignanddevelopm8061
    @zandmunimdesignanddevelopm8061 4 ปีที่แล้ว

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

  • @imvincible1391
    @imvincible1391 4 ปีที่แล้ว

    Great Tutorial! Super simple and useful!

  • @lyth4082
    @lyth4082 4 ปีที่แล้ว

    Thank you! Saved me multiple minutes/hours!

  • @allancabilestoc6235
    @allancabilestoc6235 3 ปีที่แล้ว

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

  • @holgerchristensen4021
    @holgerchristensen4021 5 ปีที่แล้ว

    Quick and simple. Thanks man!

  • @Manuel_S
    @Manuel_S 5 ปีที่แล้ว

    Thank you for this men, so simple and well explained

  • @ernesto_schz
    @ernesto_schz 5 ปีที่แล้ว

    your tutorial helped me a lot thnks man

  • @hafeezurramlee3276
    @hafeezurramlee3276 3 ปีที่แล้ว

    Amazing work!

  • @TechnoPhiliaa
    @TechnoPhiliaa 4 ปีที่แล้ว +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.

  • @Dorbellprod
    @Dorbellprod 5 ปีที่แล้ว

    Thank you so much for teaching me SetActive, epic

  • @jackal963
    @jackal963 2 ปีที่แล้ว

    Awesome man, very clever !

  • @rickmasterKKK
    @rickmasterKKK 4 ปีที่แล้ว

    Very nice, thank you for this tutorial

  • @timotimepiipponen3274
    @timotimepiipponen3274 3 ปีที่แล้ว

    Clear and useful, thank you!

    • @JayAnAm
      @JayAnAm  3 ปีที่แล้ว

      Glad it was helpful!

  • @EVHlivesforever
    @EVHlivesforever 5 ปีที่แล้ว

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

  • @AbieAqbarrizqy06
    @AbieAqbarrizqy06 4 ปีที่แล้ว

    Thanks !! Amazing video :)

  • @pollyanewertonewerton1499
    @pollyanewertonewerton1499 4 ปีที่แล้ว

    Thanks. Helped me a lot.

  • @yogeshkhandelwal4626
    @yogeshkhandelwal4626 3 ปีที่แล้ว +1

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

  • @damdakos
    @damdakos 6 ปีที่แล้ว

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

  • @denysuhendraproject5251
    @denysuhendraproject5251 4 ปีที่แล้ว

    Thank you for the knowledge !

    • @JayAnAm
      @JayAnAm  4 ปีที่แล้ว

      My pleasure!

  • @timaging
    @timaging 3 ปีที่แล้ว

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

  • @rinaldifarhan3717
    @rinaldifarhan3717 5 ปีที่แล้ว

    Thank youuuu so much for the tutorial

  • @raymondyudhi6963
    @raymondyudhi6963 5 ปีที่แล้ว +1

    Thank you for this tutorial. Would you tell me how about toggle more panels? I mean, click button > open first panel > click panel > open second panel > click panel > open third panel > click panel > close all panels

    • @Jana-vf2gq
      @Jana-vf2gq 4 ปีที่แล้ว

      Did you get any answers how to do that ? Or did you find any other Videos that explain that ? It would help me a lot :)

    • @raymondyudhi6963
      @raymondyudhi6963 4 ปีที่แล้ว

      @@Jana-vf2gq still not yet

    • @eddybplayz4801
      @eddybplayz4801 4 ปีที่แล้ว

      @@raymondyudhi6963 hi

    • @embaunton6555
      @embaunton6555 3 ปีที่แล้ว

      Any update? This is exactly what I'm looking for also

  • @zero33z
    @zero33z 6 ปีที่แล้ว +3

    and how can i close this panel?

  • @Parpleyt
    @Parpleyt 10 หลายเดือนก่อน

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

  • @shaansingh7629
    @shaansingh7629 3 ปีที่แล้ว +1

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

  • @ImInDaSkies
    @ImInDaSkies 5 ปีที่แล้ว

    Great tutorial

  • @plasmarade
    @plasmarade 4 ปีที่แล้ว +2

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

    • @scrypt5309
      @scrypt5309 4 ปีที่แล้ว

      yes use input get key

  • @caron10130
    @caron10130 5 ปีที่แล้ว

    Thanks this helped a lot!

  • @thilosapp5300
    @thilosapp5300 3 ปีที่แล้ว +1

    Thank you! Soo helpful!

  • @jaydeepbhoite5829
    @jaydeepbhoite5829 4 ปีที่แล้ว

    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 4 ปีที่แล้ว

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

  • @nurzaniliyanaabdulrani9798
    @nurzaniliyanaabdulrani9798 4 ปีที่แล้ว

    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.

  • @lora6938
    @lora6938 3 ปีที่แล้ว

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

  • @vijayanand2783
    @vijayanand2783 3 ปีที่แล้ว

    Nice video.Keep uploading videos..

    • @JayAnAm
      @JayAnAm  3 ปีที่แล้ว

      Thank you, I will

  • @IcelandicCello
    @IcelandicCello ปีที่แล้ว

    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?

  • @paulkruger4156
    @paulkruger4156 5 ปีที่แล้ว +2

    For some reason Unity editor will not let me drag the Panel in to the Inspector :(

    • @CVictor13
      @CVictor13 4 ปีที่แล้ว

      make sure the panel variable in the script is public:
      public GameObject panel;

    • @gautamkumarsingh3212
      @gautamkumarsingh3212 3 ปีที่แล้ว +1

      @@CVictor13 public or [SerializeField]

  • @remconet
    @remconet 4 ปีที่แล้ว

    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.

  • @achikarif1098
    @achikarif1098 3 ปีที่แล้ว

    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??

  • @misal-isahabe5281
    @misal-isahabe5281 4 ปีที่แล้ว

    was so beneficial. thanks.

  • @NabilMajid
    @NabilMajid 5 ปีที่แล้ว

    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?

  • @fga55
    @fga55 5 ปีที่แล้ว

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

  • @LegendeSiMituri
    @LegendeSiMituri 4 ปีที่แล้ว

    2021 still teaching people

  • @wanhui6826
    @wanhui6826 4 ปีที่แล้ว

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

  • @hemanthteja9996
    @hemanthteja9996 5 ปีที่แล้ว

    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

  • @awesomefacts9785
    @awesomefacts9785 4 ปีที่แล้ว

    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
    @micheleguardabasso8162 ปีที่แล้ว

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

  • @ephemerlab
    @ephemerlab 4 ปีที่แล้ว

    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 3 ปีที่แล้ว

      someone please reply to this one :)

  • @ALexpLK
    @ALexpLK 4 ปีที่แล้ว +1

    How do I Hide 4 other Panels and open this one?(5 buttons.I click on one of these and the right Panel opens so all the other Panels close) pls help I'm new to unity

    • @ALexpLK
      @ALexpLK 4 ปีที่แล้ว +1

      I think I got it,but I need 5 scripts for every single one of these and the script is same but instead of true at the last line it has to be falsr

    • @ВенераУтегенова-в3х
      @ВенераУтегенова-в3х 2 ปีที่แล้ว

      @@ALexpLK and now how to hide the buttons of the previous panel? were you able to do it? when you switch to 2 panels, how do I hide the button?

    • @ALexpLK
      @ALexpLK 2 ปีที่แล้ว

      @@ВенераУтегенова-в3х yo I stopped with unity some time after writing the previous comment and even though I started like a week ago, I sadly cant help you. Im gonna try around and tell you if i get it here

  • @TheNamesJT
    @TheNamesJT 5 ปีที่แล้ว +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 5 ปีที่แล้ว

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

  • @ankitsharma-se2vv
    @ankitsharma-se2vv 2 ปีที่แล้ว

    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.

  • @mrdonnki119
    @mrdonnki119 4 ปีที่แล้ว

    using this for fnaf fangame. thank you:)

  • @moonhope3638
    @moonhope3638 6 ปีที่แล้ว +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.

  • @koshinnn
    @koshinnn 2 ปีที่แล้ว

    does it work for canvas as well?

  • @LavaDemon
    @LavaDemon 4 ปีที่แล้ว +2

    Where is script?

  • @deathseeker9525
    @deathseeker9525 6 ปีที่แล้ว

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

  • @KaLeeLIU-zd8eh
    @KaLeeLIU-zd8eh 2 ปีที่แล้ว

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

  • @Cac_you
    @Cac_you 3 หลายเดือนก่อน

    this helped alot TYSM

  • @mulagraphics
    @mulagraphics 2 ปีที่แล้ว

    Thanks from the future😀😀

  • @umiumairah2733
    @umiumairah2733 5 ปีที่แล้ว

    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 4 ปีที่แล้ว

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

  • @Haxor1021
    @Haxor1021 5 ปีที่แล้ว

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

  • @kevdoesart8996
    @kevdoesart8996 6 ปีที่แล้ว

    Perfect. Thank you.

  • @aiilascosse
    @aiilascosse 6 ปีที่แล้ว

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

  • @franciscofimbres3328
    @franciscofimbres3328 4 ปีที่แล้ว

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

  • @samuelnavarro1134
    @samuelnavarro1134 5 ปีที่แล้ว

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

  • @YaTa1234
    @YaTa1234 3 ปีที่แล้ว +1

    can we make it for 2D?

  • @sitinurfatihah1928
    @sitinurfatihah1928 4 ปีที่แล้ว +1

    thankssss it works!

  • @ivogamito5750
    @ivogamito5750 6 ปีที่แล้ว

    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  6 ปีที่แล้ว

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

    • @ivogamito5750
      @ivogamito5750 6 ปีที่แล้ว

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

    • @JayAnAm
      @JayAnAm  6 ปีที่แล้ว

      @@ivogamito5750 How is you Panel member variable defined?

  • @shivamhire9869
    @shivamhire9869 5 ปีที่แล้ว

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

  • @MrISIDOROS
    @MrISIDOROS 5 ปีที่แล้ว

    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 4 ปีที่แล้ว

      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.

  • @rodrigoprimata6833
    @rodrigoprimata6833 3 ปีที่แล้ว +1

    CAN ANYBODY EXPLAIN WHY MINE IS ONLY OPENING AND NOT CLOSING?
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class Abrir : MonoBehaviour
    {
    public GameObject Panel;
    public void OpenPanel()
    {
    if (Panel != null)
    {
    bool isActive = Panel.activeSelf;
    Panel.SetActive(!isActive);
    }
    }
    }

    • @gautamkumarsingh3212
      @gautamkumarsingh3212 3 ปีที่แล้ว +1

      instead of using this complex use this
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class Abrir : MonoBehaviour
      {
      public GameObject Panel;
      public void panelonOff()
      {
      panel.SetActive(!panel.activeSelf);
      }
      }
      works same as above without any complex and long code

    • @ibukichannel1543
      @ibukichannel1543 ปีที่แล้ว

      @@gautamkumarsingh3212 U'RE FUC*IN AWESOME!!!

  • @kevinchen960
    @kevinchen960 ปีที่แล้ว

    sorry, Why I can't add scripts to the button? It always show "the class is not found"

    • @kevinchen960
      @kevinchen960 ปีที่แล้ว

      I use the Universal Windows Platform

  • @banned8980
    @banned8980 3 ปีที่แล้ว +1

    Can I reprint this video on Chinese video website?
    I will note with the link address of the original video.

    • @JayAnAm
      @JayAnAm  3 ปีที่แล้ว

      What do you mean by "reprint"? You can share the link, no probem

    • @banned8980
      @banned8980 3 ปีที่แล้ว

      @@JayAnAm "reprint" means I will translate and upload your video on bilibili. In China, we can't see the video on TH-cam easily. And I will note the original link on the reprinted video

  • @TheOnlyGamingMC
    @TheOnlyGamingMC 3 ปีที่แล้ว

    how to make panel solid and not transparent

  • @artandme8183
    @artandme8183 3 หลายเดือนก่อน

    How can i do this for unity Ar scene for android?

  • @youtuberyoutuber2495
    @youtuberyoutuber2495 5 ปีที่แล้ว

    How do you make it so after it brings up the new panel, there are icons on the new panel?

    • @samarthrao3793
      @samarthrao3793 5 ปีที่แล้ว

      can't you just put the icons as a child of the panel and position them

    • @ygkhii3077
      @ygkhii3077 5 ปีที่แล้ว

      @@samarthrao3793 you can

    • @samarthrao3793
      @samarthrao3793 5 ปีที่แล้ว

      👍

  • @rwc6930
    @rwc6930 3 ปีที่แล้ว

    Sir why the button gets disabled on click?

  • @arvindnishad1362
    @arvindnishad1362 5 ปีที่แล้ว

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

  • @robinandersson399
    @robinandersson399 4 ปีที่แล้ว

    I really love your tutorials; they're short, concise and easy to follow.
    However, in this example I would love to understand the code a bit more.
    Not being so familiar with coding, this certainly played some tricks on my mind.
    Can you or anyone else please confirm if I have gotten this right?:
    (Panel != null) // Checks if the object is activated in the hierarchy windows
    Bool = isActive = Panel.activeSelf; //Creates a bool that reflects the false/true status of the Panel-object
    Panel.SetActive(!isActive); -// Sets the Bool to the opposite of what the bool "isActive" is?

  • @wearwolf4202
    @wearwolf4202 4 ปีที่แล้ว

    How do you do this with a prefab?

  • @hysteriaadvertising4517
    @hysteriaadvertising4517 5 ปีที่แล้ว +2

    Very good tutorial...but i have one question
    How to disable other opened panels when i open one..TO AVOID PANELS OVERLAP
    Any solutions ?????

    • @ancapftw9113
      @ancapftw9113 5 ปีที่แล้ว

      Couldn't you just use one object to track all of the window's active/inactive states and make a function for each button? Then you could just check for other active windows whenever another window is activated and deactivate any active ones.

  • @StyshaLatip
    @StyshaLatip 5 ปีที่แล้ว

    Awesome! Thank you

  • @Patrick1985McMahon
    @Patrick1985McMahon 6 ปีที่แล้ว +3

    why not just panel.SetActive(!panel.activeSelf);
    so much easier and you don't need extra lines.

    • @5aira60
      @5aira60 5 ปีที่แล้ว

      thanks

    • @unhommequicourt
      @unhommequicourt 4 ปีที่แล้ว

      @@dis5166 it should replace the code panel.setactive line

    • @sexyibizanights
      @sexyibizanights 3 ปีที่แล้ว

      This simple change
      helped me a lot thx.

  • @itzquizie9007
    @itzquizie9007 3 ปีที่แล้ว

    with what program do you script

  • @damocles2x267
    @damocles2x267 4 ปีที่แล้ว

    how can i add buttons in the panel

  • @work896
    @work896 ปีที่แล้ว

    Doesn't work to close panel. I checked 3 times , but still doesn't work. What can it be?

  • @boem231
    @boem231 5 ปีที่แล้ว +1

    Why are you programming in a script?? You can Just go to the button click on the plus where it says on click event. You drag the panel in there then click on GameObject and then click on the checkbox. Check the checkbox to be active uncheck it to be bot active.

    • @JayAnAm
      @JayAnAm  5 ปีที่แล้ว

      Yes, but now assume that you want the panel to fade in and out instead of just being active / inactive... then the solution with the script is more extendable.

    • @boem231
      @boem231 5 ปีที่แล้ว

      Yes okay but if you only want to make it active/inactive you can use this method

    • @JayAnAm
      @JayAnAm  5 ปีที่แล้ว

      @@boem231 Yes, if you are sure that you don't want to extend it. Which is usually not the case:-)

  • @Rhys-gv3ir
    @Rhys-gv3ir 4 ปีที่แล้ว

    is GameObject a data type?

  • @jeffreydmason2878
    @jeffreydmason2878 3 ปีที่แล้ว

    does it work for 3d objects?