├── .github └── FUNDING.yml ├── .gitignore ├── CHANGELOG.md ├── CHANGELOG.md.meta ├── Documentation.meta ├── Documentation ├── README.md └── README.md.meta ├── Editor.meta ├── Editor ├── AssetGUIDRegenerator.cs ├── AssetGUIDRegenerator.cs.meta ├── jeffjadulco.guidregenerator.editor.asmdef └── jeffjadulco.guidregenerator.editor.asmdef.meta ├── LICENSE.md ├── LICENSE.md.meta ├── README.md ├── README.md.meta ├── assets.meta ├── assets ├── DemoScriptMeta.png ├── DemoScriptMeta.png.meta ├── instructions-1.png └── instructions-1.png.meta ├── package.json └── package.json.meta /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | ko_fi: jeffjadulco 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | */[Ll]ibrary/ 14 | */[Tt]emp/ 15 | */[Oo]bj/ 16 | */[Bb]uild/ 17 | */[Bb]uilds/ 18 | */[Ll]ogs/ 19 | */[Mm]emoryCaptures/ 20 | 21 | # Asset meta data should only be ignored when the corresponding asset is also ignored 22 | !/[Aa]ssets/**/*.meta 23 | 24 | # Uncomment this line if you wish to ignore the asset store tools plugin 25 | # /[Aa]ssets/AssetStoreTools* 26 | 27 | # Autogenerated Jetbrains Rider plugin 28 | [Aa]ssets/Plugins/Editor/JetBrains* 29 | 30 | # Visual Studio cache directory 31 | .vs/ 32 | 33 | # Gradle cache directory 34 | .gradle/ 35 | 36 | # Autogenerated VS/MD/Consulo solution and project files 37 | ExportedObj/ 38 | .consulo/ 39 | *.csproj 40 | *.unityproj 41 | *.sln 42 | *.suo 43 | *.tmp 44 | *.user 45 | *.userprefs 46 | *.pidb 47 | *.booproj 48 | *.svd 49 | *.pdb 50 | *.mdb 51 | *.opendb 52 | *.VC.db 53 | 54 | # Unity3D generated meta files 55 | *.pidb.meta 56 | *.pdb.meta 57 | *.mdb.meta 58 | 59 | # Unity3D generated file on crash reports 60 | sysinfo.txt 61 | 62 | # Builds 63 | *.apk 64 | *.unitypackage 65 | 66 | # Crashlytics generated file 67 | crashlytics-build.properties 68 | 69 | # IDE generated files 70 | .vscode/ 71 | */.idea/ 72 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 1.0.5 (2023.01.31) 2 | - **Fix**: Broken material references on an FBX asset when using legacy/remapped materials 3 | 4 | ### 1.0.4 (2021.09.04) 5 | - **Improved**: Faster regeneration time. Thanks to @mayofunk 6 | 7 | ### 1.0.3 (2021.05.14) 8 | 9 | - **New**: Added option to include folders to the list of guids to be generated 10 | 11 | ### 1.0.2 (2021.02.21) 12 | 13 | - **New**: Support installation via UPM (Unity Package Manager) 14 | 15 | ### 1.0.1 (2020.08.21) 16 | 17 | - **New**: Directory and subdirectories support 18 | -------------------------------------------------------------------------------- /CHANGELOG.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5857b2ac7b43c74dbb5fbd7af6c0f57 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Documentation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b13ed078e221b84ea5b5873cd378e96 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Documentation/README.md: -------------------------------------------------------------------------------- 1 | # :id: Unity GUID Regenerator 2 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) 3 | 4 | A Unity editor tool to regenerate GUID for your assets 5 | 6 | > **Disclaimer**: Only use this if needed. Intentionally modifying the GUID of an asset is not recommended unless certain issues are encountered 7 | 8 | ## What is GUID in Unity? 9 | GUID is a unique hash that is automatically generated and assigned when creating a new asset. This GUID is used when a serialized asset references another asset. 10 | 11 | ![GUID](assets/DemoScriptMeta.png) 12 | 13 | It is stored in an asset's meta file. Manually you can open and view a meta file in a text editor to get the GUID. However, Unity has its [AssetDatabase](https://docs.unity3d.com/ScriptReference/AssetDatabase.html) API that is useful for accessing and performing operations on assets. 14 | 15 | ## Why regenerate a GUID? 16 | When you work on multiple projects that are based on existing projects, chances are most of the assets have the same GUID. This can cause some issues later on when you add more assets from existing projects. Unity won't be able to distinguish the difference between assets with same GUID even they have different file name and contents. This can cause Unity to associate references to the wrong asset. 17 | 18 | The simplest workaround for this is to duplicate the asset. The newly created asset will have its own GUID assigned by Unity. However, you will need to manually replace all its references in the Scene, prefabs, etc. 19 | 20 | ## Usage 21 | ![inst](assets/instructions-1.png) 22 | 1. Select one or multiple assets (folders are not supported) 23 | 2. Right click > **Generate GUID** 24 | 3. A modal will show to warn and confirm the action. **Click Proceed**. 25 | 4. Wait for the operation to complete. *Note that this will take a long time on larger projects.* 26 | 5. A report will be logged in the console detailling what assets are updated/skipped. 27 | 28 | ## Notes 29 | - Scenes are always skipped as this corrupts the scene. 30 | 31 | ## [Get it here!](https://github.com/jeffjads/unity-guid-regenerator/releases) 32 | 33 | ## Author 34 | - [Jeff Jadulco](https://github.com/jeffjads) 35 | 36 | ## License 37 | This project is open source and available under the [MIT License](LICENSE). 38 | -------------------------------------------------------------------------------- /Documentation/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7c3940e635f82f4bbe603e8d2284830 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e355c55b4738da34690df9f5c28ac370 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/AssetGUIDRegenerator.cs: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | GitHub: https://github.com/jeffjads/unity-guid-regenerator 4 | Related Docs: https://docs.unity3d.com/ScriptReference/AssetDatabase.html 5 | https://docs.unity3d.com/ScriptReference/AssetDatabase.FindAssets.html 6 | 7 | === DISCLAIMER === 8 | 9 | Only use this if really needed. Intentionally modifying asset GUID is not recommended unless certain issues are encountered. 10 | 11 | === DISCLAIMER === 12 | 13 | === LICENSE === 14 | 15 | MIT License 16 | 17 | Copyright (c) 2021 Jefferson Jadulco 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in all 27 | copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 35 | SOFTWARE. 36 | 37 | === LICENSE === 38 | */ 39 | 40 | #if UNITY_EDITOR 41 | 42 | using System; 43 | using System.Collections.Generic; 44 | using System.IO; 45 | using System.Linq; 46 | using UnityEditor; 47 | using UnityEngine; 48 | 49 | namespace Jads.Tools 50 | { 51 | public class AssetGUIDRegeneratorMenu 52 | { 53 | public const string Version = "1.0.5"; 54 | 55 | [MenuItem("Assets/Regenerate GUID/Files Only", true)] 56 | public static bool RegenerateGUID_Validation() 57 | { 58 | return DoValidation(); 59 | } 60 | 61 | [MenuItem("Assets/Regenerate GUID/Files and Folders", true)] 62 | public static bool RegenerateGUIDWithFolders_Validation() 63 | { 64 | return DoValidation(); 65 | } 66 | 67 | private static bool DoValidation() 68 | { 69 | var bAreSelectedAssetsValid = true; 70 | 71 | foreach (var guid in Selection.assetGUIDs) 72 | { 73 | var assetPath = AssetDatabase.GUIDToAssetPath(guid); 74 | bAreSelectedAssetsValid = !string.IsNullOrEmpty(guid) && guid != "0"; 75 | } 76 | 77 | return bAreSelectedAssetsValid; 78 | } 79 | 80 | [MenuItem("Assets/Regenerate GUID/Files Only")] 81 | public static void RegenerateGUID_Implementation() 82 | { 83 | DoImplementation(false); 84 | } 85 | 86 | [MenuItem("Assets/Regenerate GUID/Files and Folders")] 87 | public static void RegenerateGUIDWithFolders_Implementation() 88 | { 89 | DoImplementation(true); 90 | } 91 | 92 | private static void DoImplementation(bool includeFolders) 93 | { 94 | var assetGUIDS = AssetGUIDRegenerator.ExtractGUIDs(Selection.assetGUIDs, includeFolders); 95 | 96 | var option = EditorUtility.DisplayDialogComplex($"Regenerate GUID for {assetGUIDS.Length} asset/s", 97 | "DISCLAIMER: Intentionally modifying asset GUID is not recommended unless certain issues are encountered. " + 98 | "\n\nMake sure you have a backup or is using a version control system. \n\nThis operation can take a long time on larger projects. Do you want to proceed?", 99 | "Yes, please", "Nope", "I need more info"); 100 | 101 | if (option == 0) 102 | { 103 | AssetDatabase.StartAssetEditing(); 104 | AssetGUIDRegenerator.RegenerateGUIDs(assetGUIDS); 105 | AssetDatabase.StopAssetEditing(); 106 | AssetDatabase.SaveAssets(); 107 | AssetDatabase.Refresh(); 108 | } 109 | else if (option == 2) 110 | { 111 | Application.OpenURL("https://github.com/jeffjads/unity-guid-regenerator/blob/master/README.md"); 112 | } 113 | } 114 | } 115 | 116 | internal class AssetGUIDRegenerator 117 | { 118 | // Basically, we want to limit the types here (e.g. "t:GameObject t:Scene t:Material"). 119 | // But to support ScriptableObjects dynamically, we just include the base of all assets which is "t:Object" 120 | private const string SearchFilter = "t:Object"; 121 | 122 | // Set to "Assets/" folder only. We don't want to include other directories of the root folder 123 | private static readonly string[] SearchDirectories = { "Assets" }; 124 | 125 | public static void RegenerateGUIDs(string[] selectedGUIDs) 126 | { 127 | var assetGUIDs = AssetDatabase.FindAssets(SearchFilter, SearchDirectories); 128 | 129 | var updatedAssets = new Dictionary(); 130 | var skippedAssets = new List(); 131 | 132 | var inverseReferenceMap = new Dictionary>(); 133 | 134 | /* 135 | * PREPARATION PART 1 - Initialize map to store all paths that have a reference to our selectedGUIDs 136 | */ 137 | foreach (var selectedGUID in selectedGUIDs) 138 | { 139 | inverseReferenceMap[selectedGUID] = new HashSet(); 140 | } 141 | 142 | /* 143 | * PREPARATION PART 2 - Scan all assets and store the inverse reference if contains a reference to any selectedGUI... 144 | */ 145 | var scanProgress = 0; 146 | var referencesCount = 0; 147 | foreach (var guid in assetGUIDs) 148 | { 149 | scanProgress++; 150 | var path = AssetDatabase.GUIDToAssetPath(guid); 151 | if (IsDirectory(path)) continue; 152 | 153 | var dependencies = AssetDatabase.GetDependencies(path); 154 | foreach (var dependency in dependencies) 155 | { 156 | EditorUtility.DisplayProgressBar($"Scanning guid references on:", path, (float) scanProgress / assetGUIDs.Length); 157 | 158 | var dependencyGUID = AssetDatabase.AssetPathToGUID(dependency); 159 | if (inverseReferenceMap.ContainsKey(dependencyGUID)) 160 | { 161 | inverseReferenceMap[dependencyGUID].Add(path); 162 | 163 | // Also include .meta path. This fixes broken references when an FBX uses external materials 164 | var metaPath = AssetDatabase.GetTextMetaFilePathFromAssetPath(path); 165 | inverseReferenceMap[dependencyGUID].Add(metaPath); 166 | 167 | referencesCount++; 168 | } 169 | } 170 | } 171 | 172 | var countProgress = 0; 173 | 174 | foreach (var selectedGUID in selectedGUIDs) 175 | { 176 | var newGUID = GUID.Generate().ToString(); 177 | try 178 | { 179 | /* 180 | * PART 1 - Replace the GUID of the selected asset itself. If the .meta file does not exists or does not match the guid (which shouldn't happen), do not proceed to part 2 181 | */ 182 | var assetPath = AssetDatabase.GUIDToAssetPath(selectedGUID); 183 | var metaPath = AssetDatabase.GetTextMetaFilePathFromAssetPath(assetPath); 184 | 185 | if (!File.Exists(metaPath)) 186 | { 187 | skippedAssets.Add(assetPath); 188 | throw new FileNotFoundException($"The meta file of selected asset cannot be found. Asset: {assetPath}"); 189 | } 190 | 191 | var metaContents = File.ReadAllText(metaPath); 192 | 193 | // Check if guid in .meta file matches the guid of selected asset 194 | if (!metaContents.Contains(selectedGUID)) 195 | { 196 | skippedAssets.Add(assetPath); 197 | throw new ArgumentException($"The GUID of [{assetPath}] does not match the GUID in its meta file."); 198 | } 199 | 200 | // Allow regenerating guid of folder because modifying it doesn't seem to be harmful 201 | // if (IsDirectory(assetPath)) continue; 202 | 203 | // Skip scene files 204 | if (assetPath.EndsWith(".unity")) 205 | { 206 | skippedAssets.Add(assetPath); 207 | continue; 208 | } 209 | 210 | var metaAttributes = File.GetAttributes(metaPath); 211 | var bIsInitiallyHidden = false; 212 | 213 | // If the .meta file is hidden, unhide it temporarily 214 | if (metaAttributes.HasFlag(FileAttributes.Hidden)) 215 | { 216 | bIsInitiallyHidden = true; 217 | HideFile(metaPath, metaAttributes); 218 | } 219 | 220 | metaContents = metaContents.Replace(selectedGUID, newGUID); 221 | File.WriteAllText(metaPath, metaContents); 222 | 223 | if (bIsInitiallyHidden) UnhideFile(metaPath, metaAttributes); 224 | 225 | if (IsDirectory(assetPath)) 226 | { 227 | // Skip PART 2 for directories as they should not have any references in assets or scenes 228 | updatedAssets.Add(AssetDatabase.GUIDToAssetPath(selectedGUID), 0); 229 | continue; 230 | } 231 | 232 | /* 233 | * PART 2 - Update the GUID for all assets that references the selected GUID 234 | */ 235 | var countReplaced = 0; 236 | var referencePaths = inverseReferenceMap[selectedGUID]; 237 | foreach(var referencePath in referencePaths) 238 | { 239 | countProgress++; 240 | 241 | EditorUtility.DisplayProgressBar($"Regenerating GUID: {assetPath}", referencePath, (float) countProgress / referencesCount); 242 | 243 | if (IsDirectory(referencePath)) continue; 244 | 245 | var contents = File.ReadAllText(referencePath); 246 | 247 | if (!contents.Contains(selectedGUID)) continue; 248 | 249 | contents = contents.Replace(selectedGUID, newGUID); 250 | File.WriteAllText(referencePath, contents); 251 | 252 | countReplaced++; 253 | } 254 | 255 | updatedAssets.Add(AssetDatabase.GUIDToAssetPath(selectedGUID), countReplaced); 256 | } 257 | catch (Exception e) 258 | { 259 | Debug.LogError(e); 260 | } 261 | finally 262 | { 263 | EditorUtility.ClearProgressBar(); 264 | } 265 | } 266 | 267 | if (EditorUtility.DisplayDialog("Regenerate GUID", 268 | $"Regenerated GUID for {updatedAssets.Count} assets. \nSee console logs for detailed report.", "Done")) 269 | { 270 | var message = $"GUID Regenerator {AssetGUIDRegeneratorMenu.Version}\n"; 271 | 272 | if (updatedAssets.Count > 0) message += $"{updatedAssets.Count} Updated Asset/s\tSelect this log for more info\n"; 273 | message = updatedAssets.Aggregate(message, (current, kvp) => current + $"{kvp.Value} references\t{kvp.Key}\n"); 274 | 275 | if (skippedAssets.Count > 0) message += $"\n{skippedAssets.Count} Skipped Asset/s\n"; 276 | message = skippedAssets.Aggregate(message, (current, skipped) => current + $"{skipped}\n"); 277 | 278 | Debug.Log($"{message}"); 279 | } 280 | } 281 | 282 | // Searches for Directories and extracts all asset guids inside it using AssetDatabase.FindAssets 283 | public static string[] ExtractGUIDs(string[] selectedGUIDs, bool includeFolders) 284 | { 285 | var finalGuids = new List(); 286 | foreach (var guid in selectedGUIDs) 287 | { 288 | var assetPath = AssetDatabase.GUIDToAssetPath(guid); 289 | if (IsDirectory(assetPath)) 290 | { 291 | string[] searchDirectory = {assetPath}; 292 | 293 | if (includeFolders) finalGuids.Add(guid); 294 | finalGuids.AddRange(AssetDatabase.FindAssets(SearchFilter, searchDirectory)); 295 | } 296 | else 297 | { 298 | finalGuids.Add(guid); 299 | } 300 | } 301 | 302 | return finalGuids.ToArray(); 303 | } 304 | 305 | private static void HideFile(string path, FileAttributes attributes) 306 | { 307 | attributes &= ~FileAttributes.Hidden; 308 | File.SetAttributes(path, attributes); 309 | } 310 | 311 | private static void UnhideFile(string path, FileAttributes attributes) 312 | { 313 | attributes |= FileAttributes.Hidden; 314 | File.SetAttributes(path, attributes); 315 | } 316 | 317 | public static bool IsDirectory(string path) => File.GetAttributes(path).HasFlag(FileAttributes.Directory); 318 | } 319 | } 320 | 321 | #endif 322 | -------------------------------------------------------------------------------- /Editor/AssetGUIDRegenerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c73dcc21278e086409ea2268707051b1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Editor/jeffjadulco.guidregenerator.editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jeffjadulco.guidregenerator", 3 | "references": [], 4 | "includePlatforms": [ 5 | "Editor" 6 | ], 7 | "excludePlatforms": [], 8 | "allowUnsafeCode": false, 9 | "overrideReferences": false, 10 | "precompiledReferences": [], 11 | "autoReferenced": true, 12 | "defineConstraints": [], 13 | "versionDefines": [], 14 | "noEngineReferences": false 15 | } -------------------------------------------------------------------------------- /Editor/jeffjadulco.guidregenerator.editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8204cf670cb4e14b9ae57fe54de6ede 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Jefferson Jadulco 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a834e87ff6f408e4580ddde674f2fcd6 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # :id: Unity GUID Regenerator 2 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/) 3 | 4 | A Unity editor tool to regenerate GUID for your assets 5 | 6 | > :warning: **Disclaimer**: Only use this if needed. Intentionally modifying the GUID of an asset is not recommended unless certain files are problematic 7 | 8 | ## What is GUID in Unity? 9 | GUID is a unique hash that is automatically generated and assigned when creating a new asset. This GUID is used when a serialized asset references another asset. 10 | 11 | ![GUID](assets/DemoScriptMeta.png) 12 | 13 | It is stored in an asset's meta file. Manually you can open and view a meta file in a text editor to get the GUID. However, Unity has its [AssetDatabase](https://docs.unity3d.com/ScriptReference/AssetDatabase.html) API that is useful for accessing and performing operations on assets. 14 | 15 | ## Why regenerate a GUID? 16 | When you work on multiple projects that are based on existing projects, chances are most of the assets have the same GUID. This can cause some issues later on when you add more assets from existing projects. Unity won't be able to distinguish the difference between assets with same GUID even they have different file name and contents. This can cause Unity to associate references to the wrong asset. 17 | 18 | The simplest workaround for this is to duplicate the asset. The newly created asset will have its own GUID assigned by Unity. However, you will need to manually replace all its references in the Scene, prefabs, etc. 19 | 20 | ## Installation 21 | 1. Unity Editor > Windows > Package Manager 22 | 2. Add package from git URL... 23 | 3. Enter `https://github.com/jeffjadulco/unity-guid-regenerator.git` 24 | 25 | ## Usage 26 | ![inst](assets/instructions-1.png) 27 | 1. Select one or multiple assets (folders are not supported) 28 | 2. Right click > **Generate GUID** 29 | 3. A modal will show to warn and confirm the action. **Click Proceed**. 30 | 4. Wait for the operation to complete. *Note that this will take a long time on larger projects.* 31 | 5. A report will be logged in the console detailling what assets are updated/skipped. 32 | 33 | ## Notes 34 | - Scenes are always skipped as this corrupts the scene. 35 | 36 | ## Author 37 | - [Jeff Jadulco](https://github.com/jeffjads) 38 | 39 | ## License 40 | This project is open source and available under the [MIT License](LICENSE). 41 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a00390ff1115654b8333142d350a4f7 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /assets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be685e21ce1de8849bfe240d891a3e44 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /assets/DemoScriptMeta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffjadulco/unity-guid-regenerator/7dbce4b94bd7f92c33de382439f662a0731a1db9/assets/DemoScriptMeta.png -------------------------------------------------------------------------------- /assets/DemoScriptMeta.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bf9d12146bbd7104881744384b670304 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: 1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 1 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | spriteSheet: 75 | serializedVersion: 2 76 | sprites: [] 77 | outline: [] 78 | physicsShape: [] 79 | bones: [] 80 | spriteID: 5e97eb03825dee720800000000000000 81 | internalID: 0 82 | vertices: [] 83 | indices: 84 | edges: [] 85 | weights: [] 86 | secondaryTextures: [] 87 | spritePackingTag: 88 | pSDRemoveMatte: 0 89 | pSDShowRemoveMatteOption: 0 90 | userData: 91 | assetBundleName: 92 | assetBundleVariant: 93 | -------------------------------------------------------------------------------- /assets/instructions-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeffjadulco/unity-guid-regenerator/7dbce4b94bd7f92c33de382439f662a0731a1db9/assets/instructions-1.png -------------------------------------------------------------------------------- /assets/instructions-1.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53efb3fb188a92a45b8a95bcd7bb31e0 3 | TextureImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 11 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 1 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: -1 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: 1 40 | nPOTScale: 0 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 1 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 1 53 | spriteTessellationDetail: -1 54 | textureType: 8 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | applyGammaDecoding: 0 61 | platformSettings: 62 | - serializedVersion: 3 63 | buildTarget: DefaultTexturePlatform 64 | maxTextureSize: 2048 65 | resizeAlgorithm: 0 66 | textureFormat: -1 67 | textureCompression: 1 68 | compressionQuality: 50 69 | crunchedCompression: 0 70 | allowsAlphaSplitting: 0 71 | overridden: 0 72 | androidETC2FallbackOverride: 0 73 | forceMaximumCompressionQuality_BC6H_BC7: 0 74 | spriteSheet: 75 | serializedVersion: 2 76 | sprites: [] 77 | outline: [] 78 | physicsShape: [] 79 | bones: [] 80 | spriteID: 5e97eb03825dee720800000000000000 81 | internalID: 0 82 | vertices: [] 83 | indices: 84 | edges: [] 85 | weights: [] 86 | secondaryTextures: [] 87 | spritePackingTag: 88 | pSDRemoveMatte: 0 89 | pSDShowRemoveMatteOption: 0 90 | userData: 91 | assetBundleName: 92 | assetBundleVariant: 93 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.jeffjadulco.guidregenerator", 3 | "version": "1.0.5", 4 | "displayName": "GUID Regenerator", 5 | "description": "A Unity editor tool to regenerate GUID for your assets", 6 | "unity": "2019.4", 7 | "unityRelease": "18f1", 8 | "keywords": [ 9 | "guid" 10 | ], 11 | "author": { 12 | "name": "Jeff Jadulco", 13 | "email": "hey@jeffjadulco.com", 14 | "url": "https://jeffjadulco.com" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23f391e37892d594a8649ba56e9ce419 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------