public static Object LoadAsset(AssetReferenceEntry target) { #if UNITY_EDITOR var pathSplit = target.Path.SplitFromEntryBreak(); if (pathSplit == null) { return(null); } if (pathSplit.Length == 2) { // } // if (target is SubAssetReferenceEntry subAsset) { var objs = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(pathSplit[0]); if (objs.Length == 1) { return(objs[0]); } for (int i = 0; i < objs.Length; i++) { var obj = objs[i]; if (obj.name == pathSplit[1]) { return(obj); } } } else { return(UnityEditor.AssetDatabase.LoadAssetAtPath(target.Path, target.Type)); } #endif return(null); }
public static void SetPath(AssetReferenceEntry entry) { #if UNITY_EDITOR entry.Path = entry.Asset != null?UnityEditor.AssetDatabase.GetAssetPath(entry.Asset) : ""; if (!string.IsNullOrEmpty(entry.AssetReference.SubObjectName)) { entry.Path += StringConst.MultiEntryBreak + entry.AssetReference.SubObjectName; } // if (entry is SubAssetReferenceEntry subAsset) { // subAsset.SubAssetName = entry.AssetReference.SubObjectName; // } #endif }