Hi again,

How can I access the Mesh generated by the spine assets inside a prefab to use with Particle Systems. We would like to use the mesh generated by the spine assets to use in a particle system renderer:

I have tried setting both Fix Prefab Overr.Mesh Filter on and off. Thanks!

Related Discussions
...

To use the mesh generated by Spine assets inside a prefab for a particle system renderer, you can follow these steps:

  1. Enable the Fix Prefab Override MeshFilter: Ensure that the Fix Prefab Override MeshFilter option is enabled in the Spine Preferences. This can be done globally in the Spine Preferences window or individually on each SkeletonRenderer component. This setting helps manage the mesh data within prefabs.

  2. Access the Mesh: You can use a SkeletonRenderSeparator to isolate the desired part of the mesh. This allows you to use the corresponding MeshRenderer's mesh as an emitter source for your particles. Here’s a brief guide on how to do this:

    • Add a SkeletonRenderSeparator component to your Spine GameObject.
    • Configure the SkeletonRenderSeparator to separate the parts of the mesh you want to use.
    • Access the MeshRenderer component of the separated part to get the mesh.
  3. Use the Mesh in Particle System: Once you have the mesh, you can assign it to the particle system renderer. Here’s a simple example in code:

       using UnityEngine;
    
       public class MeshParticleEmitter : MonoBehaviour
       {
           public ParticleSystem particleSystem;
           public SkeletonRenderer skeletonRenderer;
    
           void Start()
           {
               Mesh mesh = skeletonRenderer.GetComponent<MeshFilter>().mesh;
               var shape = particleSystem.shape;
               shape.shapeType = ParticleSystemShapeType.Mesh;
               shape.mesh = mesh;
           }
       }
  4. Handling Prefab Overrides: If you encounter issues with prefabs always being marked as "Override" due to the mesh data, you can refer to the issue ticket here for more details and potential workarounds.

By following these steps, you should be able to use the mesh generated by Spine assets in your particle system renderer effectively.

@belovedquestioningly If you need references to the MeshFilter, you have to disable Fix Prefab Override MeshFilter, as the documentation explains:

Fix Prefab Override MeshFilter. Fixes the prefab always being marked as changed (sets the MeshFilter's hide flags to DontSaveInEditor), but at the cost of references to the MeshFilter by other components being lost. When set to Use Global Settings, the setting in Spine Preferences is used.

You might need to update the prefab before saving it after changing the setting to disabled to re-create the MeshFilter with the proper hide flags.


Hi,
I have disabled mesh filter, and the reference is still lost.

@belovedquestioningly Unfortunately we could not reproduce this behaviour. Did you apply the prefab?
Which exact version of the spine-unity runtime (name of the unitypackage also listed in Assets/Spine/version.txt, or the version listed in the Package Manager) are you using?

    un mois plus tard

    Harald
    Apologies for getting back to you late,
    Do you mean by apply to use the "Save" feature after prefab has changes in Unity, then yes. I have applied but once I get back into the prefab after saving, the reference is lost. I can send in this project as a package if needed, unfortunately I could not upload it to this message as an attachment.

    Package version: spine-unity-4.2-2024-06-25.unitypackage

    @belovedquestioningly In your GIF you are assigning a Mesh reference, not a MeshFilter reference. In general with the skeleton components procedurally generating and filling meshes (two meshes, used as a double-buffer) at runtime it's only reliable to store a reference to a MeshFilter or MeshRenderer and then getting the Mesh via MeshFilter.sharedMesh or similar.

    Admittedly we have not yet tested whether the stored Mesh reference keeps the same asset guid, it seems no to be the case. Anyway, this mesh would never be updated at runtime and would keep the setup pose, so likely it's not what you want.

    Hi @Harald
    So to assign the mesh within a particle system, I need to have a script that gets the Mesh from Meshfilter using MeshFilter.sharedMesh and does this mean to be able to access it, I will need to have the Mesh filter in settings disabled or does it not longer matter?

      belovedquestioningly I will need to have the Mesh filter in settings disabled or does it not longer matter?

      You need to have the setting disabled, yes. This setting always mattered just for the MeshFilter (that's why it's named like that as well).