Example #1
0
        private void CreateTestAsset()
        {
#if DEBUG
            var package = Editor.Session.CurrentPackage;
            if (package != null)
            {
                using (var transaction = Editor.Session.UndoRedoService.CreateTransaction())
                {
                    var dir            = package.AssetMountPoint;
                    var name           = NamingHelper.ComputeNewName("TestAsset", x => dir.Assets.Any(y => string.Equals(x, y.Name, StringComparison.OrdinalIgnoreCase)));
                    var asset          = TestAsset.CreateNew();
                    var assetItem      = new AssetItem(name, asset);
                    var assetViewModel = package.CreateAsset(dir, assetItem, true, null);
                    Editor.Session.NotifyAssetPropertiesChanged(new[] { assetViewModel });
                    Editor.Session.ActiveAssetView.SelectAssets(new[] { assetViewModel });
                    Editor.Session.UndoRedoService.SetName(transaction, $"Create test asset '{name}'");
                }
            }
#endif
        }