{"id":31868,"date":"2024-11-01T09:03:39","date_gmt":"2024-11-01T09:03:39","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=31868"},"modified":"2024-11-01T11:34:21","modified_gmt":"2024-11-01T11:34:21","slug":"basic-unity-course-displaying-the-network-room-list","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/31868\/","title":{"rendered":"Basic Unity Course: Displaying the Network Room List"},"content":{"rendered":"<p><body><\/p>\n<h2>1. Introduction<\/h2>\n<p>In game development, multiplayer features provide a variety of experiences. In this tutorial, we will learn how to display a network room list using Unity. This tutorial is written for beginners and is based on an understanding of basic Unity usage and C# programming.<\/p>\n<h2>2. Unity and Networking<\/h2>\n<p>Unity offers various networking solutions. UNet (Unity Network) is one of them, useful for setting up basic multiplayer environments. As of Unity 2020.1, UNet has been deprecated, and the new networking framework MLAPI has been introduced. This tutorial will focus on MLAPI.<\/p>\n<h2>3. Preparation<\/h2>\n<h3>3.1. Installing Unity<\/h3>\n<p>To install Unity, download Unity Hub and install the desired version of Unity. MLAPI is supported on Unity version 2019.4 and above.<\/p>\n<h3>3.2. Adding the MLAPI Package<\/h3>\n<p>To add MLAPI to your project, use the Unity Package Manager. In the Unity editor, select &#8216;Window&#8217; -&gt; &#8216;Package Manager&#8217;, then select &#8216;Add package from git URL&#8230;&#8217; and enter <code>https:\/\/github.com\/Unity-Technologies\/Mirror.git<\/code>.<\/p>\n<h2>4. Creating a New Unity Project<\/h2>\n<p>Create a new Unity project and select the 3D template. Once the project is created, you will be ready to add all necessary assets and networking-related scripts.<\/p>\n<h2>5. Setting Up the Scene<\/h2>\n<p>Create a new scene and add a basic camera and lighting. Add a skybox and a few 3D objects to create a test environment.<\/p>\n<h2>6. Adding a Network Manager<\/h2>\n<p>To manage the network, add a <code>NetworkManager<\/code> component to the scene. The <code>NetworkManager<\/code> is responsible for creating and managing network rooms. After creating the game object, set it up as follows:<\/p>\n<pre><code>NetworkManager manager = gameObject.AddComponent&lt;NetworkManager&gt;();<\/code><\/pre>\n<h2>7. Setting Up UI to Display Room List<\/h2>\n<h3>7.1. Adding UI Elements<\/h3>\n<p>To display the room list in the UI, add a <code>Canvas<\/code> and use <code>Text<\/code> and <code>Button<\/code> elements to construct the UI that will display the room list.<\/p>\n<h3>7.2. Writing UI Scripts<\/h3>\n<p>Write a script to display the room list. Below is an example of the basic code to retrieve room information.<\/p>\n<pre><code>\nusing UnityEngine;\nusing UnityEngine.UI;\nusing UnityEngine.Networking;\nusing System.Collections.Generic;\n\npublic class RoomList : MonoBehaviour\n{\n    public GameObject roomButtonPrefab;\n    public Transform roomListContainer;\n\n    void Start()\n    {\n        NetworkManager.singleton.OnMatchList += OnMatchList;\n        NetworkManager.singleton.ListMatches(0, 20, \"\", OnMatchList);\n    }\n\n    void OnMatchList(bool success, string extendedInfo, List<matchinfosnapshot> matches)\n    {\n        foreach (Transform child in roomListContainer)\n        {\n            Destroy(child.gameObject);\n        }\n\n        if (success)\n        {\n            foreach (var match in matches)\n            {\n                Instantiate(roomButtonPrefab, roomListContainer).GetComponentInChildren<text>().text = match.name;\n            }\n        }\n    }\n}\n<\/text><\/matchinfosnapshot><\/code><\/pre>\n<h2>8. Creating a Room<\/h2>\n<p>Additional functionality is needed to allow users to create a room by clicking a button. Implement room creation by adding the following function.<\/p>\n<pre><code>\npublic void CreateRoom()\n{\n    NetworkManager.singleton.StartMatchMaker();\n    NetworkManager.singleton.matchMaker.CreateMatch(\"RoomName\", 2, true, \"\", \"\", \"\", 0, 0, OnMatchCreate);\n}\n\nvoid OnMatchCreate(bool success, string extendedInfo, MatchInfo match)\n{\n    if (success)\n    {\n        NetworkManager.singleton.StartHost();\n    }\n}\n<\/code><\/pre>\n<h2>9. Joining a Room<\/h2>\n<p>Add a UI button to allow users to join a room and implement the functionality to join a room with the following code.<\/p>\n<pre><code>\npublic void JoinRoom(MatchInfoSnapshot match)\n{\n    NetworkManager.singleton.StartMatchMaker();\n    NetworkManager.singleton.matchMaker.JoinMatch(match.networkId, \"\", OnMatchJoin);\n}\n\nvoid OnMatchJoin(bool success, string extendedInfo, MatchInfo match)\n{\n    if (success)\n    {\n        NetworkManager.singleton.StartClient();\n    }\n}\n<\/code><\/pre>\n<h2>10. Testing and Debugging<\/h2>\n<p>Once all scripts and UI are complete, test the multiplayer functionality in the Unity editor. Create a room and check the room list from another client to verify everything is working correctly.<\/p>\n<h2>11. Conclusion<\/h2>\n<p>This tutorial taught you how to display a network room list in Unity. Additional features such as room deletion, modifying room information, and UI improvements can provide a better user experience. We plan to continue covering in-depth topics on Unity and networking.<\/p>\n<h2>12. References<\/h2>\n<ul>\n<li><a href=\"https:\/\/docs.unity3d.com\/Manual\/UNetSetup.html\">Unity UNet Documentation<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/Unity-Technologies\/Mirror\">Unity Mirror Documentation<\/a><\/li>\n<\/ul>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction In game development, multiplayer features provide a variety of experiences. In this tutorial, we will learn how to display a network room list using Unity. This tutorial is written for beginners and is based on an understanding of basic Unity usage and C# programming. 2. Unity and Networking Unity offers various networking solutions. &hellip; <a href=\"https:\/\/atmokpo.com\/w\/31868\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Basic Unity Course: Displaying the Network Room List&#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-31868","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: Displaying the Network Room List - \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\/31868\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Basic Unity Course: Displaying the Network Room List - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"1. Introduction In game development, multiplayer features provide a variety of experiences. In this tutorial, we will learn how to display a network room list using Unity. This tutorial is written for beginners and is based on an understanding of basic Unity usage and C# programming. 2. Unity and Networking Unity offers various networking solutions. &hellip; \ub354 \ubcf4\uae30 &quot;Basic Unity Course: Displaying the Network Room List&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/31868\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:03:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:34:21+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\/31868\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31868\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Basic Unity Course: Displaying the Network Room List\",\"datePublished\":\"2024-11-01T09:03:39+00:00\",\"dateModified\":\"2024-11-01T11:34:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31868\/\"},\"wordCount\":442,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Unity Basic\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/31868\/\",\"url\":\"https:\/\/atmokpo.com\/w\/31868\/\",\"name\":\"Basic Unity Course: Displaying the Network Room List - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:03:39+00:00\",\"dateModified\":\"2024-11-01T11:34:21+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31868\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/31868\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/31868\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Basic Unity Course: Displaying the Network Room List\"}]},{\"@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: Displaying the Network Room List - \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\/31868\/","og_locale":"ko_KR","og_type":"article","og_title":"Basic Unity Course: Displaying the Network Room List - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"1. Introduction In game development, multiplayer features provide a variety of experiences. In this tutorial, we will learn how to display a network room list using Unity. This tutorial is written for beginners and is based on an understanding of basic Unity usage and C# programming. 2. Unity and Networking Unity offers various networking solutions. &hellip; \ub354 \ubcf4\uae30 \"Basic Unity Course: Displaying the Network Room List\"","og_url":"https:\/\/atmokpo.com\/w\/31868\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:03:39+00:00","article_modified_time":"2024-11-01T11:34:21+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\/31868\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/31868\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Basic Unity Course: Displaying the Network Room List","datePublished":"2024-11-01T09:03:39+00:00","dateModified":"2024-11-01T11:34:21+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/31868\/"},"wordCount":442,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Unity Basic"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/31868\/","url":"https:\/\/atmokpo.com\/w\/31868\/","name":"Basic Unity Course: Displaying the Network Room List - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:03:39+00:00","dateModified":"2024-11-01T11:34:21+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/31868\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/31868\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/31868\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Basic Unity Course: Displaying the Network Room List"}]},{"@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\/31868","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=31868"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31868\/revisions"}],"predecessor-version":[{"id":31869,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31868\/revisions\/31869"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=31868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=31868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=31868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}