I instantiate a prefab as a child of a hybrid game object and then why I start the instance with particle system nothing happens?? Any idea what I am doing wrong? I see the cline as a child in the scene but it doesn’t trigger when I want to.
Hybrid renderer 0.9 added support for particle system(i believe). Just letting you know.
1 Like
Basically, conversionSystem.AddHybridComponent(comp)
will do the job.
But for ParticleSystem there is one extra hidden component ParticleSystemRenderer
HybridComponent Tool
using Unity.Entities;
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
[DisallowMultipleComponent]
[RequiresEntityConversion]
public class HybridComponent : MonoBehaviour, IConvertGameObjectToEntity
{
[SerializeField] protected List<UnityEngine.Component> Components = new List<Component>();
public virtual bool IsNativeSupported(Component comp) =>
comp is Transform ||
comp is MeshRenderer ||
comp is MeshFilter ||
comp is SpriteRenderer ||
comp is UnityEngine.VFX.VisualEffect ||
comp is IConvertGameObjectToEntity ||
comp is ConvertToEntity ||
comp.GetType().Name.Contains("Authoring");
protected virtual void Reset()
{
Components.Clear();
foreach (var comp in gameObject.GetComponents<Component>())
{
if (IsNativeSupported(comp)) continue;
else Components.Add(comp);
}
}
private void OnValidate()
{
if (Components.Any(c => c is ParticleSystem) && Components.All(c => !(c is ParticleSystemRenderer)))
{
var renderer = GetComponent<ParticleSystemRenderer>();
if (renderer != null) Components.Add(renderer);
else Debug.LogError("ParticleSystem referenced but ParticleSystemRenderer is missing!");
}
}
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
foreach (var comp in Components)
{
if (!comp) continue;
if (comp is SkinnedMeshRenderer) continue;
if (comp is Animator) continue;
conversionSystem.AddHybridComponent(comp);
}
}
}
Reset HybridComponent will trigger a new search for potential Components
1 Like
UnityEngine.VFX.VisualEffect is the new way of doing FX, It will be made HybridComponent by default.
That’s probably why ParticleSystem is not made HybridComponent automatically.
1 Like
@Lieene-Guo Thank you so much for your answer here. This would have wasted an insane amount of my time if not for your pro-tip about the ParticleSystemRenderer. Cheers.