public void TearDown()
        {
            List <string> outFailedPaths = new List <string>();

            AssetDatabase.DeleteAssets(new string[] { "Assets/Tests" }, outFailedPaths);
            AssetDatabase.DeleteAssets(new string[] { "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfAssetPathHandler" }, outFailedPaths);
        }
예제 #2
0
        public void ExportGeometryData_MeshUnityDecomposer_DefaultGeometry()
        {
            // Force runtime mode to set testing package root
            RuntimeUrdf.runtimeModeEnabled = true;
            UrdfAssetPathHandler.SetPackageRoot("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/");
            RuntimeUrdf.runtimeModeEnabled     = false;
            UrdfRobotExtensions.importsettings = ImportSettings.DefaultSettings();
            UrdfRobotExtensions.importsettings.convexMethod = ImportSettings.convexDecomposer.unity;

            var    parent       = new GameObject("Parent").transform;
            string path         = "package://meshes/cube.stl";
            var    meshGeometry = new Geometry(mesh: new Mesh(path, new double[] { 1, 1, 1 }));

            UrdfCollisionExtensions.Create(parent, new Collision(meshGeometry));

            UrdfExportPathHandler.SetExportPath("Assets");
            var t      = parent.GetComponentInChildren <UrdfCollision>().transform.GetChild(0);
            var export = UrdfGeometry.ExportGeometryData(GeometryTypes.Mesh, t);

            Assert.IsNotNull(export);

            Object.DestroyImmediate(parent.gameObject);
            List <string> outFailedPaths = new List <string>();

            AssetDatabase.DeleteAssets(new string[] { "Assets/meshes" }, outFailedPaths);
        }
        void RestoreAndCleanup(AddressableAssetSettings settings)
        {
            //Delete our variant entries
            foreach (string guid in variantEntriesToRemove)
            {
                settings.RemoveAssetEntry(guid, false);
            }
            variantEntriesToRemove.Clear();

            //Delete all our variants.
            List <string> failedPaths = new List <string>();

            AssetDatabase.DeleteAssets(variantsPrefabsToDelete.ToArray(), failedPaths);
            foreach (string path in failedPaths)
            {
                Debug.LogError("Failed to delete: " + path);
            }
            variantsPrefabsToDelete.Clear();

            //Restore our original addressable entries
            foreach (AssetEntry entry in entriesToRestore)
            {
                var restoredEntry = settings.CreateOrMoveEntry(entry.assetGUID, entry.group, false, false);
                restoredEntry.address = entry.address;
                foreach (string label in entry.labels)
                {
                    restoredEntry.SetLabel(label, true, false, false);
                }
            }

            entriesToRestore.Clear();
        }
예제 #4
0
    public static void Clear()
    {
        furniturePrefabs.Clear();
        furniturePaths.Clear();
        List <string> failedPaths = new List <string>();

        AssetDatabase.DeleteAssets(new string[] { "Assets/Resources/Auto/Furniture" }, failedPaths);
        AssetDatabase.DeleteAssets(new string[] { "Assets/Resources/Auto/Materials" }, failedPaths);
        AssetDatabase.CreateFolder("Assets/Resources/Auto", "Furniture");
        AssetDatabase.CreateFolder("Assets/Resources/Auto", "Materials");
        AssetDatabase.CreateFolder("Assets/Resources/Auto/Furniture", "Thumbnails");
        AssetDatabase.Refresh();
    }
예제 #5
0
        /// <summary>
        /// Deletes all AudioBuddyObject assets that are fed into the method as a list permanently. Use with caution. Only works in editor.
        /// </summary>
        /// <param name="toBeDeleted"></param>
        private void DeletePartOfDatabase(List <AudioBuddyObject> toBeDeleted)
        {
            List <string> deleteFailed = new List <string>();

            AssetDatabase.DeleteAssets(toBeDeleted.Select(o => AssetDatabase.GetAssetPath(o)).ToArray(), deleteFailed);
            if (deleteFailed.Count > 0)
            {
                Debug.LogWarning($"Deleting of {deleteFailed.Count} AudioBuddy objects failed! Failed assets are:");
                foreach (string remainingSound in deleteFailed)
                {
                    Debug.LogWarning(remainingSound);
                }
            }
            toBeDeleted.Clear();
        }
        public bool RemoveDlls(IEnumerable <string> dllNames)
        {
            var failedPaths = new List <string>();

            ThreadHelper.RunInMainThread(() =>
                                         AssetDatabase.DeleteAssets(dllNames.Select(n => Path.Combine(_dllsDirectory, n)).ToArray(), failedPaths));

            if (failedPaths.Count > 0)
            {
                LogHelper.LogWarning($"Failed remove dll files {string.Join(", ", failedPaths)}");
                return(false);
            }

            return(true);
        }
예제 #7
0
        internal static void RemoveDirectories(params string[] directories)
        {
            var validDirectories = directories.Where(AssetDatabase.IsValidFolder).ToArray();

            if (validDirectories.Any())
            {
#if UNITY_2020
                var failedPathsList = new List <string>();
                if (!AssetDatabase.DeleteAssets(validDirectories, failedPathsList))
                {
                    var pathsCombined = string.Join(Environment.NewLine, failedPathsList);
                    Debug.LogError($"Failed to remove following assets:{Environment.NewLine}{pathsCombined}");
                }
#else
                foreach (var path in validDirectories)
                {
                    FileUtil.DeleteFileOrDirectory(path);
                    FileUtil.DeleteFileOrDirectory(path + ".meta");
                }

                AssetDatabase.Refresh();
#endif
            }
        }
예제 #8
0
        public void TearDown()
        {
            List <string> outFailedPaths = new List <string>();

            AssetDatabase.DeleteAssets(new string[] { "Assets/Tests" }, outFailedPaths);
        }