void DeleteCubemapAssets(bool deleteUnusedOnly)
        {
            var gameObjects = new List <GameObject>();
            var indices     = new List <int>();
            var scenes      = new List <Scene>();

            SceneObjectIDMap.GetAllIDsForAllScenes(
                HDBakingUtilities.SceneObjectCategory.ReflectionProbe,
                gameObjects, indices, scenes
                );

            var indicesSet = new HashSet <int>(indices);

            const int bufferLength = 1 << 10;
            var       bufferStart  = stackalloc byte[bufferLength];
            var       buffer       = new CoreUnsafeUtils.FixedBufferStringQueue(bufferStart, bufferLength);

            // Look for baked assets in scene folders
            for (int sceneI = 0, sceneC = SceneManager.sceneCount; sceneI < sceneC; ++sceneI)
            {
                var scene       = SceneManager.GetSceneAt(sceneI);
                var sceneFolder = HDBakingUtilities.GetBakedTextureDirectory(scene);
                if (!Directory.Exists(sceneFolder))
                {
                    continue;
                }

                var types = TypeInfo.GetEnumValues <ProbeSettings.ProbeType>();
                for (int typeI = 0; typeI < types.Length; ++typeI)
                {
                    var files = Directory.GetFiles(
                        sceneFolder,
                        HDBakingUtilities.HDProbeAssetPattern(types[typeI])
                        );
                    for (int fileI = 0; fileI < files.Length; ++fileI)
                    {
                        if (!HDBakingUtilities.TryParseBakedProbeAssetFileName(
                                files[fileI], out ProbeSettings.ProbeType fileProbeType, out int fileIndex
                                ))
                        {
                            continue;
                        }

                        // This file is a baked asset for a destroyed game object
                        // We can destroy it
                        if (!indicesSet.Contains(fileIndex) && deleteUnusedOnly
                            // Or we delete all assets
                            || !deleteUnusedOnly)
                        {
                            if (!buffer.TryPush(files[fileI]))
                            {
                                DeleteAllAssetsIn(ref buffer);
                            }
                        }
                    }
                }
            }
            DeleteAllAssetsIn(ref buffer);
        }
        public void PushAndPopOutOfBufferRange()
        {
            const int size        = 64;
            var       bufferStart = stackalloc byte[size];
            var       buffer      = new CoreUnsafeUtils.FixedBufferStringQueue(bufferStart, size);

            Assert.True(buffer.TryPush("Lorem ipsum dolor sit"));
            Assert.False(buffer.TryPush("amet, consectetur adipiscing"));

            Assert.AreEqual(1, buffer.Count);
        }
        static void DeleteAllAssetsIn(ref CoreUnsafeUtils.FixedBufferStringQueue queue)
        {
            if (queue.Count == 0)
            {
                return;
            }

            AssetDatabase.StartAssetEditing();
            while (queue.TryPop(out string path))
            {
                AssetDatabase.DeleteAsset(path);
            }
            AssetDatabase.StopAssetEditing();
        }
        public void PushAndPopInBufferRange()
        {
            const int size        = 512;
            var       bufferStart = stackalloc byte[size];
            var       buffer      = new CoreUnsafeUtils.FixedBufferStringQueue(bufferStart, size);

            Assert.True(buffer.TryPush("Lorem ipsum dolor sit"));
            Assert.True(buffer.TryPush("amet, consectetur adipiscing"));
            Assert.True(buffer.TryPush("elit, sed do eiusmod"));
            Assert.True(buffer.TryPush("tempor incididunt ut labore"));

            Assert.AreEqual(4, buffer.Count);

            Assert.True(buffer.TryPop(out string v) && v == "Lorem ipsum dolor sit");
            Assert.True(buffer.TryPop(out v) && v == "amet, consectetur adipiscing");
            Assert.True(buffer.TryPop(out v) && v == "elit, sed do eiusmod");
            Assert.True(buffer.TryPop(out v) && v == "tempor incididunt ut labore");
        }