{"id":31973,"date":"2024-11-01T09:04:36","date_gmt":"2024-11-01T09:04:36","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=31973"},"modified":"2024-11-01T11:33:53","modified_gmt":"2024-11-01T11:33:53","slug":"unity-basics-course-list-access","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/31973\/","title":{"rendered":"Unity Basics Course: List Access"},"content":{"rendered":"<p><body><\/p>\n<p>Hello! Today, we will learn about the usage of the list data structure, which is important in Unity development. Lists are useful tools for systematically managing data in games. The programming language we will use is C#, and we will explain in detail how to utilize lists in Unity.<\/p>\n<h2>Contents<\/h2>\n<ol>\n<li><a href=\"#list-intro\">1. What is a List?<\/a><\/li>\n<li><a href=\"#list-creation\">2. Creating a List<\/a><\/li>\n<li><a href=\"#list-operations\">3. Various Operations on a List<\/a><\/li>\n<li><a href=\"#list-access\">4. How to Access a List<\/a><\/li>\n<li><a href=\"#list-example\">5. Example Usage of a List<\/a><\/li>\n<li><a href=\"#list-best-practices\">6. Precautions and Tips for Using Lists<\/a><\/li>\n<li><a href=\"#conclusion\">7. Conclusion<\/a><\/li>\n<\/ol>\n<h2 id=\"list-intro\">1. What is a List?<\/h2>\n<p>A list is a data structure that can store multiple pieces of data sequentially. In C#, lists are dynamically sized and allow more flexibility in handling data compared to arrays. They are frequently used due to their ease of adding, removing, and accessing data. Lists are of a generic type, allowing you to define the type of data to be stored.<\/p>\n<h2 id=\"list-creation\">2. Creating a List<\/h2>\n<p>To create a list, you need to add <code>using System.Collections.Generic;<\/code>. After that, you can declare and initialize the list.<\/p>\n<pre>\n<code>using System.Collections.Generic;\n\nList&lt;int&gt; numbers = new List&lt;int&gt;(); \/\/ Integer list\nList&lt;string&gt; names = new List&lt;string&gt;(); \/\/ String list\n<\/code>\n<\/pre>\n<p>You can also add data while initializing the list. You can write it as follows.<\/p>\n<pre>\n<code>List&lt;string&gt; fruits = new List&lt;string&gt; { \"Apple\", \"Banana\", \"Cherry\" };\n<\/code>\n<\/pre>\n<h2 id=\"list-operations\">3. Various Operations on a List<\/h2>\n<p>Lists support various methods to facilitate data manipulation. Some key methods are:<\/p>\n<ul>\n<li><code>Add()<\/code>: Adds a value to the end of the list.<\/li>\n<li><code>Remove()<\/code>: Deletes a specific value.<\/li>\n<li><code>Insert()<\/code>: Adds a value at a specific index.<\/li>\n<li><code>Clear()<\/code>: Deletes all elements in the list.<\/li>\n<li><code>Count<\/code>: Returns the number of elements in the list.<\/li>\n<\/ul>\n<h2 id=\"list-access\">4. How to Access a List<\/h2>\n<p>To access the elements of a list, you use indices. Note that the list index starts from 0. For example, to access the first element, you use index 0.<\/p>\n<pre>\n<code>string firstFruit = fruits[0]; \/\/ \"Apple\"\nstring secondFruit = fruits[1]; \/\/ \"Banana\"\n<\/code>\n<\/pre>\n<p>You can also use indices to modify specific elements of the list. You can write it as follows.<\/p>\n<pre>\n<code>fruits[1] = \"Orange\"; \/\/ The list now becomes {\"Apple\", \"Orange\", \"Cherry\"}.\n<\/code>\n<\/pre>\n<h2 id=\"list-example\">5. Example Usage of a List<\/h2>\n<p>Now that we have learned the basic usage of lists, let&#8217;s write a simple Unity script. Below is an example that creates a list to store various fruits and prints all the elements of the list.<\/p>\n<pre>\n<code>using UnityEngine;\nusing System.Collections.Generic;\n\npublic class FruitManager : MonoBehaviour\n{\n    List&lt;string&gt; fruits;\n\n    void Start()\n    {\n        \/\/ Initialize the list\n        fruits = new List&lt;string&gt; { \"Apple\", \"Banana\", \"Cherry\" };\n\n        \/\/ Add fruits\n        fruits.Add(\"Orange\");\n        fruits.Add(\"Grape\");\n\n        \/\/ Print all fruits\n        foreach (string fruit in fruits)\n        {\n            Debug.Log(fruit);\n        }\n    }\n}\n<\/code>\n<\/pre>\n<h2 id=\"list-best-practices\">6. Precautions and Tips for Using Lists<\/h2>\n<p>There are a few precautions when using lists:<\/p>\n<ul>\n<li>Accessing an index when the list is empty will cause an <code>IndexOutOfRangeException<\/code>. Therefore, you should check if the list is not empty before accessing its elements.<\/li>\n<li>If you are adding or removing a lot of data in real time, performance may degrade. In such cases, consider using other data structures like <code>ArrayList<\/code> or <code>Dictionary<\/code>.<\/li>\n<li>If you want to sort the data within the list, you can use the <code>Sort()<\/code> method.<\/li>\n<\/ul>\n<h2 id=\"conclusion\">7. Conclusion<\/h2>\n<p>In this lesson, we learned how to create, access, and perform various operations with lists in Unity. Lists are tools that make data management easier and are commonly used in game development. Utilize them well to write efficient code.<\/p>\n<p>In the next lesson, we will cover advanced usage of lists and other data structures. Thank you!<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello! Today, we will learn about the usage of the list data structure, which is important in Unity development. Lists are useful tools for systematically managing data in games. The programming language we will use is C#, and we will explain in detail how to utilize lists in Unity. Contents 1. What is a List? &hellip; <a href=\"https:\/\/atmokpo.com\/w\/31973\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Unity Basics Course: List Access&#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-31973","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>Unity Basics Course: List Access - \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\/31973\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unity Basics Course: List Access - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Hello! Today, we will learn about the usage of the list data structure, which is important in Unity development. Lists are useful tools for systematically managing data in games. The programming language we will use is C#, and we will explain in detail how to utilize lists in Unity. Contents 1. What is a List? &hellip; \ub354 \ubcf4\uae30 &quot;Unity Basics Course: List Access&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/31973\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:04:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:33:53+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\/31973\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31973\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"Unity Basics Course: List Access\",\"datePublished\":\"2024-11-01T09:04:36+00:00\",\"dateModified\":\"2024-11-01T11:33:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31973\/\"},\"wordCount\":464,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Unity Basic\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/31973\/\",\"url\":\"https:\/\/atmokpo.com\/w\/31973\/\",\"name\":\"Unity Basics Course: List Access - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:04:36+00:00\",\"dateModified\":\"2024-11-01T11:33:53+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/31973\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/31973\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/31973\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unity Basics Course: List Access\"}]},{\"@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":"Unity Basics Course: List Access - \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\/31973\/","og_locale":"ko_KR","og_type":"article","og_title":"Unity Basics Course: List Access - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Hello! Today, we will learn about the usage of the list data structure, which is important in Unity development. Lists are useful tools for systematically managing data in games. The programming language we will use is C#, and we will explain in detail how to utilize lists in Unity. Contents 1. What is a List? &hellip; \ub354 \ubcf4\uae30 \"Unity Basics Course: List Access\"","og_url":"https:\/\/atmokpo.com\/w\/31973\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:04:36+00:00","article_modified_time":"2024-11-01T11:33:53+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\/31973\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/31973\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"Unity Basics Course: List Access","datePublished":"2024-11-01T09:04:36+00:00","dateModified":"2024-11-01T11:33:53+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/31973\/"},"wordCount":464,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Unity Basic"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/31973\/","url":"https:\/\/atmokpo.com\/w\/31973\/","name":"Unity Basics Course: List Access - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:04:36+00:00","dateModified":"2024-11-01T11:33:53+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/31973\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/31973\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/31973\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"Unity Basics Course: List Access"}]},{"@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\/31973","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=31973"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31973\/revisions"}],"predecessor-version":[{"id":31974,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/31973\/revisions\/31974"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=31973"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=31973"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=31973"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}