I just found myself needing to call an event from C# so thought I'd post the process here for any other noobs.
Add the using ORKFramework; to the top of your script.
Create a global object to call the events from ORKFramework.Events.GameEvent gameEvent = new ORKFramework.Events.GameEvent();
Create an inspector field to drag and drop the event you've created with ork into public ORKEventAsset eventAsset;
Now when you need to call the event simply use gameEvent.CallEvent(eventAsset, 0);
You'll either first need to set up an Event Interaction component and call it's StartEvent function, or use the following code to start an event:
ORK.Core.GameObject.AddComponent<GameEventTicker>().StartEvent(ORKGameEvent eventAsset, IEventStarter starter, GameObject startingObject, bool inPause);
The starter is an interface to receive notification when an event finished - you can use null if you don't need it.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
The code you gave above works fine for object that has only one event attached to it.
1.
However, just in case we have several events in an object and want to call the second event, third event, and so on in the same object.
How can we use the code?
2.
Another question, if we want to call an event in a specific name of child object.
How to use the code?
Thanks in advance.
If you have multiple event interactions added to a game object, I'd try getting them all:
EventInteraction[] interaction = gameObject.GetComponents<EventInteraction>();
Theoretically they should be returned in the order they're attached, but I don't think Unity 100% guarentees that ...
2) You'll have to get the child object from the game object - ORK has a helpe class for that:
gameObject = TransformHelper.GetChildObject("path/to/child", gameObject);
It'll return either the found child object or the game object itself if no child was found for the path.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Thanks a lot for your help.
I will try them out and see the result.
I believe I figured out a way to solve my issue from the answer you gave above.
Thanks so much.