New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial support for prefab preview thumbnails #1931
Conversation
In order to support prefab thumbnails MeshFilter.sharedMesh needs to be saved as an asset, otherwise the scene mesh will be used by unity, which creates a type mismatch. To overcome this problem a prefab asset post processor is introduced to generate and save a new mesh with the prefab. When a prefab is created/updated this post process script is run and generates a new skeleton mesh and saves the one stored in MeshFilter component for each game object with SkeletonRenderer component attached. This way unity can use this saved in prefab mesh to generate preview thumbnail for the prefab.
a09089f
to
4a02935
Compare
After posting the previous message I realized it is possible to reuse the same logic in the asset postprocessor, but instead of attaching a pre-generated asset file, it can be used to generate and store in the prefab a new one. As far as I can tell it solved a few of the issues mentioned above - it supports dynamic mesh and skins. |
As it turned out this pull request breaks player build. For this reason I am closing this pull-request for the moment to prevent anyone cherry-picking it and realizing their builds are broken by it on a later state. |
…b instance always listing MeshFilter as changed (via parameter `Advanced - Fix Prefab Override MeshFilter`, see changelog). Closes #1273.
With the new prefab processing there is an issue where the mesh tries to get into the build. To prevent this a build pre/post process is introduced that will clean up the prefab from the meshes before the build and restore the prefab meshes after the build. This change reverts bf70a62 and is related to EsotericSoftware#1273,EsotericSoftware#1931.
With the new prefab processing there is an issue where the mesh tries to get into the build. To prevent this a build pre/post process is introduced that will clean up the prefab from the meshes before the build and restore the prefab meshes after the build. This change reverts bf70a62 and is related to EsotericSoftware#1273,EsotericSoftware#1931.
With the new prefab processing there is an issue where the mesh tries to get into the build. To prevent this a build pre/post process is introduced that will clean up the prefab from the meshes before the build and restore the prefab meshes after the build. This change reverts bf70a62 and is related to EsotericSoftware#1273,EsotericSoftware#1931.
This is an early (WIP) request for comment on preliminary (and very limited) support for prefab thumbnails ( #1722 ).
Currently the prefab assets don't include any visual hint that there are any spine skeletons in them.
The reason for this is basically that when saving a asset results in MeshFilter's sharedMesh being invalid. This can be caused by one of the following reasons (depending on the current state of the SkeleonRenderer object):
The fact that the dynamic mesh is scene only object results in type mismatch mesh (partially handled by #1387 ) which then results in null mesh on the subsequent prefab modifications.
This change introduces an extra asset next to SkeletonData asset, that holds the a mesh in SetupPose which is attached to the sharedMesh when prefab is being saved. This way a thumbnail is generated with the default setup pose for every spine skeleton inside a prefab.This pull request is more of an initial proof-of-concept and a scream for help
Known things that needs to be completed (and verified):
While I haven't check a lot of possible scenarios, the simple change presented here seems to work in the most simple use-case. I don't know if it could create any fatal error, but I guess it can have a corner case where an error is logged to the console while saving a prefab. At least on the spine examples I imported nothing broke during the import.What I mostly want to do as a next step is to enable dynamic mesh save support (I believe this will also fix skin support?)I imagine this to happen by adding the mesh to the prefab asset (using AssetDatabase.AddObjectToAsset(mesh, prefab) and updating it when changed. I tried to do that by scraping out the double buffer and pointing the mesh to an asset.
What I failed to achieve here is two thing:
Another issue with the above approach I see is how to handle the embedded mesh assets inside the prefab. I haven't come up yet with an idea how to clean up the garbage (for example when a skeleton is deleted from a prefab), how to resolve name collisions (with multiple skeletons inside a prefab), nor how to handle nested prefabs.Any suggestions on how to proceed further with this are welcome (also any comment on the above checks too)