Created
March 3, 2019 01:04
-
-
Save jkredz/8097fbf7af1570a17b5ba8aebd0721c5 to your computer and use it in GitHub Desktop.
Shows GUID, InstanceID, File ID for an asset in Unity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Get instance, guid, and file ID of file during play mode | |
//Possibly useful for getting the type or instance of a specific file in the project folder and possibly loading | |
//This script prints these details for a selected asset in project window | |
using System.Text; | |
using UnityEngine; | |
using UnityEditor; | |
class ShowAssetIds | |
{ | |
[MenuItem("Assets/Show Asset Ids")] | |
static void MenuShowIds() | |
{ | |
var stringBuilder = new StringBuilder(); | |
foreach (var obj in AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(Selection.activeObject))) | |
{ | |
string guid; | |
long file; | |
if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(obj, out guid, out file)) | |
{ | |
stringBuilder.AppendFormat("Asset: " + obj.name + | |
"\n Instance ID: " + obj.GetInstanceID() + | |
"\n GUID: " + guid + | |
"\n File ID: " + file); | |
} | |
} | |
Debug.Log(stringBuilder.ToString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment