public void AssetExists_False() { RuntimeUrdf.SetRuntimeMode(false); Assert.IsFalse(RuntimeUrdf.AssetExists($"{createAssetPath}/tEstAsset.Prefab")); // case Assert.IsFalse(RuntimeUrdf.AssetExists($"{createAssetPath}/TestAsset.prefabs", true)); Assert.IsFalse(RuntimeUrdf.AssetExists($"{createAssetPath}/TestAsset.prefa", true)); Assert.IsFalse(RuntimeUrdf.AssetExists($"{createAssetPath}/estAsset.prefab", true)); Assert.IsFalse(RuntimeUrdf.AssetExists($"{createAssetPath}/sub/TestAsset.prefab", true)); }
public static T FindUrdfAsset <T>(string urdfFileName) where T : UnityEngine.Object { string fileAssetPath = UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath(urdfFileName); // check if it is an asset tha requires post processing (AIRO-908) var originalUrdfPath = UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath(urdfFileName, false); if (originalUrdfPath.ToLower().EndsWith(".stl")) { // it is an asset that requires post processing if (UrdfRobotExtensions.importsettings.OverwriteExistingPrefabs || !RuntimeUrdf.AssetExists(fileAssetPath, true)) { // post process again to (re)create prefabs StlAssetPostProcessor.PostprocessStlFile(originalUrdfPath); } } T assetObject = RuntimeUrdf.AssetDatabase_LoadAssetAtPath <T>(fileAssetPath); if (assetObject) { 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 = RuntimeUrdf.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)RuntimeUrdf.AssetDatabase_LoadAssetAtPath(fileAssetPath, typeof(T)); if (assetObject != null) { return(assetObject); } ChooseFailureOption(urdfFileName); return(null); }
public void StlPostprocess_NewStl_DontCreatePrefab() { // make a new copy of the stl file Assert.IsTrue(AssetDatabase.CopyAsset(k_StlCubeSourcePath, m_StlCubeCopyPath)); Assert.IsTrue(RuntimeUrdf.AssetExists(m_StlCubeCopyPath)); // make sure the .asset file is not automatically created var meshAssetPath = StlAssetPostProcessor.GetMeshAssetPath(m_StlCubeCopyPath, 0); Assert.IsFalse(RuntimeUrdf.AssetExists(meshAssetPath)); // make sure the .prefab file is not automatically created var prefabPath = StlAssetPostProcessor.GetPrefabAssetPath(m_StlCubeCopyPath); Assert.IsFalse(RuntimeUrdf.AssetExists(prefabPath)); // make sure the .asset and .prefab file are created when requested StlAssetPostProcessor.PostprocessStlFile(m_StlCubeCopyPath); Assert.IsTrue(RuntimeUrdf.AssetExists(meshAssetPath)); Assert.IsTrue(RuntimeUrdf.AssetExists(prefabPath)); }
public void AssetExists_True() { RuntimeUrdf.SetRuntimeMode(false); Assert.IsTrue(RuntimeUrdf.AssetExists($"{createAssetPath}/TestAsset.prefab")); Assert.IsTrue(RuntimeUrdf.AssetExists($"{createAssetPath}/tEstAsset.Prefab", true)); }