Skip to content

Commit

Permalink
feat: GetAssetAbsolutePath function added.
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-osipov committed Feb 10, 2021
1 parent e7b0352 commit 21b910f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Editor/EditorUtilities/AssetDatabaseUtility.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;

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

var serializedObject = new SerializedObject(unityObject);
inspectorModeInfo.SetValue(serializedObject, InspectorMode.Debug, null);
var localIdProp = serializedObject.FindProperty("m_LocalIdentfierInFile"); //note the misspelling!
var localIdProp = serializedObject.FindProperty("m_LocalIdentfierInFile"); //note the misspelling!
return localIdProp.intValue;
}

/// <summary>
/// Returns the absolute path name for the asset.
/// </summary>
/// <param name="asset">A reference to the asset.</param>
/// <returns>The asset path name, or null, or an empty string if the asset does not exist.</returns>
public static string GetAssetAbsolutePath(Object asset)
{
var absoluteFilePath = Application.dataPath.Substring(0, Application.dataPath.Length - 7);
return $"{absoluteFilePath}/{AssetDatabase.GetAssetPath(asset)}";
}
}
}
}

0 comments on commit 21b910f

Please sign in to comment.