Skip to content

Instantly share code, notes, and snippets.

@Unity-Javier
Created July 10, 2020 10:06
Show Gist options
  • Save Unity-Javier/a2258b2a542fc61f15d10cd6e83dcefa to your computer and use it in GitHub Desktop.
Save Unity-Javier/a2258b2a542fc61f15d10cd6e83dcefa to your computer and use it in GitHub Desktop.

Revisions

  1. Unity-Javier created this gist Jul 10, 2020.
    35 changes: 35 additions & 0 deletions LibraryPathsForAsset.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    using System.IO;
    using System.Text;
    using UnityEditor;
    using UnityEditor.Experimental;
    using UnityEngine;

    public class LibraryPathsForAsset
    {
    [MenuItem("AssetDatabase/OutputLibraryPathsForAsset")]
    public static void OutputLibraryPathsForAsset()
    {
    var assetPath = "Assets/Shaders/Mat05.mat";

    StringBuilder assetPathInfo = new StringBuilder();

    var guidString = AssetDatabase.AssetPathToGUID(assetPath);
    var hash = AssetDatabaseExperimental.GetArtifactHash(guidString);

    AssetDatabaseExperimental.GetArtifactPaths(hash, out var paths);

    assetPathInfo.Append($"Files associated with {assetPath}");
    assetPathInfo.AppendLine();

    foreach (var curVirtualPath in paths)
    {
    //The virtual path redirects somewhere, so we get the
    //actual path on disk (or on the in memory database, accordingly)
    var curPath = Path.GetFullPath(curVirtualPath);
    assetPathInfo.Append("\t" + curPath);
    assetPathInfo.AppendLine();
    }

    Debug.Log("Path info for all assets:\n"+assetPathInfo.ToString());
    }
    }