Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hoverbird/a0416525fc6e97c3dfa0d07cfe586b36 to your computer and use it in GitHub Desktop.
Save hoverbird/a0416525fc6e97c3dfa0d07cfe586b36 to your computer and use it in GitHub Desktop.
Unity3d utility thing. Right Click an asset-> Copy Asset Path. - ideal for use with AssetDatabase.LoadAssetAtPath<>
using UnityEngine;
using UnityEditor;
public static class CopyAssetPathContextMenu
{
[MenuItem("Assets/Copy Asset Path")]
public static void CopyAssetPath()
{
if (Selection.activeObject != null)
{
string assetPath = AssetDatabase.GetAssetPath(Selection.activeObject);
TextEditor te = new TextEditor();
te.text = assetPath;
te.SelectAll();
te.Copy();
Debug.Log("Copied to Buffer:" + assetPath);
}
else
{
Debug.Log("Nothing selected.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment