{"id":964,"date":"2018-03-19T22:39:14","date_gmt":"2018-03-19T19:39:14","guid":{"rendered":"http:\/\/enisnecipoglu.com\/?p=964"},"modified":"2018-03-19T22:53:35","modified_gmt":"2018-03-19T19:53:35","slug":"unity-3d-son-c-surumunu-kullanmak-c-7-1","status":"publish","type":"post","link":"https:\/\/enisnecipoglu.com\/en\/unity-3d-son-c-surumunu-kullanmak-c-7-1\/","title":{"rendered":"Unity 3D Using Latest C# version (C# 7.1)"},"content":{"rendered":"<p><\/p>\n<h1>Tasks in Unity<\/h1>\n<p>As you know there is no way to use\u00a0<strong>System.Threading.Tasks<\/strong> in Unity 3D as normal way. This library is no accessible in default unity 3D project template. You should use IEnumerator to use\u00a0continuously background activities or tasks. If you could use latest C# version you can use Tasks too.<\/p>\n<h1>Lambda Expressions in Unity<\/h1>\n<p>In Unity, you can use LINQ methods and send parameters into them as Func with lambda expressions but, property get and set mothods or single line method writing is not supported in default in Unity.<\/p>\n<h1>.Net Framework in Unity<\/h1>\n<p>A default Unity 3D project supports .Net <strong>Framework 3.5<\/strong> with <strong>C# 4.0<\/strong>. Why it does not contain latest versions of these?<\/p>\n<p>When Unity compile a project, takes all your C#code and serialize them to convert C++ to create a C++ Library. It&#8217;s not easy to support immediately newest versions. But there is a way to use latest .Net Framework and C# version in unity projects but there is a <strong>warning by Unity<\/strong>: It&#8217;s not stable. I&#8217;m using latest version and I haven&#8217;t got any negative situation until now. Let&#8217;s see how to use latest libraries:<\/p>\n<p>&nbsp;<\/p>\n<h1>Upgrading Latest C# and .Net Framework<\/h1>\n<p>Go <strong>File&gt;Build Setings\u00a0<\/strong>In Unity Editor. See this windows like below:<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-965\" src=\"http:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/03\/unityLatestFramework_00-300x291.png\" alt=\"Unity 3D Player Settings Enis Necipoglu using latest .Net Framework Version C#\" width=\"300\" height=\"291\" srcset=\"https:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/03\/unityLatestFramework_00-300x291.png 300w, https:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/03\/unityLatestFramework_00.png 630w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>Click to\u00a0<strong>Player Settings\u00a0<\/strong>from here. Some properties will come to the\u00a0<strong>Inspector\u00a0<\/strong>window which is going to be like:<\/p>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-966 alignleft\" src=\"http:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/03\/unityLatestFramework_01-124x300.png\" alt=\"Unity 3D Build Settings Enis Necipoglu using latest .Net Framework C#\" width=\"124\" height=\"300\" srcset=\"https:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/03\/unityLatestFramework_01-124x300.png 124w, https:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/03\/unityLatestFramework_01.png 324w\" sizes=\"(max-width: 124px) 100vw, 124px\" \/><\/p>\n<p>Go to\u00a0<strong>Other Settings<\/strong> windows from here and find\u00a0<strong>Scripting Runtime Version<\/strong> property. Switch it to\u00a0<strong>.Net Framework 4.6<\/strong><\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-medium wp-image-967\" src=\"http:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/03\/unityLatestFramework_02-300x121.png\" alt=\"Unity 3D Build Settings scripting runtime version using latest .Net Framework C# Enis Necipoglu\" width=\"300\" height=\"121\" srcset=\"https:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/03\/unityLatestFramework_02-300x121.png 300w, https:\/\/enisnecipoglu.com\/wp-content\/uploads\/2018\/03\/unityLatestFramework_02.png 327w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Then you need to restart your Unity 3D. After restarting go your editor and use latest features without any Errors.<\/p>","protected":false},"excerpt":{"rendered":"Tasks in Unity As you know there is no way to use\u00a0System.Threading.Tasks in Unity 3D as normal way. This library is no accessible in default unity 3D project template. You should use IEnumerator to use\u00a0continuously background activities or tasks. If you could use latest C# version you can use Tasks too. Lambda Expressions in Unity In Unity, you can use LINQ methods and send parameters into them as Func with lambda expressions but, property get and set mothods or single line method writing is not supported in default in Unity. .Net Framework in Unity A default Unity 3D project supports .Net Framework 3.5 with C# 4.0. Why it does not contain latest versions of these? When Unity compile a project, takes all your C#code and serialize them to convert C++ to create a C++ Library. It&#8217;s not easy to support immediately newest versions. But there is a way to use latest .Net Framework and C# version in unity projects but there is a warning by Unity: It&#8217;s not stable. I&#8217;m using latest version and I haven&#8217;t got any negative situation until now. Let&#8217;s see how to use latest libraries: &nbsp; Upgrading Latest C# and .Net Framework Go File&gt;Build Setings\u00a0In Unity Editor. See this windows like below: Click to\u00a0Player Settings\u00a0from here. Some properties will come to the\u00a0Inspector\u00a0window which is going to be like: Go to\u00a0Other Settings windows from here and find\u00a0Scripting Runtime Version property. Switch it to\u00a0.Net Framework 4.6 &nbsp; &nbsp; &nbsp; &nbsp; Then you need to restart your Unity 3D. After restarting go your editor and use latest features without any Errors.","protected":false},"author":1,"featured_media":971,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,6],"tags":[],"_links":{"self":[{"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/posts\/964"}],"collection":[{"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/comments?post=964"}],"version-history":[{"count":3,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/posts\/964\/revisions"}],"predecessor-version":[{"id":970,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/posts\/964\/revisions\/970"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/media\/971"}],"wp:attachment":[{"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/media?parent=964"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/categories?post=964"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enisnecipoglu.com\/en\/wp-json\/wp\/v2\/tags?post=964"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}