private static string LocateAssetFile(string invalidPath) { string fileExtension = Path.GetExtension(invalidPath)?.Replace(".", ""); string newPath = EditorUtility.OpenFilePanel( "Couldn't find asset at " + invalidPath + ". Select correct file.", UrdfAssetPathHandler.GetPackageRoot(), fileExtension); return(UrdfAssetPathHandler.GetRelativeAssetPath(newPath)); }
private static void MoveMaterialsToNewLocation(string oldPackageRoot) { if (AssetDatabase.IsValidFolder(Path.Combine(oldPackageRoot, MaterialFolderName))) { AssetDatabase.MoveAsset( Path.Combine(oldPackageRoot, MaterialFolderName), Path.Combine(UrdfAssetPathHandler.GetPackageRoot(), MaterialFolderName)); } else { AssetDatabase.CreateFolder(UrdfAssetPathHandler.GetPackageRoot(), MaterialFolderName); } }
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); }