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

Custom component OnActivated never called #82

Closed
BChapoulie opened this issue Jun 8, 2021 · 2 comments
Closed

Custom component OnActivated never called #82

BChapoulie opened this issue Jun 8, 2021 · 2 comments
Assignees

Comments

@BChapoulie
Copy link

BChapoulie commented Jun 8, 2021

Hello,

I want to perform certain actions according to different WPF button clicks. To do so, I took a great inspiration on how it was done with the CameraResetComponent in the WPF example. My tests using WaveEngine 3.1 went smoothly... however I have a few problems with WaveEngine 3.2.0.7787. In fact, first of all the editor doesn't load my project (see this issue : #80 ). So to achieve my goal I add an entity within the CreateScene method and attach my component to it. However the method OnActivated is never called (I used a breakpoint to check) so I can't bind it to the InteractionService. I tested to do everything programmatically with WaveEngine 3.1 (add an entity in the CreateScene and attach a component to it) and it works fine.

I used the same following code snippet for both versions of WaveEngine

// In MyScene.cs
protected override void CreateScene() 
{
    base.CreateScene();
    var entity = new Entity()
        .AddComponent(MyCustomComponent());

    Managers.EntityManager.Add(entity);
}

// In MyCustomComponent.cs
protected override void OnActivated()
{
    base.OnActivated(); // I've put my breakpoint here, called in v3.1, never called in v3.2
    if (interactionService is not null) 
    {
        interactionService.MyServiceEvent += Service_MyService;
    }
}

Can someone guide me to what I am doing wrong, or if this is a bug in WaveEngine?

Thanks for your help!

@danielcaceresm
Copy link

Hi @BChapoulie,

I have just checked in a new project that the "OnActivated" method is called in WaveEngine 3.2.0.7787.
The issue should be that the component attach fail (because one of its dependencies is not resolved), and it is not activated.
The dependencies issues can be found in the application output:

MyWaveProjectGh82.Windows Error: 0 : [MyWaveProjectGh82.MyCustomComponent] Failed resolving [MyWaveProjectGh82.MyService], and wont be attached. Id:[a5ed3d78-9f2a-43fd-a8f2-fa69f3811629]

@BChapoulie
Copy link
Author

Hello,

Thank you for your reply. Since my issue with the editor has been solved I've managed to see that indeed there was a failure in binding my interaction service. As I am defining a WPF control I thought of registering the InteractionService in the application container in the WPF subproject... but I forgot to do so in the Windows subproject which caused this failure.

Thanks for this guidance which helped me solve my issue!

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

2 participants