![]() | IKasEventsOnLinkCreated Property |
Namespace: KASAPIv2
EventData<IKasLinkEvent> OnLinkCreated { get; }
The argument of the callback is a KAS event object that describes the link.
Consider using OnKASLinkedState(IKasLinkEvent, Boolean) when this state change is needed in scope of just one part.
public class KasEventsExample1: PartModule { public override void OnAwake() { base.OnAwake(); KASAPI.KasEvents.OnStartLinking.Add(LinkStarted); KASAPI.KasEvents.OnStopLinking.Add(LinkStopped); KASAPI.KasEvents.OnLinkCreated.Add(LinkCreated); KASAPI.KasEvents.OnLinkBroken.Add(LinkBroken); } void OnDestroy() { KASAPI.KasEvents.OnStartLinking.Remove(LinkStarted); KASAPI.KasEvents.OnStopLinking.Remove(LinkStopped); KASAPI.KasEvents.OnLinkCreated.Remove(LinkCreated); KASAPI.KasEvents.OnLinkBroken.Remove(LinkBroken); } void LinkStarted(ILinkSource source) { DebugEx.Info("Link started by: {0}", source); } void LinkStopped(ILinkSource source) { DebugEx.Info("Link stopepd by: {0}", source); } void LinkCreated(IKasLinkEvent ev) { DebugEx.Info("Link created: {0} <=> {1}", ev.source, ev.target); } void LinkBroken(IKasLinkEvent ev) { DebugEx.Info("Link broken: {0} <=> {1}", ev.source, ev.target); } }