|
Post by wohltaeter on Aug 9, 2017 10:20:06 GMT
Hi,
I want to despawn a gameobject (Ngui Uisprite) by custom event- how can I do that?
thanks in advance!
|
|
|
Post by DarkTonic Dev on Aug 9, 2017 18:07:45 GMT
You would have to write your own subclass of ICGKCustomEventReceiver (I think is the name of the class), to do this.
I have on the roadmap to add the ability to make Killables despawn from a custom event.
|
|
|
Post by wohltaeter on Aug 10, 2017 11:37:07 GMT
I have found the class and tried to put the script as usual to a gameobejct but the error-message says class can not be abstract... - can you please help me with the code to make a subclass? - I think it must be monobehavior to be placed on a Gameobjet. - So I want to place the subclass on the object which I want to despawn when I FireCustomEvent("DespawnKarten1").
/*! \cond PRIVATE */ using UnityEngine;
// ReSharper disable once CheckNamespace namespace DarkTonic.CoreGameKit { // ReSharper disable once CheckNamespace public interface ICgkEventReceiver { // this interface is used to "listen" to custom events that Core GameKit transmits. /// <summary> /// This checks for events that are not found in Core GameKit. It's a good idea to call this in Start (Awake is too early), and save yourself some troubleshooting time! Optional /// </summary> void CheckForIllegalCustomEvents();
/// <summary> /// This receives the event when it's fired. /// </summary> void ReceiveEvent(string customEventName, Vector3 eventOrigin);
/// <summary> /// This returns a bool of whether the specified custom event is subscribed to in this class /// </summary> bool SubscribesToEvent(string customEventName);
/// <summary> /// Registers the receiver with Core GameKit. Call this in OnEnable /// </summary> void RegisterReceiver();
/// <summary> /// Unregisters the receiver with Core GameKit. Call this in OnDisable /// </summary> void UnregisterReceiver(); } } /*! \endcond */
|
|
|
Post by DarkTonic Dev on Aug 11, 2017 5:08:06 GMT
Here, I created something for the next version that does what you want and more. This script attached will do one of the following for a chosen Custom Event: despawn, deal X damage or destroy. The last 2 only work on Killables. UniversalCustomEventReceiver.cs (3.63 KB) If you have more actions you'd like me to add to this script, let me know what they are and I'll consider them.
|
|