{"id":5709,"date":"2023-12-07T14:05:32","date_gmt":"2023-12-07T12:05:32","guid":{"rendered":"https:\/\/unitycoder.com\/blog\/?p=5709"},"modified":"2023-12-19T09:36:14","modified_gmt":"2023-12-19T07:36:14","slug":"unityhub-add-support-for-custom-project-titles-instead-of-folder-name","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2023\/12\/07\/unityhub-add-support-for-custom-project-titles-instead-of-folder-name\/","title":{"rendered":"UnityHub: Add support for custom project title (instead of folder name) or use ProductName"},"content":{"rendered":"\n<p>This request has been open since 2018..<br><a href=\"https:\/\/forum.unity.com\/threads\/renaming-projects.514061\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/forum.unity.com\/threads\/renaming-projects.514061\/<\/a><\/p>\n\n\n\n<p>So had to test it myself and seems to be really simple <br>(*** as a proof of concept, i don&#8217;t know it the Title value affects something else)<br><\/p>\n\n\n\n<p><strong>Steps:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Unpack app.asar from Hub folder (using 7zip Asar plugin <a href=\"https:\/\/www.tc4shell.com\/en\/7zip\/asar\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.tc4shell.com\/en\/7zip\/asar\/<\/a> or python script <a href=\"https:\/\/github.com\/unitycoder\/UnityHubPatcher\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/unitycoder\/UnityHubPatcher<\/a> )<\/li>\n\n\n\n<li>rename old app.asar as app.asar.bak<\/li>\n\n\n\n<li>Open app\/ folder in VSCode\/VSStudio (need to run as an Admin)<\/li>\n\n\n\n<li>Open <strong>localProject.js<\/strong><\/li>\n\n\n\n<li>Add this line at top (near other definitions)<br><em>const kPCustomNamePath = path.join(ProjectSettingsFolderPath, &#8216;ProjectName.txt&#8217;);<\/em><\/li>\n\n\n\n<li>modify getProjectData(projectPath) method<\/li>\n\n\n\n<li>Add these lines of code (inside green rectangles)<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image-1.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"762\" height=\"298\" data-attachment-id=\"5711\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2023\/12\/07\/unityhub-add-support-for-custom-project-titles-instead-of-folder-name\/image-1-16\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image-1.png?fit=762%2C298&amp;ssl=1\" data-orig-size=\"762,298\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image-1.png?fit=762%2C298&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image-1.png?resize=762%2C298&#038;ssl=1\" alt=\"\" class=\"wp-image-5711\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image-1.png?w=762&amp;ssl=1 762w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image-1.png?resize=300%2C117&amp;ssl=1 300w\" sizes=\"auto, (max-width: 762px) 100vw, 762px\" \/><\/a><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open <strong>projectDataHelpers.js<\/strong><\/li>\n\n\n\n<li>Add these lines at the end<br><em>exports.getCustomProjectName = getCustomProjectName;<br>async function getCustomProjectName(customNamePath, defaultName) {<br>&nbsp; &nbsp; &nbsp;try {<br>&nbsp; &nbsp; &nbsp; &nbsp;const customName = await fileSystem_1.fs.readFile(customNamePath, &#8216;utf8&#8217;);<br>&nbsp; &nbsp; &nbsp; &nbsp;return customName.trim();<br>&nbsp; &nbsp; &nbsp;} catch (error) {<br>&nbsp; &nbsp; &nbsp; &nbsp;return defaultName;<br>&nbsp; &nbsp; &nbsp;}<br>}<\/em><\/li>\n\n\n\n<li>Make sure Hub process is closed completely (not minimized)<\/li>\n\n\n\n<li>Save script changes<\/li>\n\n\n\n<li>You can now add ProjectName.txt file inside Project settings to some of your projects to test it<\/li>\n\n\n\n<li>Start hub again, if everything is correct, it should display custom title for that project<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"855\" data-attachment-id=\"5710\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2023\/12\/07\/unityhub-add-support-for-custom-project-titles-instead-of-folder-name\/image-38\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image.png?fit=1085%2C906&amp;ssl=1\" data-orig-size=\"1085,906\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image.png?fit=1024%2C855&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image.png?resize=1024%2C855&#038;ssl=1\" alt=\"\" class=\"wp-image-5710\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image.png?resize=1024%2C855&amp;ssl=1 1024w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image.png?resize=300%2C251&amp;ssl=1 300w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image.png?resize=768%2C641&amp;ssl=1 768w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image.png?w=1085&amp;ssl=1 1085w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a><\/figure>\n\n\n\n<p>So then it uses same ProjectName.txt file like my custom launcher (which allows project rename with F2)<br><a href=\"https:\/\/github.com\/unitycoder\/UnityLauncherPro\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/unitycoder\/UnityLauncherPro<\/a><\/p>\n\n\n\n<p>UPDATE 19.12.2023, you can add support for reading ProjectSettings Product Name field also, use this for the getCustomProjectName method:<br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>exports.getCustomProjectName = getCustomProjectName;\nasync function getCustomProjectName(customNamePath, defaultName) {\n     try {\n        \/\/ if ProjectName.txt exists\n       const customName = await fileSystem_1.fs.readFile(customNamePath, 'utf8');\n       return customName.trim();\n     } catch (error) {\n     }\n     try {\n        \/\/ try to read ProjectSettings.asset next\n        let settingsFilePath = customNamePath.replace(\"ProjectName.txt\",\"\"+\"\/ProjectSettings.asset\");\n        console.log(settingsFilePath);\n        const settingsNameRaw = await fileSystem_1.fs.readFile(settingsFilePath, 'utf8');\n        const settingsName = settingsNameRaw.match(\/productName: (.*)\/)&#91;1];\n        return settingsName.trim();\n    } catch (error) {\n        \/\/console.log(error.Error);\n    }\n    return defaultName;\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><em>*08.12.2023 Generic disclaimer: For Education Purposes Only.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This request has been open since 2018..https:\/\/forum.unity.com\/threads\/renaming-projects.514061\/ So had to test it myself and seems to be really simple (*** as a proof of concept, i don&#8217;t know it the Title value affects something else) Steps: So then it uses same ProjectName.txt file like my [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5710,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":false,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1267],"tags":[568,1236,1269,1268],"class_list":["post-5709","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-unityhub","tag-custom","tag-hub","tag-modification","tag-unityhub"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2023\/12\/image.png?fit=1085%2C906&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-1u5","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/5709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=5709"}],"version-history":[{"count":9,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/5709\/revisions"}],"predecessor-version":[{"id":5727,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/5709\/revisions\/5727"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/5710"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=5709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=5709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=5709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}