Prioritize more than one EventHandler in C#.

117 views Asked by At

So the problem is I have a class in C#, in Unity that has a few EventHandlers. They are responsible for input for GearVR but it's not relevant. I need to prioritize methods they're calling. I know that C# invokes them depending on order they're added. I know I can write a Dictionary that will handle that but then I'll need to write a lot of dictionaries (there's 16 events), and I also know I can override add funtion of these EventHandlers but it'll be a lot overriding.

I need to prioritize methods added to 16 events and I want to do it in a good way.Does anybody know how I can do such thing?

1

There are 1 answers

0
Jerome Maurey-Delaunay On

We had that same issue recently in an HTC Vive Unreal project where a single input (trigger) was controlling various actions like:

  • Moving a slider
  • Teleporting freely
  • Teleporting to a preset locations in an area
  • etc...

In the end, and just as jdl134679 indicated, we used Tags on target objects to figure out what they user was pointing out (looking at in your case). In Unreal the PlayerController had the basic logic to handle a case or not.