private static string LocateRootAssetFolder <T>(string urdfFileName) where T : UnityEngine.Object { string newAssetPath = EditorUtility.OpenFolderPanel( "Locate package root folder", Path.Combine(Path.GetDirectoryName(Application.dataPath), "Assets"), ""); if (UrdfAssetPathHandler.IsValidAssetPath(newAssetPath)) { UrdfAssetPathHandler.SetPackageRoot(newAssetPath, true); } else { Debug.LogWarning("Selected package root " + newAssetPath + " is not within the Assets folder."); } return(UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath(urdfFileName)); }
public static T FindUrdfAsset <T>(string urdfFileName) where T : UnityEngine.Object { string fileAssetPath = UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath(urdfFileName); T assetObject = AssetDatabase.LoadAssetAtPath <T>(fileAssetPath); if (assetObject != null) { return(assetObject); } //If asset was not found, let user choose whether to search for //or ignore the missing asset. string invalidPath = fileAssetPath ?? urdfFileName; int option = EditorUtility.DisplayDialogComplex("Urdf Importer: Asset Not Found", "Current root folder: " + UrdfAssetPathHandler.GetPackageRoot() + "\n\nExpected asset path: " + invalidPath, "Locate Asset", "Ignore Missing Asset", "Locate Root Folder"); switch (option) { case 0: fileAssetPath = LocateAssetFile(invalidPath); break; case 1: break; case 2: fileAssetPath = LocateRootAssetFolder <T>(urdfFileName); break; } assetObject = (T)AssetDatabase.LoadAssetAtPath(fileAssetPath, typeof(T)); if (assetObject != null) { return(assetObject); } ChooseFailureOption(urdfFileName); return(null); }