Skip to content
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

[Enhancement] RequireComponent Attribute #23

Open
inmny opened this issue Oct 14, 2024 · 0 comments
Open

[Enhancement] RequireComponent Attribute #23

inmny opened this issue Oct 14, 2024 · 0 comments

Comments

@inmny
Copy link

inmny commented Oct 14, 2024

It is common to assign RequireComponent for a self-defined component in Unity for easier initialization.

Like this:

class SubComponent : MonoBehaviour {}

[RequireComponent(typeof(SubComponent), typeof(SpriteRenderer))]
class CustomComponent : MonoBehaviour {}

var obj = new GameObject("Test", typeof(CustomComponent));

// Then obj has CustomComponent, SubComponent, SpriteRenderer together.

Is it possible to implement it in Friflo? like this:

[RequireComponent(typeof(Position))] 
struct AnimData : IComponent 
{
    public int frame_idx;
    public Sprite[] ref_frames;
}

var e = store.CreateEntity(new AnimData());
// Then e has both AnimData and Position components.

To my knowledge, it is possible to expand Generic<AnimData>.ComponentTypes through the attribute,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant