7
2023
UnityHub: Add support for custom project title (instead of folder name) or use ProductName
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’t know it the Title value affects something else)
Steps:
- Unpack app.asar from Hub folder (using 7zip Asar plugin https://www.tc4shell.com/en/7zip/asar/ or python script https://github.com/unitycoder/UnityHubPatcher )
- rename old app.asar as app.asar.bak
- Open app/ folder in VSCode/VSStudio (need to run as an Admin)
- Open localProject.js
- Add this line at top (near other definitions)
const kPCustomNamePath = path.join(ProjectSettingsFolderPath, ‘ProjectName.txt’); - modify getProjectData(projectPath) method
- Add these lines of code (inside green rectangles)
- Open projectDataHelpers.js
- Add these lines at the end
exports.getCustomProjectName = getCustomProjectName;
async function getCustomProjectName(customNamePath, defaultName) {
try {
const customName = await fileSystem_1.fs.readFile(customNamePath, ‘utf8’);
return customName.trim();
} catch (error) {
return defaultName;
}
} - Make sure Hub process is closed completely (not minimized)
- Save script changes
- You can now add ProjectName.txt file inside Project settings to some of your projects to test it
- Start hub again, if everything is correct, it should display custom title for that project
So then it uses same ProjectName.txt file like my custom launcher (which allows project rename with F2)
https://github.com/unitycoder/UnityLauncherPro
UPDATE 19.12.2023, you can add support for reading ProjectSettings Product Name field also, use this for the getCustomProjectName method:
exports.getCustomProjectName = getCustomProjectName;
async function getCustomProjectName(customNamePath, defaultName) {
try {
// if ProjectName.txt exists
const customName = await fileSystem_1.fs.readFile(customNamePath, 'utf8');
return customName.trim();
} catch (error) {
}
try {
// try to read ProjectSettings.asset next
let settingsFilePath = customNamePath.replace("ProjectName.txt",""+"/ProjectSettings.asset");
console.log(settingsFilePath);
const settingsNameRaw = await fileSystem_1.fs.readFile(settingsFilePath, 'utf8');
const settingsName = settingsNameRaw.match(/productName: (.*)/)[1];
return settingsName.trim();
} catch (error) {
//console.log(error.Error);
}
return defaultName;
}
*08.12.2023 Generic disclaimer: For Education Purposes Only.
Related Posts
Leave a comment
Recent posts
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
Recent Comments
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- ffmpeg stream raw video into Unity Texture2D on