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

Triggering event on custom variable changed #160

Open
ReallyRad opened this issue Dec 6, 2021 · 0 comments
Open

Triggering event on custom variable changed #160

ReallyRad opened this issue Dec 6, 2021 · 0 comments

Comments

@ReallyRad
Copy link

Hi!

I'm trying to subscribe to changes made to a custom variables made using code generation. I created a UserStatesVariable based on a UserStates class defined as follows :

public enum UserStatus { headsetOff, headsetOn, readyToStart } 

public class UserStates
{
    public UserStatus selfStatus;
    public UserStatus otherStatus;
    public bool dataCollectionConsent;
}

My StatusManager.cs script has a method that I want to assign as a dynamic UserStates method with the following signature

private void UserStatesChanged(UserStates newState)

I first tried adding the following.

userStatesVariable.AddListener(delegate(UserStates value)
{
    UserStatesChanged(value);
});

but changing the values of the UserStatesVariables wouldn't trigger any event.

I then tried adding the UserStatesVariable as a parameter to a GameEventListener, however, by doing so I am unable to assign the dynamic UserStatesChanged method

So I am left with using an extra event, called UserStatesGameEvent that I can use as an input to an UserStatesGameEventListener to assign to my UserStatesChanged(UserStates newState) method, which I would have liked to avoid.

image

Am I missing something or is it simply not possible to use a custom class as a variable that can be used to trigger events?

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