Skip to content

Commit 21b910f

Browse files
committed
feat: GetAssetAbsolutePath function added.
1 parent e7b0352 commit 21b910f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Editor/EditorUtilities/AssetDatabaseUtility.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Reflection;
33
using UnityEditor;
4+
using UnityEngine;
45
using Object = UnityEngine.Object;
56

67
namespace StansAssets.Foundation.Editor
@@ -23,8 +24,19 @@ public static int GetLocalIdentifierInFile(Object unityObject)
2324

2425
var serializedObject = new SerializedObject(unityObject);
2526
inspectorModeInfo.SetValue(serializedObject, InspectorMode.Debug, null);
26-
var localIdProp = serializedObject.FindProperty("m_LocalIdentfierInFile"); //note the misspelling!
27+
var localIdProp = serializedObject.FindProperty("m_LocalIdentfierInFile"); //note the misspelling!
2728
return localIdProp.intValue;
2829
}
30+
31+
/// <summary>
32+
/// Returns the absolute path name for the asset.
33+
/// </summary>
34+
/// <param name="asset">A reference to the asset.</param>
35+
/// <returns>The asset path name, or null, or an empty string if the asset does not exist.</returns>
36+
public static string GetAssetAbsolutePath(Object asset)
37+
{
38+
var absoluteFilePath = Application.dataPath.Substring(0, Application.dataPath.Length - 7);
39+
return $"{absoluteFilePath}/{AssetDatabase.GetAssetPath(asset)}";
40+
}
2941
}
30-
}
42+
}

0 commit comments

Comments
 (0)