playcanvas / editor

Issue tracker for the PlayCanvas Editor
https://playcanvas.com/
154 stars 28 forks source link

Downloading a template asset is not working #551

Open tgg-dhruv opened 2 years ago

tgg-dhruv commented 2 years ago

Description

Not able to download a template asset by clicking the download button in inspector. Upon clicking the said button, a new tab opens showing "{"error":"Not Found"}". Please allow downloading a template and importing a template from the downloaded template file.

Steps to Reproduce

  1. Create a template.
  2. Select the created template asset.
  3. Click on the Download button available in the inspector.
  4. A new tab opens showing the above-mentioned error message.
yaustar commented 2 years ago

Please allow downloading a template and importing a template from the downloaded template file.

At runtime or importing into the project in the Editor?

What are the use cases for both? The template asset is purely JSON that has the entity hierarchy and component data but doesn't store any thing like models, textures etc.

If you want to copy templates to other projects, you can do so by right clicking on the asset, copy and in the other project, paste and it will not only copy the template but also all the associated assets such scripts, models etc.

tgg-dhruv commented 2 years ago

At runtime or importing into the project in the Editor?

I meant for importing into project in editor. When we copy and paste the template from one project to another, all the connected assets(textures, materials, scripts, etc.) also get created in the target project with all connections intact.

What I meant is the same thing but through file import.

To elaborate more, read the following scenario:

Suppose I want to create a package (zipped folder) for some functionality. The package will contain all the necessary assets (scripts, textures, materials, etc.) including templates of some ready-made entities that the user will just have to instantiate in their project for using them, to implement the functionality. For copy and paste the user will need access to both the source project and the target project. This is undesirable in this scenario because the creator is making this package so that they don't have to provide access to his source project to the other users.

So if we could download the templates (which i guess will probably automatically download its connected assets along with template JSON), the creator can put the template JSON and connected assets in the package. The end users will just have to import the package. The template JSON in the package will be recognized and read by the editor and all the connected assets will then be loaded from the package .

That is the whole idea. It's probably not very refined but it would be very helpful.

If this becomes available then, people can create custom packages and make them available for other users to import and use. If the creators can upload their custom packages to playcanvas asset store that would be even better.

yaustar commented 2 years ago

Ah, so similar to assetpackages in Unity? Currently, that isn't support with any assets at the moment but something that has been requested a few times.

For copy and paste the user will need access to both the source project and the target project. This is undesirable in this scenario because the creator is making this package so that they don't have to provide access to his source project to the other users.

Why is it undesirable? Wouldn't having the package be the same as having access to content in the project regardless? I currently do this for our 3D Bitmoji Library: https://playcanvas.com/project/721733/overview/3d-bitmoji-library

tgg-dhruv commented 2 years ago

Why is it undesirable? Wouldn't having the package be the same as having access to content in the project regardless?

No, it's not the same. Suppose, the functionality you want to provide as a package is only a small part of a big project, then access to the project exposes the whole project which may be undesirable if the project is a private project and you want the public to see only the final product that gets released and not the project itself.

Therefore, in my opinion, it would be better to provide the functionality as a separate package than providing the end users access to the project.

yaustar commented 2 years ago

Ah, I see. Normally when I do this, I create a new public project that just contains the package and examples that have been copied from a larger private project. And then share the smaller public project.

tgg-dhruv commented 2 years ago

agreed, that is a way to do it but it involves extra work of creating a new project just for that functionality.

Anyways, it would be awesome if this feature is introduced in playcanvas. I mean both asset packages and template downloads & imports.

Steveorevo commented 2 years ago

I’d like to upvote this.

This would be a very nice feature, including the linked template assets, materials, scripts; either as a single JSON file or broken up and zipped. Other high-level tools past (Adobe Director, HyperCard, Elemental) provided similar functionality with assets.

It also facilitated code re-use and sharing. I could see an entire eco-system or marketplace for template assets; complete with their own materials and importantly their behaviors, etc. Just drop in (import/upload) the template asset and you could be own your way with avatars, NPCs, various entities that have all their logic ready to go. Because each asset has a unique ID, redundant linked scripts, materials, etc, could be merged (either promoting the user or default to overwrite all) on upload/import.

