From 3df386ecbcdcdd2d6eb21c54fdf0f4676deb15ac Mon Sep 17 00:00:00 2001 From: AlexanderVorobyov Date: Sun, 19 May 2024 12:59:27 +0300 Subject: [PATCH 1/2] Update AssetsEditorUtility.cs --- .../UGF.EditorTools/Editor/Assets/AssetsEditorUtility.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Packages/UGF.EditorTools/Editor/Assets/AssetsEditorUtility.cs b/Packages/UGF.EditorTools/Editor/Assets/AssetsEditorUtility.cs index 856f6dc5..732b5ab5 100644 --- a/Packages/UGF.EditorTools/Editor/Assets/AssetsEditorUtility.cs +++ b/Packages/UGF.EditorTools/Editor/Assets/AssetsEditorUtility.cs @@ -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)); From b0559a9443d6beb9c403ff023962956ab304edb1 Mon Sep 17 00:00:00 2001 From: AlexanderVorobyov Date: Sun, 19 May 2024 12:59:29 +0300 Subject: [PATCH 2/2] Update AssetIdEditorUtility.cs --- .../Editor/Assets/AssetIdEditorUtility.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Packages/UGF.EditorTools/Editor/Assets/AssetIdEditorUtility.cs b/Packages/UGF.EditorTools/Editor/Assets/AssetIdEditorUtility.cs index 492d1b72..08b07458 100644 --- a/Packages/UGF.EditorTools/Editor/Assets/AssetIdEditorUtility.cs +++ b/Packages/UGF.EditorTools/Editor/Assets/AssetIdEditorUtility.cs @@ -4,6 +4,7 @@ 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; @@ -11,6 +12,15 @@ 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));