Esempio n. 1
0
        /// <inheritdoc/>
        protected override PreviewEntity CreatePreviewEntity()
        {
            // load the material from the data base
            var material = LoadAsset <Material>(AssetItem.Location);

            // create a sphere model to display the material
            var proceduralModel = CreatePrimitiveModel(previewPrimitive);
            var model           = proceduralModel.GenerateModel(Game.Services); // TODO: should dispose those resources at some points!

            model.Add(material);

            // create the entity, create and set the model component
            var materialEntity = new Entity {
                Name = BuildName()
            };

            materialEntity.Add(new ModelComponent {
                Model = model
            });

            var previewEntity = new PreviewEntity(materialEntity);

            previewEntity.Disposed += () => UnloadAsset(material);
            return(previewEntity);
        }
Esempio n. 2
0
        /// <inheritdoc/>
        protected override PreviewEntity CreatePreviewEntity()
        {
            // create the preview entity from the entity build on the database
            var entity        = LoadAsset <Entity>(AssetItem.Location);
            var previewEntity = new PreviewEntity(entity);

            // ensure that the model is correctly unloaded after used
            previewEntity.Disposed += () => UnloadAsset(previewEntity.Entity);

            return(previewEntity);
        }
Esempio n. 3
0
        /// <inheritdoc/>
        protected override PreviewEntity CreatePreviewEntity()
        {
            UFile spriteStudioSheetLocation = AssetItem.Location;
            // load the created material and the model from the data base
            var sheet = LoadAsset<SpriteStudioSheet>(spriteStudioSheetLocation);

            // create the entity, create and set the model component
            var entity = new Entity { Name = "Preview entity of SpriteStudio sheet: " + spriteStudioSheetLocation };
            entity.Add(new SpriteStudioComponent { Sheet = sheet });

            var previewEntity = new PreviewEntity(entity);

            previewEntity.Disposed += () => UnloadAsset(sheet);

            return previewEntity;
        }
Esempio n. 4
0
        /// <inheritdoc/>
        protected override PreviewEntity CreatePreviewEntity()
        {
            // create the preview entity from the entity build on the database
            var entity = LoadAsset <Entity>(AssetItem.Location);

            // Don't preview scene, as they cannot be added as child of a scene
            if (entity is Scene)
            {
                UnloadAsset(entity);
                return(null);
            }
            var previewEntity = new PreviewEntity(entity);

            // ensure that the model is correctly unloaded after used
            previewEntity.Disposed += () => UnloadAsset(previewEntity.Entity);

            return(previewEntity);
        }
Esempio n. 5
0
        /// <inheritdoc/>
        protected override PreviewEntity CreatePreviewEntity()
        {
            // load the material from the data base
            var model = LoadAsset <Model>(AssetItem.Location);

            // create the entity, create and set the model component
            var modelEntity = new Entity {
                Name = BuildName()
            };

            modelEntity.Add(new ModelComponent {
                Model = model
            });

            var previewEntity = new PreviewEntity(modelEntity);

            previewEntity.Disposed += () => UnloadAsset(model);
            return(previewEntity);
        }
Esempio n. 6
0
        protected override PreviewEntity CreatePreviewEntity()
        {
            var prefab = LoadAsset <Prefab>(AssetItem.Location);

            var entity = new Entity {
                Name = "Preview Entity of model: " + AssetItem.Location
            };

            foreach (var prefabEntity in prefab.Entities)
            {
                entity.AddChild(prefabEntity);
            }

            var previewEntity = new PreviewEntity(entity);

            previewEntity.Disposed += () => UnloadAsset(prefab);

            return(previewEntity);
        }
Esempio n. 7
0
        /// <summary>
        /// Handles the Click event of the btnPreview control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnPreview_Click(object sender, EventArgs e)
        {
            // Clean-up UI
            gPreview.Visible     = true;
            ltImportResults.Text = string.Empty;

            RockContext rockContext         = new RockContext();
            var         workflowTypeService = new WorkflowTypeService(rockContext);
            var         workflowType        = workflowTypeService.Get(wtpExport.SelectedValueAsId().Value);
            var         coder    = new EntityCoder(new RockContext());
            var         exporter = new WorkflowTypeExporter();

            coder.EnqueueEntity(workflowType, exporter);

            List <PreviewEntity> previewEntities = new List <PreviewEntity>();

            foreach (var qe in coder.Entities)
            {
                string shortType = CodingHelper.GetEntityType(qe.Entity).Name;

                if (shortType == "Attribute" || shortType == "AttributeValue" || shortType == "AttributeQualifier" || shortType == "WorkflowActionFormAttribute")
                {
                    continue;
                }

                var preview = new PreviewEntity
                {
                    Guid       = qe.Entity.Guid,
                    Name       = EntityFriendlyName(qe.Entity),
                    ShortType  = shortType,
                    IsCritical = qe.IsCritical,
                    IsNewGuid  = qe.RequiresNewGuid,
                    Paths      = qe.ReferencePaths.Select(p => p.ToString()).ToList()
                };

                previewEntities.Add(preview);
            }

            ViewState["PreviewEntities"] = previewEntities;

            BindPreviewGrid();
        }
Esempio n. 8
0
        /// <inheritdoc/>
        protected override PreviewEntity CreatePreviewEntity()
        {
            UFile modelLocation = AssetItem.Location;
            // load the created material and the model from the data base
            var model = LoadAsset <Model>(modelLocation);

            // create the entity, create and set the model component
            var entity = new Entity {
                Name = "Preview Entity of model: " + modelLocation
            };

            entity.Add(new ModelComponent {
                Model = model
            });

            var previewEntity = new PreviewEntity(entity);

            previewEntity.Disposed += () => UnloadAsset(model);

            return(previewEntity);
        }
Esempio n. 9
0
        protected override PreviewEntity CreatePreviewEntity()
        {
            var skybox = LoadAsset <Skybox>(AssetItem.Location);

            var rootEntity = new Entity();

            // Create skybox lighting
            var skyLight = new Entity();

            skyLight.Add(new LightComponent {
                Type = new LightSkybox {
                    Skybox = skybox
                }
            });
            rootEntity.AddChild(skyLight);

            targetEntity = CreateMaterialPreview(rootEntity, Vector3.Zero, out previewModel);

            var previewEntity = new PreviewEntity(rootEntity);

            previewEntity.Disposed += () => UnloadAsset(skybox);
            return(previewEntity);
        }
Esempio n. 10
0
        protected override PreviewEntity CreatePreviewEntity()
        {
            if (compiledModelUrl == null)
            {
                return(null);
            }

            // load the created material and the model from the data base
            var model   = LoadAsset <Model>(compiledModelUrl);
            var anim    = LoadAsset <AnimationClip>(AssetItem.Location);
            var animSrc = LoadAsset <AnimationClip>(AssetItem.Location + AnimationAssetCompiler.SrcClipSuffix);

            // create the entity, create and set the model component
            var entity = new Entity {
                Name = "Preview Entity of animation: " + AssetItem.Location
            };

            entity.Add(new ModelComponent {
                Model = model
            });
            // In case of additive animation, play the original source (we can't play the additive animation itself)
            entity.Add(new AnimationComponent {
                Animations = { { "preview", animSrc ?? anim } }
            });

            var previewEntity = new PreviewEntity(entity);

            previewEntity.Disposed += () => UnloadAsset(model);
            previewEntity.Disposed += () => UnloadAsset(anim);
            if (animSrc != null)
            {
                previewEntity.Disposed += () => UnloadAsset(animSrc);
            }

            return(previewEntity);
        }