Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Packages/UGF.EditorTools/Editor/Assets/AssetIdEditorUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
using UGF.EditorTools.Editor.Ids;
using UGF.EditorTools.Editor.Serialized;
using UGF.EditorTools.Runtime.Assets;
using UGF.EditorTools.Runtime.Ids;
using UnityEditor;
using Object = UnityEngine.Object;

namespace UGF.EditorTools.Editor.Assets
{
public static class AssetIdEditorUtility
{
public static GlobalId GetId(Object asset)
{
if (asset == null) throw new ArgumentNullException(nameof(asset));

string guid = AssetsEditorUtility.GetGuid(asset);

return new GlobalId(guid);
}

public static bool CheckAssetIdAttributeType(SerializedProperty serializedProperty, Object asset)
{
if (serializedProperty == null) throw new ArgumentNullException(nameof(serializedProperty));
Expand Down
9 changes: 9 additions & 0 deletions Packages/UGF.EditorTools/Editor/Assets/AssetsEditorUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ namespace UGF.EditorTools.Editor.Assets
{
public static class AssetsEditorUtility
{
public static string GetGuid(Object asset)
{
if (asset == null) throw new ArgumentNullException(nameof(asset));

string path = AssetDatabase.GetAssetPath(asset);

return AssetDatabase.AssetPathToGUID(path);
}

public static bool TrySelectFile(string title, string directory, string extension, bool relative, out string path)
{
if (string.IsNullOrEmpty(title)) throw new ArgumentException("Value cannot be null or empty.", nameof(title));
Expand Down