Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.
This repository was archived by the owner on May 9, 2025. It is now read-only.

Triggering event on custom variable changed #160

@ReallyRad

Description

@ReallyRad

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions