{"id":31876,"date":"2024-11-01T09:03:43","date_gmt":"2024-11-01T09:03:43","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=31876"},"modified":"2024-11-01T11:34:20","modified_gmt":"2024-11-01T11:34:20","slug":"basic-unity-course","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/31876\/","title":{"rendered":"Basic Unity Course"},"content":{"rendered":"<p><body><\/p>\n<h2>Network Lobby Screen: Join Room<\/h2>\n<p>Hello! In this course, we will learn how to implement a lobby screen in a network game using Unity. Specifically, we will focus on the &#8220;Join Room&#8221; feature and explain various methods. During this process, we will use Unity&#8217;s <strong>UNet<\/strong> to implement network functionality and later expand to other network libraries like <strong>Mirror<\/strong>.<\/p>\n<h2>1. Understanding the Concept of Network Lobby<\/h2>\n<p>The network lobby refers to a space where players wait before joining a specific room in multiplayer games. In the lobby, players gather to adjust game settings and perform tasks such as joining or creating rooms.<\/p>\n<h3>1.1 Key Features of the Lobby<\/h3>\n<ul>\n<li>Create Room<\/li>\n<li>View Room List<\/li>\n<li>Join Room<\/li>\n<li>Leave Room<\/li>\n<li>Start and End Game<\/li>\n<\/ul>\n<h3>1.2 Setting Up the Network<\/h3>\n<p>To enable network functionality in Unity, you must first set up &#8220;<strong>Unity Multiplayer<\/strong>&#8220;. Install the UNet package via Unity&#8217;s <strong>Package Manager<\/strong>. You can develop network functionality using this package.<\/p>\n<h2>2. Setting Up the Project<\/h2>\n<p>First, create a new Unity project. Next, I will add the necessary UI components to implement the lobby screen.<\/p>\n<pre><code>using UnityEngine;\nusing UnityEngine.UI;\n\npublic class Lobby : MonoBehaviour\n{\n    public Button createRoomButton;\n    public Button joinRoomButton;\n\n    void Start()\n    {\n        createRoomButton.onClick.AddListener(CreateRoom);\n        joinRoomButton.onClick.AddListener(JoinRoom);\n    }\n\n    void CreateRoom()\n    {\n        \/\/ Implement room creation logic\n    }\n\n    void JoinRoom()\n    {\n        \/\/ Implement room joining logic\n    }\n}<\/code><\/pre>\n<h2>3. Creating a Room<\/h2>\n<p>To create a room, you need to set up the network manager and write the logic for creating a room. Here is an example of room creation code.<\/p>\n<pre><code>using UnityEngine.Networking;\n\nvoid CreateRoom()\n{\n    if (NetworkServer.active)\n    {\n        \/\/ Cannot create a room if the server is already running.\n        Debug.Log(\"The server is already running.\");\n        return;\n    }\n\n    \/\/ Set room properties\n    RoomOptions roomOptions = new RoomOptions();\n    roomOptions.MaxPlayers = 4; \/\/ Maximum number of players\n\n    \/\/ Create room\n    NetworkManager.singleton.CreateRoom(\"New Room\", roomOptions);\n    Debug.Log(\"The room has been created.\");\n}<\/code><\/pre>\n<h2>4. Getting the Room List<\/h2>\n<p>After creating a room, we need to display the current list of existing rooms. We will learn about the necessary UI elements and how to update room information.<\/p>\n<pre><code>using UnityEngine.Networking;\nusing UnityEngine.UI;\n\npublic void UpdateRoomList()\n{\n    \/\/ Get room list\n    foreach (RoomInfo room in NetworkManager.singleton.RoomList)\n    {\n        \/\/ Update room information in UI\n        Debug.Log(\"Room Name: \" + room.Name);\n    }\n}<\/code><\/pre>\n<h2>5. Joining a Room<\/h2>\n<p>I will also explain how players can join a room. Here, we will add logic to receive the room name and join that room.<\/p>\n<pre><code>void JoinRoom(string roomName)\n{\n    if (string.IsNullOrEmpty(roomName))\n    {\n        Debug.Log(\"Room name is empty.\");\n        return;\n    }\n\n    NetworkManager.singleton.JoinRoom(roomName);\n    Debug.Log(\"Joining room: \" + roomName);\n}<\/code><\/pre>\n<h2>6. Leaving a Room<\/h2>\n<p>We can also implement the functionality to leave a room. The player will be able to leave the room and return to the lobby screen.<\/p>\n<pre><code>void LeaveRoom()\n{\n    if (!NetworkServer.active)\n    {\n        \/\/ Leave the room if not a server\n        NetworkManager.singleton.LeaveRoom();\n        Debug.Log(\"Left the room.\");\n        \/\/ Add logic to return to the lobby screen\n    }\n}<\/code><\/pre>\n<h2>7. Starting the Game<\/h2>\n<p>We also need to consider the feature to start the game after all players have joined the room. We can check if all players are ready and start the game.<\/p>\n<pre><code>void StartGame()\n{\n    if (AllPlayersReady())\n    {\n        \/\/ Game start logic\n        Debug.Log(\"Starting the game.\");\n    }\n}\n\nbool AllPlayersReady()\n{\n    \/\/ Logic to check if all players are ready\n    \/\/ Testing with a simple return of true\n    return true;\n}<\/code><\/pre>\n<h2>8. Testing and Debugging<\/h2>\n<p>Once the code is complete, we need to test it locally. Using Unity&#8217;s play mode, we should create and join rooms, finding and fixing any errors that occur during the process.<\/p>\n<h2>9. Implementing Additional Features<\/h2>\n<p>In addition to basic room creation and joining, various features can be added to enhance the lobby interface. For example, displaying room information, player status, and implementing a chat system.<\/p>\n<h2>10. Conclusion<\/h2>\n<p>Through this course, we have learned how to implement a network lobby screen in Unity and how to join rooms. Based on this foundational knowledge, you can create more complex network games. In the next course, we will learn how to further develop these features.<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Network Lobby Screen: Join Room Hello! In this course, we will learn how to implement a lobby screen in a network game using Unity. Specifically, we will focus on the &#8220;Join Room&#8221; feature and explain various methods. During this process, we will use Unity&#8217;s UNet to implement network functionality and later expand to other network &hellip; <a href=\"https:\/\/atmokpo.com\/w\/31876\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Basic Unity Course&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[135],"tags":[],"class_list":["post-31876","post","type-post","status-publish","format-standard","hentry","category-unity-basic"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Basic Unity Course - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/31876\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Basic Unity Course - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Network Lobby Screen: Join Room Hello! In this course, we will learn how to implement a lobby screen in a network game using Unity. Specifically, we will focus on the &#8220;Join Room&#8221; feature and explain various methods. During this process, we will use Unity&#8217;s UNet to implement network functionality and later expand to other network &hellip; \ub354 \ubcf4\uae30 &quot;Basic Unity Course&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/31876\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:03:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:34:20+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/31876\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31876\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Basic Unity Course\",\"datePublished\":\"2024-11-01T09:03:43+00:00\",\"dateModified\":\"2024-11-01T11:34:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31876\/\"},\"wordCount\":444,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Unity Basic\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/31876\/\",\"url\":\"https:\/\/atmokpo.com\/w\/31876\/\",\"name\":\"Basic Unity Course - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:03:43+00:00\",\"dateModified\":\"2024-11-01T11:34:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31876\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/31876\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/31876\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Basic Unity Course\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Basic Unity Course - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/31876\/","og_locale":"ko_KR","og_type":"article","og_title":"Basic Unity Course - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Network Lobby Screen: Join Room Hello! In this course, we will learn how to implement a lobby screen in a network game using Unity. Specifically, we will focus on the &#8220;Join Room&#8221; feature and explain various methods. During this process, we will use Unity&#8217;s UNet to implement network functionality and later expand to other network &hellip; \ub354 \ubcf4\uae30 \"Basic Unity Course\"","og_url":"https:\/\/atmokpo.com\/w\/31876\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:03:43+00:00","article_modified_time":"2024-11-01T11:34:20+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/31876\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/31876\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Basic Unity Course","datePublished":"2024-11-01T09:03:43+00:00","dateModified":"2024-11-01T11:34:20+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/31876\/"},"wordCount":444,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Unity Basic"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/31876\/","url":"https:\/\/atmokpo.com\/w\/31876\/","name":"Basic Unity Course - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:03:43+00:00","dateModified":"2024-11-01T11:34:20+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/31876\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/31876\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/31876\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Basic Unity Course"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31876","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=31876"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31876\/revisions"}],"predecessor-version":[{"id":31877,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31876\/revisions\/31877"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=31876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=31876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=31876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}