public override void Show(string assetName)
        {
            base.Show(assetName);
            EngineRef.SetViewsControlsEnabled(false, false, false, false, false);

            EngineRef.CameraEntity.GetComponent <Transform>().SetTransformations(new Vector3(0f, 0, -2f),
                                                                                 Quaternion.RotationYawPitchRoll(MathUtil.Pi, 0, 0));

            PreviewEntity.SetActive(true);
            EngineRef.ECSWorld.Refresh();

            Texture2DAsset asset = AssetsManagerInstance.GetManager().LoadAsset <Texture2DAsset>(assetName);

            ratio = (float)asset.Data.Width / asset.Data.Height;
            Vector3 scale;

            if (ratio >= 1)
            {
                scale = (Vector3.Right + Vector3.Up / ratio) * 3.85f;
            }
            else
            {
                scale = (Vector3.Right + Vector3.Up * ratio) * 3.85f;
            }
            scale += Vector3.ForwardLH * 0.1f;
            PreviewEntity.GetComponent <Transform>().Scale = scale;

            TestMaterial.AlbedoMapAsset = assetName;
        }
        public override void Show(string assetName)
        {
            base.Show(assetName);
            EngineRef.SetViewsControlsEnabled(true, true, true, false, true);

            EngineRef.CameraEntity.GetComponent <Transform>().SetTransformations(new Vector3(0f, 0, -1.5f),
                                                                                 Quaternion.RotationYawPitchRoll(MathUtil.Pi, 0, 0));
            RendererComponent.SetMaterial(AssetsLoader.LoadMaterialInfo(assetName));

            PreviewEntity.SetActive(true);
            EngineRef.ECSWorld.Refresh();
        }
Ejemplo n.º 3
0
        public void SetPreviewAsset(MetaAsset SelectedAsset)
        {
            ZoomValue            = 1;
            YawValue             = 0;
            PitchValue           = 0;
            ViewValue            = 0;
            ControlsVisibleFlags = new bool[] { false, false, false, false, false };

            var AM = AssetsManager.AssetsManagerInstance.GetManager();

            switch (SelectedAsset.InfoType)
            {
            case AssetTypes.Invalid:
                break;

            case AssetTypes.Mesh:
                break;

            case AssetTypes.Texture2D:
                break;

            case AssetTypes.TextureCube:
                break;

            case AssetTypes.Material:
                MaterialAsset asset = AM.LoadAsset <MaterialAsset>(SelectedAsset.Name);
                AssetObject = new MaterialAssetModelView(asset, EngineRef);
                MAMV?.Invoke(AssetObject);
                break;

            case AssetTypes.Shader:
                break;

            case AssetTypes.Meta:
                break;

            default:
                break;
            }
            EngineRef?.PreviewAsset(SelectedAsset);
        }