I’ve been toying around with DOTS on occasion, and just grabbed the Entities 0.50 experimental package to try out.
I haven’t done much with hybrid components thus far and was just looking into how the conversion works with them, however somehow the conversion isn’t creating the CompanionLink component or GameObject and so at runtime when I try to use the added hybrid component it is null.
Authoring Component
using UnityEngine;
public sealed class TestHybridComponent : MonoBehaviour
{
public string Message;
}
Conversion System
using Unity.Entities;
using UnityEngine;
public sealed class TestHybridComponentConversionSystem : GameObjectConversionSystem
{
protected override void OnUpdate()
{
Entities.ForEach((TestHybridComponent component) => {
Entity entity = GetPrimaryEntity(component);
DstEntityManager.AddComponentObject(entity, component);
});
}
}
For my scene, I am leaving the camera outside of the SubScene but have the directional light, a ground plane, and a sphere inside the SubScene. I also have a GameObject with my TestHybridComponent script with a string parameter on it as shown here:
Everything seems to be correct here, however when I close the SubScene for conversion, if I take a look at the converted entities, and find the one with my TestHybridComponent script on it, there is no CompanionLink component created for it:
Now this might be a systemic issue, however if I take a look at the Entity corresponding to the “Directional Light” (converted by the Hybrid Renderer package) then the CompanionLink is created correctly, and references seem to be valid:
So I’m a little at a loss as to what I am doing differently to how the Lights are being converted…taking a look at the conversion system in use by Hybrid Renderer I can see that it’s little more than what I’m doing:
Now, there are a few differences between this and mine, all of which I have tried and the result is the same:
- Adding the ConverterVersion attribute to the conversion system
- Adding the WorldSystemFilter attribute to the conversion system
- Calling InitEntityQueryCache(20) in the OnCreate method
- Calling ConfigureEditorRenderData on the TestHybridComponent’s GameObject
I realise this is my first post on the forums. I usually like to dig around and try to solve issues by myself but at this point I’m at a loss as to why the conversion process creates CompanionLink for the “Directional Light” GameObject I have, but not for my own test object. Any help would be greatly appreciated!