Forums › 💬 NodeCanvas › 🗨️ General Discussion › Condition Question › Reply To: Condition Question
with this code i can subscribe and unsubscribe. if there are 2 conditions on a state. i miss one subscription. i need a function like ActivatingCondition, DeActivatingCondition.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
public class OnDraggingCondition : ConditionTask { private bool _listens; public int Index; private bool _started; protected override string info { get { var finalString = "OnDraggingCondition"; return finalString; } } /*protected override string OnInit() { _started = false; IT_Gesture.onDraggingE += ItGestureOnOnDraggingE; return null; }*/ private void ItGestureOnOnDraggingE(DragInfo dragInfo) { Debug.Log("OnDraggingCondition Index:" + dragInfo.index); if (dragInfo.index == Index) { IT_Gesture.onDraggingE -= ItGestureOnOnDraggingE; _started = true; } } protected override bool OnCheck() { if (!_listens) { IT_Gesture.onDraggingE += ItGestureOnOnDraggingE; _listens = true; } if (_started) { _started = false; _listens = false; return true; } return false; } } |
