question

ToostR-7663 avatar image
0 Votes"
ToostR-7663 asked JackJJun-MSFT commented

Subscribing to an event

So I made a post asking on an explenation on delegates and it was answered, now I want to subscribe to an event but I don't know how to do it. so I'm using an event from the bs_utils refrence., I know I have to use +=. I know I have to set it up llike this

BS_Utils.Utilities.BSEvents.LevelCleared += but thats it so what I want to do is for example have something writting to the console with Log.Debug("Something"); but don't know how to do it, could someone please explain in simple works how to execute this?

dotnet-csharp
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@ToostR-7663, Could you show the related code about how do you define the LevelCleared event?

0 Votes 0 ·

Sorry if I get this wrong, please specify in your next response if I get this wrong, its BS_Utils.Utilities.BSEvents.LevelCleard

0 Votes 0 ·

Ok I think I know what you mean now, there is really none, its reference you can add using the Reference manager built into the template the BS_Utils github is https://github.com/Kylemc1413/Beat-Saber-Utils

0 Votes 0 ·

1 Answer

JackJJun-MSFT avatar image
0 Votes"
JackJJun-MSFT answered JackJJun-MSFT commented

@ToostR-7663, you could try the following code to subscribe to an event.

   BSEvents.levelCleared += BSEvents_levelCleared;
    
   private void BSEvents_levelCleared(StandardLevelScenesTransitionSetupDataSO arg1, LevelCompletionResults arg2)
         {
             Log.Debug("Something");
         }

Note: Please use the same parameter with the event levelCleared.

Hope this could help you.


Best Regards,
Jack


If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Sorry that I’m asking a lot but could you please explain each part of it please ?

0 Votes 0 ·

Ok after putting this in at the BS.Events part is gives me the error "The name BSEvents does not exist in its current context", and for the LevelCompletionResult it gives me this error "The type or namespace name 'LevelCompletionResults' could not be found (are you missing a using directive or an assembly reference?)"

Here is my current code

185893-currentcode.txt


0 Votes 0 ·
currentcode.txt (2.1 KiB)

Precede BSEvents with it's full namespace

0 Votes 0 ·
ToostR-7663 avatar image ToostR-7663 karenpayneoregon ·

When I do that I get 3 errors

185874-image.png


0 Votes 0 ·
image.png (20.4 KiB)
Show more comments