Skip to content

Best way to associate Svelto Components with UnityGameObject #93

Answered by cathei
lovepurple asked this question in Q&A
Discussion options

You must be logged in to vote

You can make a component that holds unique id of game object, such as ObjectIndexComponent here. (Maybe your GameObjectComponent is doing the same thing?)

public struct ObjectIndexComponent : IEntityComponent
{
    public          uint          index;
    public readonly PrimitiveType type;

    public ObjectIndexComponent(PrimitiveType type) : this() { this.type = type; }
}

Which can be assigned when GameObject is created. Such as here in SyncEntityCreation Engine.

public void Add(ref ObjectIndexComponent entityComponent, EGID egid)
{
    entityComponent.index = _oopManager.RegisterEntity(entityComponent.type);
}

Then query both ObjectIndexComponent and FadeoutComponent from PlayerFadeou…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@lovepurple
Comment options

@lovepurple
Comment options

Answer selected by lovepurple
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
FAQ Svelto FAQs
2 participants