Renamed RuntimeURDF to RuntimeUrdf (#126)

* Renamed RuntimeURDFImporter to RuntimeURDFImporterExample for clarification

* added comments about RuntimeURDFImporterExample

* typo fix  in the comments

* renaming: URDF to Urdf

* Renamed "URDF" to "Urdf" in class names, function names and source filenames.
This commit is contained in:
Hamid Younesy 2021-07-13 19:02:40 -07:00 коммит произвёл GitHub
Родитель e9735c6a51
Коммит 388d81e609
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
21 изменённых файлов: 160 добавлений и 146 удалений

Просмотреть файл

@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
### Changed
- STL files will not be automatically processed to create .prefab files when copied into the Assets directory or when assets are reimported. Instead the processing happens during the URDF import and required .prefab files will be created if they don't exist already or if the "Overwrite Existing Prefabs" option is checked in the URDF Import settings dialog.
- Renamed "URDF" to "Urdf" in class names, function names and source filenames.
- Renamed RuntimeURDFImporter to RuntimeUrdfImporterExample for clarification
### Deprecated

Просмотреть файл

@ -104,7 +104,7 @@ namespace Unity.Robotics.UrdfImporter.Editor
GUILayout.Space(5);
if (GUILayout.Button("Compare URDF Files"))
{
CompareURDF window = (CompareURDF)EditorWindow.GetWindow(typeof(CompareURDF));
CompareUrdf window = (CompareUrdf)EditorWindow.GetWindow(typeof(CompareUrdf));
window.minSize = new Vector2(500, 200);
window.GetEditorPrefs();
window.Show();

Просмотреть файл

@ -4,7 +4,7 @@ using UnityEngine;
namespace Unity.Robotics.UrdfImporter.Editor
{
public class CompareURDF : EditorWindow
public class CompareUrdf : EditorWindow
{
public UrdfComparator comparator;
public string originalFile = "";

Просмотреть файл

@ -28,13 +28,13 @@ namespace Unity.Robotics.UrdfImporter
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))
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);
T assetObject = RuntimeUrdf.AssetDatabase_LoadAssetAtPath<T>(fileAssetPath);
if (assetObject)
return assetObject;
@ -42,7 +42,7 @@ namespace Unity.Robotics.UrdfImporter
//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",
int option = RuntimeUrdf.EditorUtility_DisplayDialogComplex("Urdf Importer: Asset Not Found",
"Current root folder: " + UrdfAssetPathHandler.GetPackageRoot() +
"\n\nExpected asset path: " + invalidPath,
"Locate Asset",
@ -60,7 +60,7 @@ namespace Unity.Robotics.UrdfImporter
break;
}
assetObject = (T) RuntimeURDF.AssetDatabase_LoadAssetAtPath(fileAssetPath, typeof(T));
assetObject = (T) RuntimeUrdf.AssetDatabase_LoadAssetAtPath(fileAssetPath, typeof(T));
if (assetObject != null)
return assetObject;
@ -70,7 +70,7 @@ namespace Unity.Robotics.UrdfImporter
private static string LocateRootAssetFolder<T>(string urdfFileName) where T : UnityEngine.Object
{
string newAssetPath = RuntimeURDF.EditorUtility_OpenFolderPanel(
string newAssetPath = RuntimeUrdf.EditorUtility_OpenFolderPanel(
"Locate package root folder",
Path.Combine(Path.GetDirectoryName(Application.dataPath), "Assets"),
"");
@ -90,7 +90,7 @@ namespace Unity.Robotics.UrdfImporter
{
string fileExtension = Path.GetExtension(invalidPath)?.Replace(".", "");
string newPath = RuntimeURDF.EditorUtility_OpenFilePanel(
string newPath = RuntimeUrdf.EditorUtility_OpenFilePanel(
"Couldn't find asset at " + invalidPath + ". Select correct file.",
UrdfAssetPathHandler.GetPackageRoot(),
fileExtension);
@ -100,7 +100,7 @@ namespace Unity.Robotics.UrdfImporter
private static void ChooseFailureOption(string urdfFilePath)
{
if (!RuntimeURDF.EditorUtility_DisplayDialog(
if (!RuntimeUrdf.EditorUtility_DisplayDialog(
"Urdf Importer: Missing Asset",
"Missing asset " + Path.GetFileName(urdfFilePath) +
" was ignored or could not be found.\n\nContinue URDF Import?",

Просмотреть файл

@ -30,9 +30,9 @@ namespace Unity.Robotics.UrdfImporter
packageRoot = GetRelativeAssetPath(newPath);
if (!RuntimeURDF.AssetDatabase_IsValidFolder(Path.Combine(packageRoot, MaterialFolderName)))
if (!RuntimeUrdf.AssetDatabase_IsValidFolder(Path.Combine(packageRoot, MaterialFolderName)))
{
RuntimeURDF.AssetDatabase_CreateFolder(packageRoot, MaterialFolderName);
RuntimeUrdf.AssetDatabase_CreateFolder(packageRoot, MaterialFolderName);
}
if (correctingIncorrectPackageRoot)
@ -54,7 +54,7 @@ namespace Unity.Robotics.UrdfImporter
if (!absolutePathUnityFormat.StartsWith(Application.dataPath.SetSeparatorChar()))
{
#if UNITY_EDITOR
if (!RuntimeURDF.IsRuntimeMode())
if (!RuntimeUrdf.IsRuntimeMode())
{
return null;
}
@ -118,7 +118,7 @@ namespace Unity.Robotics.UrdfImporter
public static bool IsValidAssetPath(string path)
{
#if UNITY_EDITOR
if (!RuntimeURDF.IsRuntimeMode())
if (!RuntimeUrdf.IsRuntimeMode())
{
return GetRelativeAssetPath(path) != null;
}
@ -131,15 +131,15 @@ namespace Unity.Robotics.UrdfImporter
private static void MoveMaterialsToNewLocation(string oldPackageRoot)
{
if (RuntimeURDF.AssetDatabase_IsValidFolder(Path.Combine(oldPackageRoot, MaterialFolderName)))
if (RuntimeUrdf.AssetDatabase_IsValidFolder(Path.Combine(oldPackageRoot, MaterialFolderName)))
{
RuntimeURDF.AssetDatabase_MoveAsset(
RuntimeUrdf.AssetDatabase_MoveAsset(
Path.Combine(oldPackageRoot, MaterialFolderName),
Path.Combine(UrdfAssetPathHandler.GetPackageRoot(), MaterialFolderName));
}
else
{
RuntimeURDF.AssetDatabase_CreateFolder(UrdfAssetPathHandler.GetPackageRoot(), MaterialFolderName);
RuntimeUrdf.AssetDatabase_CreateFolder(UrdfAssetPathHandler.GetPackageRoot(), MaterialFolderName);
}
}

Просмотреть файл

@ -33,9 +33,9 @@ namespace Unity.Robotics.UrdfImporter
string[] foldersToSearch = {Path.GetDirectoryName(prefabPath)};
string prefabName = Path.GetFileNameWithoutExtension(prefabPath);
foreach (string guid2 in RuntimeURDF.AssetDatabase_FindAssets(prefabName, foldersToSearch))
foreach (string guid2 in RuntimeUrdf.AssetDatabase_FindAssets(prefabName, foldersToSearch))
{
string possiblePath = RuntimeURDF.AssetDatabase_GUIDToAssetPath(guid2);
string possiblePath = RuntimeUrdf.AssetDatabase_GUIDToAssetPath(guid2);
if (possiblePath.ToLower().Contains(".stl"))
{
prefabPath = possiblePath;
@ -69,12 +69,12 @@ namespace Unity.Robotics.UrdfImporter
private static void CopyDaeTextureToExportDestination(string prefabPath, string newFolderLocation)
{
//Get material from Collada prefab
Material material = RuntimeURDF.AssetDatabase_LoadAssetAtPath<Material>(prefabPath);
Material material = RuntimeUrdf.AssetDatabase_LoadAssetAtPath<Material>(prefabPath);
if (material.mainTexture == null) return;
//Get relative subfolder where texture is, compared to the DAE file.
string commonFolder = Path.GetDirectoryName(prefabPath).SetSeparatorChar();
string texturePath = RuntimeURDF.AssetDatabase_GetAssetPath(material.mainTexture).SetSeparatorChar();
string texturePath = RuntimeUrdf.AssetDatabase_GetAssetPath(material.mainTexture).SetSeparatorChar();
string relativeLocation = "";
if (texturePath.Contains(commonFolder))
relativeLocation = texturePath.Substring(commonFolder.Length + 1);
@ -107,7 +107,7 @@ namespace Unity.Robotics.UrdfImporter
private static string GetPrefabPath(GameObject gameObject)
{
return RuntimeURDF.AssetDatabase_GetAssetPath(RuntimeURDF.PrefabUtility_GetCorrespondingObjectFromSource(gameObject));
return RuntimeUrdf.AssetDatabase_GetAssetPath(RuntimeUrdf.PrefabUtility_GetCorrespondingObjectFromSource(gameObject));
}
}
}

Просмотреть файл

@ -63,7 +63,7 @@ namespace Unity.Robotics.UrdfImporter
private static GameObject CreateMeshCollider(Link.Geometry.Mesh mesh)
{
if (!RuntimeURDF.IsRuntimeMode())
if (!RuntimeUrdf.IsRuntimeMode())
{
GameObject prefabObject = LocateAssetHandler.FindUrdfAsset<GameObject>(mesh.filename);
if (prefabObject == null)
@ -72,7 +72,7 @@ namespace Unity.Robotics.UrdfImporter
return null;
}
GameObject meshObject = (GameObject)RuntimeURDF.PrefabUtility_InstantiatePrefab(prefabObject);
GameObject meshObject = (GameObject)RuntimeUrdf.PrefabUtility_InstantiatePrefab(prefabObject);
ConvertMeshToColliders(meshObject, location:mesh.filename);
return meshObject;
@ -118,14 +118,14 @@ namespace Unity.Robotics.UrdfImporter
GameObject go = filter.gameObject;
var collider = filter.sharedMesh;
// Only create an asset if not runtime import
if (!RuntimeURDF.IsRuntimeMode())
if (!RuntimeUrdf.IsRuntimeMode())
{
var packageRoot = UrdfAssetPathHandler.GetPackageRoot();
var filePath = RuntimeURDF.AssetDatabase_GUIDToAssetPath(RuntimeURDF.AssetDatabase_CreateFolder($"{packageRoot}", "meshes"));
var filePath = RuntimeUrdf.AssetDatabase_GUIDToAssetPath(RuntimeUrdf.AssetDatabase_CreateFolder($"{packageRoot}", "meshes"));
var name =$"{filePath}/Cylinder.asset";
Debug.Log($"Creating new cylinder file: {name}");
RuntimeURDF.AssetDatabase_CreateAsset(collider, name, uniquePath:true);
RuntimeURDF.AssetDatabase_SaveAssets();
RuntimeUrdf.AssetDatabase_CreateAsset(collider, name, uniquePath:true);
RuntimeUrdf.AssetDatabase_SaveAssets();
}
MeshCollider current = go.AddComponent<MeshCollider>();
current.sharedMesh = collider;
@ -142,12 +142,12 @@ namespace Unity.Robotics.UrdfImporter
}
GameObject objectToCopy = visualToCopy.GetChild(0).gameObject;
GameObject prefabObject = (GameObject)RuntimeURDF.PrefabUtility_GetCorrespondingObjectFromSource(objectToCopy);
GameObject prefabObject = (GameObject)RuntimeUrdf.PrefabUtility_GetCorrespondingObjectFromSource(objectToCopy);
GameObject collisionObject;
if (prefabObject != null)
{
collisionObject = (GameObject)RuntimeURDF.PrefabUtility_InstantiatePrefab(prefabObject);
collisionObject = (GameObject)RuntimeUrdf.PrefabUtility_InstantiatePrefab(prefabObject);
}
else
{
@ -182,7 +182,7 @@ namespace Unity.Robotics.UrdfImporter
string templateFileName = "";
string filePath = "";
int meshIndex = 0;
if (!RuntimeURDF.IsRuntimeMode() && location != null)
if (!RuntimeUrdf.IsRuntimeMode() && location != null)
{
string meshFilePath = UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath(location, false);
templateFileName = Path.GetFileNameWithoutExtension(meshFilePath);
@ -196,13 +196,13 @@ namespace Unity.Robotics.UrdfImporter
List<Mesh> colliderMeshes = decomposer.GenerateConvexMeshes(meshFilter.sharedMesh);
foreach (Mesh collider in colliderMeshes)
{
if (!RuntimeURDF.IsRuntimeMode())
if (!RuntimeUrdf.IsRuntimeMode())
{
meshIndex++;
string name = $"{filePath}/{templateFileName}_{meshIndex}.asset";
Debug.Log($"Creating new mesh file: {name}");
RuntimeURDF.AssetDatabase_CreateAsset(collider, name);
RuntimeURDF.AssetDatabase_SaveAssets();
RuntimeUrdf.AssetDatabase_CreateAsset(collider, name);
RuntimeUrdf.AssetDatabase_SaveAssets();
}
MeshCollider current = child.AddComponent<MeshCollider>();
current.sharedMesh = collider;

Просмотреть файл

@ -60,10 +60,10 @@ namespace Unity.Robotics.UrdfImporter
private static GameObject CreateMeshVisual(Link.Geometry.Mesh mesh)
{
#if UNITY_EDITOR
if (!RuntimeURDF.IsRuntimeMode())
if (!RuntimeUrdf.IsRuntimeMode())
{
GameObject meshObject = LocateAssetHandler.FindUrdfAsset<GameObject>(mesh.filename);
return meshObject == null ? null : (GameObject)RuntimeURDF.PrefabUtility_InstantiatePrefab(meshObject);
return meshObject == null ? null : (GameObject)RuntimeUrdf.PrefabUtility_InstantiatePrefab(meshObject);
}
#endif
return CreateMeshVisualRuntime(mesh);

Просмотреть файл

@ -37,7 +37,7 @@ namespace Unity.Robotics.UrdfImporter
urdfMaterial.name = GenerateMaterialName(urdfMaterial);
}
var material = RuntimeURDF.AssetDatabase_LoadAssetAtPath<Material>(UrdfAssetPathHandler.GetMaterialAssetPath(urdfMaterial.name));
var material = RuntimeUrdf.AssetDatabase_LoadAssetAtPath<Material>(UrdfAssetPathHandler.GetMaterialAssetPath(urdfMaterial.name));
if (material != null)
{ //material already exists
return material;
@ -53,7 +53,7 @@ namespace Unity.Robotics.UrdfImporter
material.mainTexture = LoadTexture(urdfMaterial.texture.filename);
}
RuntimeURDF.AssetDatabase_CreateAsset(material, UrdfAssetPathHandler.GetMaterialAssetPath(urdfMaterial.name));
RuntimeUrdf.AssetDatabase_CreateAsset(material, UrdfAssetPathHandler.GetMaterialAssetPath(urdfMaterial.name));
return material;
}
@ -62,9 +62,9 @@ namespace Unity.Robotics.UrdfImporter
{
Material material = defaultMaterial;
#if UNITY_EDITOR
if (!RuntimeURDF.IsRuntimeMode())
if (!RuntimeUrdf.IsRuntimeMode())
{
material = RuntimeURDF.AssetDatabase_LoadAssetAtPath<Material>(UrdfAssetPathHandler.GetMaterialAssetPath(DefaultMaterialName));
material = RuntimeUrdf.AssetDatabase_LoadAssetAtPath<Material>(UrdfAssetPathHandler.GetMaterialAssetPath(DefaultMaterialName));
}
#endif
if (material != null)
@ -78,10 +78,10 @@ namespace Unity.Robotics.UrdfImporter
// just keep it in memory while the app is running.
defaultMaterial = material;
#if UNITY_EDITOR
if (!RuntimeURDF.IsRuntimeMode())
if (!RuntimeUrdf.IsRuntimeMode())
{
// create the material to be reused
RuntimeURDF.AssetDatabase_CreateAsset(material, UrdfAssetPathHandler.GetMaterialAssetPath(DefaultMaterialName));
RuntimeUrdf.AssetDatabase_CreateAsset(material, UrdfAssetPathHandler.GetMaterialAssetPath(DefaultMaterialName));
}
#endif
}
@ -143,9 +143,9 @@ namespace Unity.Robotics.UrdfImporter
{
Material material = defaultMaterial;
#if UNITY_EDITOR
if (!RuntimeURDF.IsRuntimeMode())
if (!RuntimeUrdf.IsRuntimeMode())
{
material = RuntimeURDF.AssetDatabase_LoadAssetAtPath<Material>(UrdfAssetPathHandler.GetMaterialAssetPath(DefaultMaterialName));
material = RuntimeUrdf.AssetDatabase_LoadAssetAtPath<Material>(UrdfAssetPathHandler.GetMaterialAssetPath(DefaultMaterialName));
}
#endif
SetMaterial(gameObject, material);
@ -207,7 +207,7 @@ namespace Unity.Robotics.UrdfImporter
private static Link.Visual.Material.Texture ExportTextureData(Texture texture)
{
string oldTexturePath = UrdfAssetPathHandler.GetFullAssetPath(RuntimeURDF.AssetDatabase_GetAssetPath(texture));
string oldTexturePath = UrdfAssetPathHandler.GetFullAssetPath(RuntimeUrdf.AssetDatabase_GetAssetPath(texture));
string newTexturePath = UrdfExportPathHandler.GetNewResourcePath(Path.GetFileName(oldTexturePath));
if (oldTexturePath != newTexturePath)
{

Просмотреть файл

@ -68,12 +68,12 @@ namespace Unity.Robotics.UrdfImporter
ImportPipelineData im = new ImportPipelineData();
im.settings = settings;
im.loadStatus = loadStatus;
im.wasRuntimeMode = RuntimeURDF.IsRuntimeMode();
im.wasRuntimeMode = RuntimeUrdf.IsRuntimeMode();
im.forceRuntimeMode = forceRuntimeMode;
if (forceRuntimeMode)
{
RuntimeURDF.SetRuntimeMode(true);
RuntimeUrdf.SetRuntimeMode(true);
}
im.robot = new Robot(filename);
@ -83,7 +83,7 @@ namespace Unity.Robotics.UrdfImporter
Debug.LogError("URDF file and ressources must be placed in Assets Folder:\n" + Application.dataPath);
if (forceRuntimeMode)
{ // set runtime mode back to what it was
RuntimeURDF.SetRuntimeMode(im.wasRuntimeMode);
RuntimeUrdf.SetRuntimeMode(im.wasRuntimeMode);
}
return null;
}
@ -103,7 +103,7 @@ namespace Unity.Robotics.UrdfImporter
im.robotGameObject.AddComponent<UrdfRobot>();
im.robotGameObject.AddComponent<Unity.Robotics.UrdfImporter.Control.Controller>();
if (RuntimeURDF.IsRuntimeMode())
if (RuntimeUrdf.IsRuntimeMode())
{// In runtime mode, we have to disable controller while robot is being constructed.
im.robotGameObject.GetComponent<Unity.Robotics.UrdfImporter.Control.Controller>().enabled = false;
}
@ -153,7 +153,7 @@ namespace Unity.Robotics.UrdfImporter
if (im.forceRuntimeMode)
{ // set runtime mode back to what it was
RuntimeURDF.SetRuntimeMode(im.wasRuntimeMode);
RuntimeUrdf.SetRuntimeMode(im.wasRuntimeMode);
}
}

Просмотреть файл

@ -32,7 +32,7 @@ namespace Unity.Robotics.UrdfImporter
public void OnPreprocessModel()
{
#if UNITY_EDITOR
if (!RuntimeURDF.IsRuntimeMode())
if (!RuntimeUrdf.IsRuntimeMode())
{
ModelImporter modelImporter = (ModelImporter)assetImporter;
isCollada = Path.GetExtension(modelImporter.assetPath).ToLowerInvariant() == ".dae";

Просмотреть файл

@ -57,7 +57,7 @@ namespace Unity.Robotics.UrdfImporter
return;
}
RuntimeURDF.PrefabUtility_SaveAsPrefabAsset(gameObject, GetPrefabAssetPath(stlFile));
RuntimeUrdf.PrefabUtility_SaveAsPrefabAsset(gameObject, GetPrefabAssetPath(stlFile));
Object.DestroyImmediate(gameObject);
}
@ -65,9 +65,9 @@ namespace Unity.Robotics.UrdfImporter
{
#if UNITY_EDITOR
// also save the material in the Assets
if (!RuntimeURDF.IsRuntimeMode() && MaterialExtensions.GetRenderPipelineType() == MaterialExtensions.RenderPipelineType.Standard)
if (!RuntimeUrdf.IsRuntimeMode() && MaterialExtensions.GetRenderPipelineType() == MaterialExtensions.RenderPipelineType.Standard)
{
s_DefaultDiffuse = RuntimeURDF.AssetDatabase_GetBuiltinExtraResource<Material>("Default-Diffuse.mat");
s_DefaultDiffuse = RuntimeUrdf.AssetDatabase_GetBuiltinExtraResource<Material>("Default-Diffuse.mat");
}
#endif
if (s_DefaultDiffuse)
@ -89,7 +89,7 @@ namespace Unity.Robotics.UrdfImporter
for (int i = 0; i < meshes.Length; i++)
{
string meshAssetPath = GetMeshAssetPath(stlFile, i);
RuntimeURDF.AssetDatabase_CreateAsset(meshes[i], meshAssetPath);
RuntimeUrdf.AssetDatabase_CreateAsset(meshes[i], meshAssetPath);
GameObject gameObject = CreateStlGameObject(meshAssetPath, material);
gameObject.transform.SetParent(parent.transform, false);
}
@ -99,7 +99,7 @@ namespace Unity.Robotics.UrdfImporter
private static GameObject CreateStlGameObject(string meshAssetPath, Material material)
{
GameObject gameObject = new GameObject(Path.GetFileNameWithoutExtension(meshAssetPath));
gameObject.AddComponent<MeshFilter>().sharedMesh = RuntimeURDF.AssetDatabase_LoadAssetAtPath<Mesh>(meshAssetPath);
gameObject.AddComponent<MeshFilter>().sharedMesh = RuntimeUrdf.AssetDatabase_LoadAssetAtPath<Mesh>(meshAssetPath);
gameObject.AddComponent<MeshRenderer>().sharedMaterial = material;
return gameObject;
}

Просмотреть файл

@ -10,7 +10,7 @@ using UnityEditor;
/// This is to reduce the usage of #if UNITY_EDITOR in the code and have a consistent way of skipping editor only code.
/// Also to allow having the option of running the runtime mode code in editor.
/// </summary>
public static class RuntimeURDF
public static class RuntimeUrdf
{
#if UNITY_EDITOR
public static bool runtimeModeEnabled = false;
@ -242,7 +242,7 @@ public static class RuntimeURDF
var assetName = Path.GetFileNameWithoutExtension(assetPath);
foreach (var guid2 in AssetDatabase_FindAssets(assetName, foldersToSearch))
{
var possiblePath = RuntimeURDF.AssetDatabase_GUIDToAssetPath(guid2);
var possiblePath = RuntimeUrdf.AssetDatabase_GUIDToAssetPath(guid2);
if (string.Equals(possiblePath, assetPath, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal))
{
return true;

Просмотреть файл

@ -7,16 +7,28 @@ using UnityEngine;
/// <summary>
/// Example component for using the runtime urdf import funcionality.
/// To use, attach to a gameobject and use the GUI to load a URDF.
///
/// Notes:
///
/// - This component is for demonstration and testing only
/// and is not intended to be used as is in a final product.
///
/// - The runtime import feature is currently only functional in builds created using
/// Mono scripting backend and will not fully work in standalone builds created with
/// IL2CPP due to the dependency to Assimpnet plugin for loading collada meshes.
/// However URDF files that only use STL format for both visual and collision meshes
/// can still be imported in runtime in standalone IL2CPP builds.
/// </summary>
public class RuntimeURDFImporter : MonoBehaviour
public class RuntimeUrdfImporterExample : MonoBehaviour
{
public string urdfFilepath;
public bool setImmovableLink = true;
public bool useVHACD = false;
public bool useVHACD = false; // this is not yet fully functional in runtime.
public bool showProgress = false; // this is not stable in runtime.
public bool clearOnLoad = true;
public string immovableLinkName = "base_link";
// The values below are tested to work with the niryo_one URDF:
private float controllerStiffness = 10000;
private float controllerDamping = 100;
private float controllerForceLimit = 1000;
@ -25,7 +37,7 @@ public class RuntimeURDFImporter : MonoBehaviour
private GameObject currentRobot = null;
private bool isLoading = false;
private IEnumerator LoadURDF()
private IEnumerator LoadUrdf()
{
isLoading = true;
if (string.IsNullOrEmpty(urdfFilepath))
@ -105,7 +117,7 @@ public class RuntimeURDFImporter : MonoBehaviour
showProgress = GUI.Toggle(new Rect(10, 125, 200, 25), showProgress, "Show Progress (experimental)");
if (!isLoading && GUI.Button(new Rect(530, 50, 150, 25), "Load UDRF File"))
{
StartCoroutine(LoadURDF());
StartCoroutine(LoadUrdf());
}
}
}

Просмотреть файл

@ -21,7 +21,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
assetRoot = "Assets/Tests/Runtime/UrdfAssetPathHandler";
packageRoot = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfAssetPathHandler";
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
Directory.CreateDirectory(assetRoot);
Directory.CreateDirectory(packageRoot);
}
@ -30,7 +30,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
public void GetSetPackageRoot_RuntimeModeEnabled_Success()
{
// Force runtime mode to set testing package root
RuntimeURDF.runtimeModeEnabled = true;
RuntimeUrdf.runtimeModeEnabled = true;
UrdfAssetPathHandler.SetPackageRoot(assetRoot); // Set oldPackagePath
UrdfAssetPathHandler.SetPackageRoot(assetRoot, true); // Run correctPackageRoot
Assert.AreEqual(assetRoot, UrdfAssetPathHandler.GetPackageRoot());
@ -39,7 +39,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
[Test]
public void GetRelativeAssetPath_Nonruntime_NullValues()
{
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
// Everything returns null during non-runtime
Assert.IsNull(UrdfAssetPathHandler.GetRelativeAssetPath("Invalid/Asset/Path"));
Assert.IsNull(UrdfAssetPathHandler.GetRelativeAssetPath($"{assetRoot}/TestAsset.txt"));
@ -49,7 +49,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
[Test]
public void GetRelativeAssetPath_Runtime_Success()
{
RuntimeURDF.runtimeModeEnabled = true;
RuntimeUrdf.runtimeModeEnabled = true;
// Starting with Application.dataPath
Assert.AreEqual("Assets/Valid/Path", UrdfAssetPathHandler.GetRelativeAssetPath($"{Application.dataPath}/Valid/Path"));
// Not starting with dataPath
@ -69,9 +69,9 @@ namespace Unity.Robotics.UrdfImporter.Tests
{
string urdfRoot = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube";
// Force runtime mode to set testing package root
RuntimeURDF.runtimeModeEnabled = true;
RuntimeUrdf.runtimeModeEnabled = true;
UrdfAssetPathHandler.SetPackageRoot(urdfRoot);
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
Assert.AreEqual($"{urdfRoot}/meshes/cube.prefab", UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath("package://meshes/cube.stl"));
Assert.AreEqual($"{urdfRoot}/meshes/cube.prefab", UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath("../meshes/cube.stl"));
@ -80,7 +80,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
[Test]
public void IsValidAssetPath_Nonruntime_Success()
{
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
AssetDatabase.CreateAsset(new TextAsset("TestAsset"), $"{assetRoot}/TestAsset.txt");
// Everything returns null during non-runtime
@ -88,7 +88,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
Assert.IsFalse(UrdfAssetPathHandler.IsValidAssetPath($"{assetRoot}/TestAsset.txt"));
Assert.IsFalse(UrdfAssetPathHandler.IsValidAssetPath($"Packages/com.unity.robotics.urdf-importer/Tests/Runtime/AssetHandlers/UrdfAssetPathHandlerTests.cs"));
RuntimeURDF.runtimeModeEnabled = true;
RuntimeUrdf.runtimeModeEnabled = true;
// Everything returns true during runtime
Assert.IsTrue(UrdfAssetPathHandler.IsValidAssetPath("Invalid/Asset/Path"));
Assert.IsTrue(UrdfAssetPathHandler.IsValidAssetPath($"{assetRoot}/TestAsset.txt"));
@ -99,16 +99,16 @@ namespace Unity.Robotics.UrdfImporter.Tests
public void GetMaterialAssetPath_AssetAndPackage_Success()
{
// Force runtime mode to set testing package root
RuntimeURDF.runtimeModeEnabled = true;
RuntimeUrdf.runtimeModeEnabled = true;
UrdfAssetPathHandler.SetPackageRoot(assetRoot);
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
Assert.AreEqual($"{assetRoot}/Materials/TestMaterial.mat", UrdfAssetPathHandler.GetMaterialAssetPath("TestMaterial"));
// Force runtime mode to set testing package root
RuntimeURDF.runtimeModeEnabled = true;
RuntimeUrdf.runtimeModeEnabled = true;
UrdfAssetPathHandler.SetPackageRoot(packageRoot);
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
Assert.AreEqual($"{packageRoot}/Materials/TestMaterial.mat", UrdfAssetPathHandler.GetMaterialAssetPath("TestMaterial"));
}

Просмотреть файл

@ -18,7 +18,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
[Test]
public void Create_GeometryBox_DefaultGeometry()
{
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
var parent = new GameObject("Parent").transform;
var collision = UrdfCollisionExtensions.Create(parent, GeometryTypes.Box);
@ -32,7 +32,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
[Test]
public void Create_GeometryBoxWithVisual_NondefaultScale()
{
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
var parent = new GameObject("Parent").transform;
var copy = new GameObject("Copy").transform;
copy.transform.localScale = Vector3.one * 2f;
@ -49,7 +49,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
[Test]
public void Create_GeometryMesh_DefaultGeometry()
{
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
var parent = new GameObject("Parent").transform;
var collision = UrdfCollisionExtensions.Create(parent, GeometryTypes.Mesh);
@ -63,7 +63,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
[Test]
public void Create_GeometryMeshWithVisual_NondefaultScale()
{
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
var parent = new GameObject("Parent").transform;
var copy = new GameObject("Copy").transform;
copy.transform.localScale = Vector3.one * 2f;
@ -80,7 +80,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
[Test]
public void Create_LinkCollision_DefaultGeometry()
{
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
var parent = new GameObject("Parent").transform;
var geometry = new Geometry(box:new Box(new double[] {1, 1, 1}));
@ -96,7 +96,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
[Test]
public void ExportCollisionData_DefaultGeometry_Succeeds()
{
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
var parent = new GameObject("Parent").transform;
var collisionComponent = UrdfCollisionExtensions.Create(parent, GeometryTypes.Box);

Просмотреть файл

@ -22,9 +22,9 @@ namespace Unity.Robotics.UrdfImporter.Tests
[SetUp]
public void SetUp()
{
RuntimeURDF.AssetDatabase_CreateFolder("Assets", "Tests");
RuntimeURDF.AssetDatabase_CreateFolder("Assets/Tests", "Runtime");
RuntimeURDF.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "GeometryTests");
RuntimeUrdf.AssetDatabase_CreateFolder("Assets", "Tests");
RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests", "Runtime");
RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "GeometryTests");
}
[Test]
@ -46,9 +46,9 @@ namespace Unity.Robotics.UrdfImporter.Tests
public void Create_CylinderMesh_AssetCreated()
{
// Force runtime mode to set testing package root
RuntimeURDF.runtimeModeEnabled = true;
RuntimeUrdf.runtimeModeEnabled = true;
UrdfAssetPathHandler.SetPackageRoot("Assets/Tests/Runtime/GeometryTests");
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
var parent = new GameObject("Parent").transform;
UrdfGeometryCollision.Create(parent, GeometryTypes.Cylinder);
@ -62,7 +62,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
Assert.IsTrue(Vector3.Distance(Vector3.zero, createdCylinder.GetComponent<MeshCollider>().sharedMesh.bounds.center) < centerDelta);
Assert.IsTrue(Vector3.Distance(new Vector3(0.5f, 1f, 0.5f), createdCylinder.GetComponent<MeshCollider>().sharedMesh.bounds.extents) < scaleDelta);
// Verify Cylinder created in Assets
Assert.IsNotNull(RuntimeURDF.AssetDatabase_FindAssets("Cylinder t:mesh", new string[] {"Assets/Tests/Runtime/GeometryTests"}));
Assert.IsNotNull(RuntimeUrdf.AssetDatabase_FindAssets("Cylinder t:mesh", new string[] {"Assets/Tests/Runtime/GeometryTests"}));
AssetDatabase.DeleteAsset("Assets/Tests/Runtime/GeometryTests/Cylinder.asset");
Object.DestroyImmediate(parent.gameObject);
@ -102,9 +102,9 @@ namespace Unity.Robotics.UrdfImporter.Tests
public void Create_FromStlUnity_CubeMesh()
{
// Force runtime mode to set testing package root
RuntimeURDF.runtimeModeEnabled = true;
RuntimeUrdf.runtimeModeEnabled = true;
UrdfAssetPathHandler.SetPackageRoot("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/");
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
UrdfRobotExtensions.importsettings = ImportSettings.DefaultSettings();
UrdfRobotExtensions.importsettings.convexMethod = ImportSettings.convexDecomposer.unity;
@ -132,9 +132,9 @@ namespace Unity.Robotics.UrdfImporter.Tests
public void Create_FromStlVhacdNotRuntime_CubeMesh()
{
// Force runtime mode to set testing package root
RuntimeURDF.runtimeModeEnabled = true;
RuntimeUrdf.runtimeModeEnabled = true;
UrdfAssetPathHandler.SetPackageRoot("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/");
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
UrdfRobotExtensions.importsettings = ImportSettings.DefaultSettings();
var parent = new GameObject("Parent").transform;
@ -161,7 +161,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
public void Create_FromStlVhacdRuntime_CubeMesh()
{
// Force runtime mode to set testing package root
RuntimeURDF.runtimeModeEnabled = true;
RuntimeUrdf.runtimeModeEnabled = true;
UrdfAssetPathHandler.SetPackageRoot("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/");
UrdfRobotExtensions.importsettings = ImportSettings.DefaultSettings();

Просмотреть файл

@ -52,7 +52,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
public void ExportGeometryData_Cylinder_DefaultGeometry()
{
// Force runtime mode to avoid creating asset file
RuntimeURDF.runtimeModeEnabled = true;
RuntimeUrdf.runtimeModeEnabled = true;
var parent = new GameObject("Parent").transform;
UrdfGeometryCollision.Create(parent, GeometryTypes.Cylinder);
@ -90,9 +90,9 @@ namespace Unity.Robotics.UrdfImporter.Tests
public void ExportGeometryData_MeshUnityDecomposer_DefaultGeometry()
{
// Force runtime mode to set testing package root
RuntimeURDF.runtimeModeEnabled = true;
RuntimeUrdf.runtimeModeEnabled = true;
UrdfAssetPathHandler.SetPackageRoot("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/");
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
UrdfRobotExtensions.importsettings = ImportSettings.DefaultSettings();
UrdfRobotExtensions.importsettings.convexMethod = ImportSettings.convexDecomposer.unity;

Просмотреть файл

@ -16,7 +16,7 @@ namespace Unity.Robotics.UrdfImporter.Tests
public void SetUp()
{
m_StlCubeCopyPath = k_AssetRoot + "/cube.stl";
RuntimeURDF.SetRuntimeMode(false);
RuntimeUrdf.SetRuntimeMode(false);
Directory.CreateDirectory(k_AssetRoot);
}
@ -25,20 +25,20 @@ namespace Unity.Robotics.UrdfImporter.Tests
{
// make a new copy of the stl file
Assert.IsTrue(AssetDatabase.CopyAsset(k_StlCubeSourcePath, m_StlCubeCopyPath));
Assert.IsTrue(RuntimeURDF.AssetExists(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));
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));
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));
Assert.IsTrue(RuntimeUrdf.AssetExists(meshAssetPath));
Assert.IsTrue(RuntimeUrdf.AssetExists(prefabPath));
}
[TearDown]

Просмотреть файл

@ -9,16 +9,16 @@ using Unity.Robotics.UrdfImporter;
namespace Unity.Robotics.UrdfImporter.Tests
{
public class RuntimeURDFTests
public class RuntimeUrdfTests
{
string createAssetPath = "Assets/Tests/Runtime";
string createFolderPath = "Assets/Tests/Runtime/RuntimeURDF";
string createFolderPath = "Assets/Tests/Runtime/RuntimeUrdf";
UnityEngine.Object testObject;
[SetUp]
public void SetUp()
{
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
AssetDatabase.CreateFolder("Assets", "Tests");
AssetDatabase.CreateFolder("Assets/Tests", "Runtime");
@ -28,46 +28,46 @@ namespace Unity.Robotics.UrdfImporter.Tests
[Test]
public void IsRuntimeMode_True()
{
RuntimeURDF.runtimeModeEnabled = true;
Assert.IsTrue(RuntimeURDF.IsRuntimeMode());
RuntimeUrdf.runtimeModeEnabled = true;
Assert.IsTrue(RuntimeUrdf.IsRuntimeMode());
}
[Test]
public void SetRuntimeMode_False()
{
RuntimeURDF.SetRuntimeMode(false);
Assert.IsFalse(RuntimeURDF.IsRuntimeMode());
RuntimeUrdf.SetRuntimeMode(false);
Assert.IsFalse(RuntimeUrdf.IsRuntimeMode());
}
[Test]
public void AssetDatabase_LoadAssetAtPath_Script()
{
RuntimeURDF.SetRuntimeMode(false);
string path = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeURDFTests.cs";
Assert.IsNotNull(RuntimeURDF.AssetDatabase_LoadAssetAtPath<UnityEngine.Object>(path));
RuntimeUrdf.SetRuntimeMode(false);
string path = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeUrdfTests.cs";
Assert.IsNotNull(RuntimeUrdf.AssetDatabase_LoadAssetAtPath<UnityEngine.Object>(path));
}
[Test]
public void AssetDatabase_LoadAssetAtPath_Object()
{
RuntimeURDF.SetRuntimeMode(false);
string path = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeURDFTests.cs";
Assert.IsNotNull(RuntimeURDF.AssetDatabase_LoadAssetAtPath(path, typeof(UnityEngine.Object)));
RuntimeUrdf.SetRuntimeMode(false);
string path = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeUrdfTests.cs";
Assert.IsNotNull(RuntimeUrdf.AssetDatabase_LoadAssetAtPath(path, typeof(UnityEngine.Object)));
}
[Test]
public void AssetDatabase_IsValidFolder_EditorMode()
{
RuntimeURDF.runtimeModeEnabled = false;
Assert.IsTrue(RuntimeURDF.AssetDatabase_IsValidFolder("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport"));
Assert.IsFalse(RuntimeURDF.AssetDatabase_IsValidFolder("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/Does/Not/Exist"));
RuntimeUrdf.runtimeModeEnabled = false;
Assert.IsTrue(RuntimeUrdf.AssetDatabase_IsValidFolder("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport"));
Assert.IsFalse(RuntimeUrdf.AssetDatabase_IsValidFolder("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/Does/Not/Exist"));
}
[Test]
public void AssetDatabase_CreateFolder_AssetAsRoot()
{
RuntimeURDF.runtimeModeEnabled = false;
string createdGUID = RuntimeURDF.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "RuntimeURDF");
RuntimeUrdf.runtimeModeEnabled = false;
string createdGUID = RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "RuntimeUrdf");
string compareGUID = AssetDatabase.GUIDFromAssetPath(createFolderPath).ToString();
// Verify valid folder
@ -77,15 +77,15 @@ namespace Unity.Robotics.UrdfImporter.Tests
Assert.AreEqual(createdGUID, compareGUID);
// Try creating the same folder again
createdGUID = RuntimeURDF.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "RuntimeURDF");
createdGUID = RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "RuntimeUrdf");
Assert.AreEqual(createdGUID, compareGUID);
}
[Test]
public void AssetDatabase_MoveAsset_AssetAsRoot()
{
RuntimeURDF.runtimeModeEnabled = false;
Assert.IsTrue(RuntimeURDF.AssetDatabase_MoveAsset($"{createAssetPath}/TestAsset.prefab", "Assets/Tests/TestAsset.prefab").Length == 0);
RuntimeUrdf.runtimeModeEnabled = false;
Assert.IsTrue(RuntimeUrdf.AssetDatabase_MoveAsset($"{createAssetPath}/TestAsset.prefab", "Assets/Tests/TestAsset.prefab").Length == 0);
// Move back for other tests
AssetDatabase.MoveAsset("Assets/Tests/TestAsset.prefab", $"{createAssetPath}/TestAsset.prefab");
@ -94,79 +94,79 @@ namespace Unity.Robotics.UrdfImporter.Tests
[Test]
public void AssetDatabase_FindAssets_AssetAsRoot()
{
RuntimeURDF.runtimeModeEnabled = false;
Assert.IsTrue(RuntimeURDF.AssetDatabase_FindAssets("TestAsset", new string[] { "Assets/Tests" }).Length > 0);
RuntimeUrdf.runtimeModeEnabled = false;
Assert.IsTrue(RuntimeUrdf.AssetDatabase_FindAssets("TestAsset", new string[] { "Assets/Tests" }).Length > 0);
}
[Test]
public void AssetDatabase_GUIDToAssetPath_AssetAsRoot()
{
RuntimeURDF.runtimeModeEnabled = false;
string createdGUID = RuntimeURDF.AssetDatabase_CreateFolder(createAssetPath, "RuntimeURDF");
Assert.AreEqual(createFolderPath, RuntimeURDF.AssetDatabase_GUIDToAssetPath(AssetDatabase.AssetPathToGUID(createFolderPath)));
RuntimeUrdf.runtimeModeEnabled = false;
string createdGUID = RuntimeUrdf.AssetDatabase_CreateFolder(createAssetPath, "RuntimeUrdf");
Assert.AreEqual(createFolderPath, RuntimeUrdf.AssetDatabase_GUIDToAssetPath(AssetDatabase.AssetPathToGUID(createFolderPath)));
}
[Test]
public void AssetDatabase_GetAssetPath_AssetAsRoot()
{
RuntimeURDF.runtimeModeEnabled = false;
Assert.AreEqual($"{createAssetPath}/TestAsset.prefab", RuntimeURDF.AssetDatabase_GetAssetPath(testObject));
RuntimeUrdf.runtimeModeEnabled = false;
Assert.AreEqual($"{createAssetPath}/TestAsset.prefab", RuntimeUrdf.AssetDatabase_GetAssetPath(testObject));
}
[Test]
public void PrefabUtility_GetCorrespondingObjectFromSource_AssetAsRoot()
{
RuntimeURDF.runtimeModeEnabled = false;
RuntimeUrdf.runtimeModeEnabled = false;
var instantiated = PrefabUtility.InstantiatePrefab(testObject);
Assert.AreEqual(testObject, RuntimeURDF.PrefabUtility_GetCorrespondingObjectFromSource(instantiated));
Assert.AreEqual(testObject, RuntimeUrdf.PrefabUtility_GetCorrespondingObjectFromSource(instantiated));
}
[Test]
public void PrefabUtility_SaveAsPrefabAsset_AssetAsRoot()
{
RuntimeURDF.runtimeModeEnabled = false;
Assert.IsNotNull(RuntimeURDF.PrefabUtility_SaveAsPrefabAsset(new GameObject("TestAsset2"), $"{createAssetPath}/TestAsset2.prefab"));
RuntimeUrdf.runtimeModeEnabled = false;
Assert.IsNotNull(RuntimeUrdf.PrefabUtility_SaveAsPrefabAsset(new GameObject("TestAsset2"), $"{createAssetPath}/TestAsset2.prefab"));
}
[Test]
public void AssetDatabase_GetBuiltinExtraResource_Sprite()
{
RuntimeURDF.runtimeModeEnabled = false;
Assert.IsNotNull(RuntimeURDF.AssetDatabase_GetBuiltinExtraResource<Sprite>("UI/Skin/Background.psd"));
RuntimeUrdf.runtimeModeEnabled = false;
Assert.IsNotNull(RuntimeUrdf.AssetDatabase_GetBuiltinExtraResource<Sprite>("UI/Skin/Background.psd"));
}
[Test]
public void AssetDatabase_CreateAsset_GameObject()
{
RuntimeURDF.runtimeModeEnabled = false;
RuntimeURDF.AssetDatabase_CreateAsset(new TextAsset("TextAsset content"), $"{createAssetPath}/TestAsset3", true);
RuntimeUrdf.runtimeModeEnabled = false;
RuntimeUrdf.AssetDatabase_CreateAsset(new TextAsset("TextAsset content"), $"{createAssetPath}/TestAsset3", true);
Assert.IsNotNull(AssetDatabase.FindAssets("TestAsset3", new string[] { createAssetPath }));
}
[Test]
public void PrefabUtility_InstantiatePrefab_GameObject()
{
RuntimeURDF.runtimeModeEnabled = false;
Assert.IsNotNull(RuntimeURDF.PrefabUtility_InstantiatePrefab(testObject));
RuntimeUrdf.runtimeModeEnabled = false;
Assert.IsNotNull(RuntimeUrdf.PrefabUtility_InstantiatePrefab(testObject));
}
[Test]
public void AssetExists_True()
{
RuntimeURDF.SetRuntimeMode(false);
Assert.IsTrue(RuntimeURDF.AssetExists($"{createAssetPath}/TestAsset.prefab"));
Assert.IsTrue(RuntimeURDF.AssetExists($"{createAssetPath}/tEstAsset.Prefab", true));
RuntimeUrdf.SetRuntimeMode(false);
Assert.IsTrue(RuntimeUrdf.AssetExists($"{createAssetPath}/TestAsset.prefab"));
Assert.IsTrue(RuntimeUrdf.AssetExists($"{createAssetPath}/tEstAsset.Prefab", true));
}
[Test]
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));
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));
}
[TearDown]