To provide this functionality in the editor would be ideal; through the REST API and optionally somehow at runtime through our own code would be above and beyond (but not necessary).

The nature of JSON makes them friendly for code repositories and viewing differentials too (JSON pretty print format please).

yaustar commented 2 years ago

Currently sharing assets/code is generally best handled on a copy/paste between projects which we should expand to allow a smarter overwrite system to replace existing assets.

At as part of the publish/build process, any template that is marked as preload is part of the config.json file and templates not marked as preload, will be in a separate JSON file. (not pretty printed for size).

At the moment, downloading and importing materials, templates, textures, models etc are not supported with the meta data. It's

I think working on a smarter overwrite system for copying and pasting would be the way to go next.

Steveorevo commented 2 years ago

Copy and paste is working great. It’s just a code reuse and sharing aspect that would be ideal. I get that the editor is SaaS and it’s an awesome one at that; with built in version control.

But I’d still love a way to have an asset market from third party repos (github, gitlab, etc). Node-RED allows this plus the aforementioned upload/download of zip modules.

I guess this could be created as a editor extension using the documented browser extension suggestion or through the REST api?

yaustar commented 2 years ago

It’s just a code reuse and sharing aspect that would be ideal.

Can you elaborate a bit more here please? I typically have my libraries with code and templates to be in a folder so one can copy and paste the whole folder.

But I’d still love a way to have an asset market

There is a ticket about sharing projects as libraries: https://github.com/playcanvas/editor/issues/340 but yes I agree, it be nice to have some way to load form other sources.

Steveorevo commented 2 years ago

That would make even more sense; upload/download of a given folder. Yes, I noticed placing everything I need in a folder and using copy/paste works beautifully! That's how I currently do it to "merge" projects.

I can see that building a complex game or application may require features from other projects; and this is where it would apply. Some editors offer package management for dependencies in their IDE. I.e. Node-RED has a sidebar where you can choose community assets (they call nodes; see screenshot) or you can upload your own as a zip file. In formerly Macromedia/Adobe Director, they had "external casts"; these were just folders that you could link to that came from someplace else and could be re-used in other projects.

But to simplify things upload/download a folder that could include template assets would make drag n' drop of complete game characters, with their own behavior and material intact would be a great feature.

Having a community library pallet or marketplace to add to that would be awesome as well. It's one thing to get a model or mesh with materials and perhaps animation; it's quite a step up to have it include all it's behavior (scripts) as well. And with multiple template assets within that folder. Uses could be:

8 -node-red-install-module-search

Steveorevo commented 2 years ago

I guess in the end this needs to be weighed against just copying and pasting against existing projects. After all, the more complex assets would want to be previewed before being copied over to another.

I believe the upload/download of a folder would simply make it more obvious to creators that if you want your template assets to be shared or re-used; one really needs to be more structured than placing scripts randomly about.

yaustar commented 2 years ago

Current workaround from: https://github.com/meta-space-org/playcanvas-server-boilerplate#templates

Open Editor
Select single Template asset
Open Dev Tools > Console
Execute in console: JSON.stringify(editor.call('selector:items')[0].json(), null, 4);
Right-click on logged string > Copy string contents
Paste copied JSON into ./src/templates/template.json - your template file
Maksims commented 2 years ago

Current workaround from: https://github.com/meta-space-org/playcanvas-server-boilerplate#templates

Open Editor
Select single Template asset
Open Dev Tools > Console
Execute in console: JSON.stringify(editor.call('selector:items')[0].json(), null, 4);
Right-click on logged string > Copy string contents
Paste copied JSON into ./src/templates/template.json - your template file

Loved it if the Download button would actually download just that JSON (maybe without some branch and other data). When uploading JSON, it can check if it is valid JSON, then check using the validator, to identify what kind of content it has, that way it could upload JSON file and detect it is an asset with type template.

jpauloruschel commented 2 years ago

While the feature for downloading Templates is not complete, we're removing the Download button for Template assets. This is to avoid confusion, as clicking that button yields a 404. https://github.com/playcanvas/editor/releases/tag/v1.21.38