且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

单击一个按钮时实例化弹出窗口

更新时间:2023-01-07 19:51:51

您可能会使用Unity.UI,而仅使用面板.

You would probably use Unity.UI, and just use a panel.

这非常容易(1)单击添加画布"(2)单击添加面板".

It is very easy (1) click "add canvas" (2) click "add panel".

只需

 .SetActive

来自您的代码.享受!如您所见,这很简单:

from your code. Enjoy! As you can see it's this easy:

尝试在编辑器中打开和关闭它,并在Inspector上进行切换.在代码中只是..

Try turning it on and off in the Editor with that toggle on Inspector. In code it's just..

   public GameObject popupPanel;
   ...
   popupPanel.SetActive(false);  or...
   popupPanel.SetActive(true);