Beispiel #1
0
        public void AssetDatabase_GUIDToAssetPath_AssetAsRoot()
        {
            RuntimeUrdf.runtimeModeEnabled = false;
            string createdGUID = RuntimeUrdf.AssetDatabase_CreateFolder(createAssetPath, "RuntimeUrdf");

            Assert.AreEqual(createFolderPath, RuntimeUrdf.AssetDatabase_GUIDToAssetPath(AssetDatabase.AssetPathToGUID(createFolderPath)));
        }
Beispiel #2
0
 public void SetUp()
 {
     // a robot tag needs to be added in project settings before runtime import can work
     RuntimeUrdf.SetRuntimeMode(false);
     UrdfRobotExtensions.CreateTag();
     RuntimeUrdf.AssetDatabase_CreateFolder("Assets", "Tests");
     RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests", "Runtime");
     RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "GeometryTests");
 }
Beispiel #3
0
 private static void MoveMaterialsToNewLocation(string oldPackageRoot)
 {
     if (RuntimeUrdf.AssetDatabase_IsValidFolder(Path.Combine(oldPackageRoot, MaterialFolderName)))
     {
         RuntimeUrdf.AssetDatabase_MoveAsset(
             Path.Combine(oldPackageRoot, MaterialFolderName),
             Path.Combine(UrdfAssetPathHandler.GetPackageRoot(), MaterialFolderName));
     }
     else
     {
         RuntimeUrdf.AssetDatabase_CreateFolder(UrdfAssetPathHandler.GetPackageRoot(), MaterialFolderName);
     }
 }
Beispiel #4
0
        public static void SetPackageRoot(string newPath, bool correctingIncorrectPackageRoot = false)
        {
            string oldPackagePath = packageRoot;

            packageRoot = GetRelativeAssetPath(newPath);

            if (!RuntimeUrdf.AssetDatabase_IsValidFolder(Path.Combine(packageRoot, MaterialFolderName)))
            {
                RuntimeUrdf.AssetDatabase_CreateFolder(packageRoot, MaterialFolderName);
            }

            if (correctingIncorrectPackageRoot)
            {
                MoveMaterialsToNewLocation(oldPackagePath);
            }
        }
Beispiel #5
0
        public void AssetDatabase_CreateFolder_AssetAsRoot()
        {
            RuntimeUrdf.runtimeModeEnabled = false;
            string createdGUID = RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "RuntimeUrdf");
            string compareGUID = AssetDatabase.GUIDFromAssetPath(createFolderPath).ToString();

            // Verify valid folder
            Assert.IsTrue(AssetDatabase.IsValidFolder(createFolderPath));

            // Verify matching GUID
            Assert.AreEqual(createdGUID, compareGUID);

            // Try creating the same folder again
            createdGUID = RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "RuntimeUrdf");
            Assert.AreEqual(createdGUID, compareGUID);
        }
Beispiel #6
0
        private static void ConvertCylinderToCollider(MeshFilter filter)
        {
            GameObject go       = filter.gameObject;
            var        collider = filter.sharedMesh;

            // Only create an asset if not runtime import
            if (!RuntimeUrdf.IsRuntimeMode())
            {
                var packageRoot = UrdfAssetPathHandler.GetPackageRoot();
                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();
            }
            MeshCollider current = go.AddComponent <MeshCollider>();

            current.sharedMesh = collider;
            current.convex     = true;
            Object.DestroyImmediate(go.GetComponent <MeshRenderer>());
            Object.DestroyImmediate(filter);
        }