{"id":812,"date":"2025-05-10T19:45:04","date_gmt":"2025-05-10T19:45:04","guid":{"rendered":"https:\/\/sites.wsagames.com\/sl1c22\/?p=812"},"modified":"2025-09-30T10:39:17","modified_gmt":"2025-09-30T10:39:17","slug":"esc-key-system","status":"publish","type":"post","link":"https:\/\/sites.wsagames.com\/sl1c22\/2025\/05\/10\/esc-key-system\/","title":{"rendered":"Esc Key System"},"content":{"rendered":"\n<figure class=\"wp-block-image alignwide size-full has-custom-border\"><img fetchpriority=\"high\" decoding=\"async\" width=\"2560\" height=\"1532\" src=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1-_DX11_-2025_5_10-21_08_07.png\" alt=\"\" class=\"wp-image-820\" style=\"border-width:5px\" srcset=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1-_DX11_-2025_5_10-21_08_07.png 2560w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1-_DX11_-2025_5_10-21_08_07-300x180.png 300w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1-_DX11_-2025_5_10-21_08_07-1024x613.png 1024w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1-_DX11_-2025_5_10-21_08_07-768x460.png 768w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1-_DX11_-2025_5_10-21_08_07-1536x919.png 1536w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1-_DX11_-2025_5_10-21_08_07-2048x1226.png 2048w\" sizes=\"(max-width: 2560px) 100vw, 2560px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When I was trying to build the menu and inventory systems, I used a key-pressed function to toggle their appearance and disappearance. However, I encountered a problem: the new system shares the same layer as the game screen. Although the new system visually covers the game, the in-game items underneath can still be clicked through it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I realized that the issue occurred because my new system wasn\u2019t built on Unity\u2019s UI canvas. Since I don\u2019t know how to control everything through code, I could only rely on Fungus commands to achieve the effect I needed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now that I\u2019ve completed all the tasks, I\u2019ve realized that I could have simply disabled the clickable areas of the game screen when a key is pressed. That would\u2019ve achieved the effect I wanted as well. However, when I was building the system, I chose to create a new view to act as a separate canvas.<\/p>\n\n\n\n<figure class=\"wp-block-image alignwide size-full has-custom-border\"><img decoding=\"async\" width=\"1567\" height=\"1123\" src=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-21_56_19-1.png\" alt=\"\" class=\"wp-image-829\" style=\"border-width:5px\" srcset=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-21_56_19-1.png 1567w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-21_56_19-1-300x215.png 300w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-21_56_19-1-1024x734.png 1024w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-21_56_19-1-768x550.png 768w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-21_56_19-1-1536x1101.png 1536w\" sizes=\"(max-width: 1567px) 100vw, 1567px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-center\"><strong>Pressed Esc Key<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-media-text has-media-on-the-right is-stacked-on-mobile\" style=\"grid-template-columns:auto 64%\"><div class=\"wp-block-media-text__content\">\n<p class=\"wp-block-paragraph\">When the player presses the ESC key, Fungus executes this command.<\/p>\n<\/div><figure class=\"wp-block-media-text__media\"><img decoding=\"async\" width=\"638\" height=\"1024\" src=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-21_59_08-1-638x1024.png\" alt=\"\" class=\"wp-image-849 size-full\" srcset=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-21_59_08-1-638x1024.png 638w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-21_59_08-1-187x300.png 187w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-21_59_08-1.png 645w\" sizes=\"(max-width: 638px) 100vw, 638px\" \/><\/figure><\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">By switching the player\u2019s view to another camera view, the menu system\u2019s interface no longer overlaps with the interactive elements of the main game screen, effectively preventing any unwanted interference between the two.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-center\"><strong>Click Quit Button<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-media-text has-media-on-the-right is-stacked-on-mobile\" style=\"grid-template-columns:auto 64%\"><div class=\"wp-block-media-text__content\">\n<p class=\"wp-block-paragraph\">When the player selects the &#8220;Quit&#8221; option, Fungus executes the command to exit the game.<\/p>\n<\/div><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"647\" height=\"714\" src=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1-_DX11_-2025_5_10-22_21_18.png\" alt=\"\" class=\"wp-image-858 size-full\" srcset=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1-_DX11_-2025_5_10-22_21_18.png 647w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1-_DX11_-2025_5_10-22_21_18-272x300.png 272w\" sizes=\"(max-width: 647px) 100vw, 647px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-text-align-center\"><strong>Click Back Button<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">However, things get more complicated when the player wants to return to the game from the Esc menu. Since not every scene has only one game view, such as Scene: 3.2_Hallway and Scene: 3.2 Hallway, figuring out how to bring the player back to the exact view they were in before entering the Esc menu becomes a challenge.<\/p>\n\n\n\n<div class=\"wp-block-media-text has-media-on-the-right is-stacked-on-mobile\" style=\"grid-template-columns:auto 64%\"><div class=\"wp-block-media-text__content\">\n<p class=\"wp-block-paragraph\">Back button command in the scene which only has one view, for example, Scene: 2.2_Lobby<\/p>\n<\/div><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"643\" height=\"767\" src=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1-_DX11_-2025_5_10-22_30_18-1.png\" alt=\"\" class=\"wp-image-862 size-full\" srcset=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1-_DX11_-2025_5_10-22_30_18-1.png 643w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-2.2_Looby-Windows-Mac-Linux-Unity-2022.3.15f1-_DX11_-2025_5_10-22_30_18-1-251x300.png 251w\" sizes=\"(max-width: 643px) 100vw, 643px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-media-text has-media-on-the-right is-stacked-on-mobile\" style=\"grid-template-columns:auto 64%\"><div class=\"wp-block-media-text__content\">\n<p class=\"wp-block-paragraph\">Back button command in the scene which only has one view, for example, Scene: 3.2_Hallway<\/p>\n<\/div><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"504\" height=\"1024\" src=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-3.2_Hallway-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-22_29_46-1-504x1024.png\" alt=\"\" class=\"wp-image-866 size-full\" srcset=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-3.2_Hallway-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-22_29_46-1-504x1024.png 504w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-3.2_Hallway-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-22_29_46-1-148x300.png 148w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/My-project-5-3.2_Hallway-Windows-Mac-Linux-Unity-2022.3.15f1_-_DX11_-2025_5_10-22_29_46-1.png 638w\" sizes=\"(max-width: 504px) 100vw, 504px\" \/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Another issue comes up when dealing with multiple views: if the player opens the Esc menu without activating any of the variables tied to a specific view, the system doesn\u2019t know which view to return to, making the logic more complicated. So I also had to add a fallback command that returns the player to the first view if none of the view-related variables had been triggered.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Moreover, in the final scene, the Basement Scene, there are not only multiple views, but they\u2019re also divided into two groups based on the background. This makes the return logic even more complex.<\/p>\n\n\n\n<div class=\"wp-block-media-text has-media-on-the-right is-stacked-on-mobile\" style=\"grid-template-columns:auto 65%\"><div class=\"wp-block-media-text__content\">\n<p class=\"wp-block-paragraph\">Back button command in the Scene: 5.2_Basement<\/p>\n<\/div><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"643\" height=\"1919\" src=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/image-2.png\" alt=\"\" class=\"wp-image-869 size-full\" srcset=\"https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/image-2.png 643w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/image-2-101x300.png 101w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/image-2-343x1024.png 343w, https:\/\/sites.wsagames.com\/sl1c22\/wp-content\/uploads\/sites\/14\/2025\/05\/image-2-515x1536.png 515w\" sizes=\"(max-width: 643px) 100vw, 643px\" \/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">I set up group-based variables and used them to track the last view the player passed through, so the system can determine which view to return to.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When I was trying to build the menu and inventory systems, I used a key-pressed function to toggle their appearance and disappearance. However, I encountered a problem: the new system shares the same layer as the game screen. Although the new system visually covers the game, the in-game items underneath can still be clicked through [&hellip;]<\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,64,33],"tags":[],"class_list":["post-812","post","type-post","status-publish","format-standard","hentry","category-programing","category-systems-in-the-game","category-semester-2"],"_links":{"self":[{"href":"https:\/\/sites.wsagames.com\/sl1c22\/wp-json\/wp\/v2\/posts\/812","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.wsagames.com\/sl1c22\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.wsagames.com\/sl1c22\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.wsagames.com\/sl1c22\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.wsagames.com\/sl1c22\/wp-json\/wp\/v2\/comments?post=812"}],"version-history":[{"count":34,"href":"https:\/\/sites.wsagames.com\/sl1c22\/wp-json\/wp\/v2\/posts\/812\/revisions"}],"predecessor-version":[{"id":1320,"href":"https:\/\/sites.wsagames.com\/sl1c22\/wp-json\/wp\/v2\/posts\/812\/revisions\/1320"}],"wp:attachment":[{"href":"https:\/\/sites.wsagames.com\/sl1c22\/wp-json\/wp\/v2\/media?parent=812"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.wsagames.com\/sl1c22\/wp-json\/wp\/v2\/categories?post=812"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.wsagames.com\/sl1c22\/wp-json\/wp\/v2\/tags?post=812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}