コード例 #1
0
 public void TriggerHidden()
 {
     Debug.Log("Triggering hidden dialogue");
     if (hiddenTriggerOptionalEventOnEnd.GetPersistentEventCount() >= 1)
     {
         SingletonDialogueController.instance.BindEventToDialogueComplete(hiddenTriggerOptionalEventOnEnd);
     }
     SingletonDialogueController.instance.StartDialogue(hiddenDialogue);
 }
コード例 #2
0
 public void Drop()
 {
     drop.Invoke();
     if (drop.GetPersistentEventCount() == 0)
     {
         DefaultDrop();
     }
     parent = null;
 }
コード例 #3
0
        /// <summary>
        /// Function called by Action scriptable object when the action is raised
        /// </summary>
        public void OnActionRaised()
        {
            if (_Response.GetPersistentEventCount() == 0)
            {
                Logger.Log(Logger.Type.Warning, "_Response doesn't have any listener...", this);
            }

            _Response?.Invoke();
        }
コード例 #4
0
 public void Drop()
 {
     drop.Invoke();
     if (drop.GetPersistentEventCount() == 0) // Checks how many listeners you've added -- if zero, runs the default
     {
         DefaultDrop();
     }
     parent = null;
 }
コード例 #5
0
 public void Trigger()
 {
     Debug.Log("Triggering normal dialogue");
     if (triggerOptionalEventsOnEnd.GetPersistentEventCount() >= 1)
     {
         SingletonDialogueController.instance.BindEventToDialogueComplete(triggerOptionalEventsOnEnd);
     }
     SingletonDialogueController.instance.StartDialogue(dialogue);
 }
コード例 #6
0
 public void Drop()
 {
     DropEvent.Invoke();
     if (DropEvent.GetPersistentEventCount() == 0)
     {
         DefaultDrop();
     }
     ActiveHand = null;
 }
コード例 #7
0
    public void EventRaised()
    {
        // default/generic
        if (response.GetPersistentEventCount() >= 1) // always check if at least 1 object is listening for the event
        {
            response.Invoke();
        }

        // string
        if (responseForSentString.GetPersistentEventCount() >= 1)
        {
            responseForSentString.Invoke(gameEvent.sentString);
        }

        // int
        if (responseForSentInt.GetPersistentEventCount() >= 1)
        {
            responseForSentInt.Invoke(gameEvent.sentInt);
        }

        // float
        if (responseForSentFloat.GetPersistentEventCount() >= 1)
        {
            responseForSentFloat.Invoke(gameEvent.sentFloat);
        }

        // bool
        if (responseForSentBool.GetPersistentEventCount() >= 1)
        {
            responseForSentBool.Invoke(gameEvent.sentBool);
        }

        // Vector2
        if (responseForSentVector2.GetPersistentEventCount() >= 1)
        {
            responseForSentVector2.Invoke(gameEvent.sentVector2);
        }

        // Vector3
        if (responseForSentVector3.GetPersistentEventCount() >= 1)
        {
            responseForSentVector3.Invoke(gameEvent.sentVector3);
        }

        // GameObject
        if (responseWithGameObject.GetPersistentEventCount() >= 1)
        {
            responseWithGameObject.Invoke(gameEvent.sentGameObject);
        }

        // AttackEvent
        if (responseWithAttackEvent.GetPersistentEventCount() >= 1)
        {
            responseWithAttackEvent.Invoke(gameEvent.sentAttackEvent);
        }
    }
コード例 #8
0
 public virtual void Played()
 {
     Debug.Log("play " + gameObject.name);
     if (played.GetPersistentEventCount() > 0)
     {
         //trigger additional effect if there is any
         played.Invoke();
     }
     AfterPlayed();
 }
コード例 #9
0
    public void PickUp()
    {
        pickUp.Invoke();

        if (pickUp.GetPersistentEventCount() == 0)
        {
            DefaultPickUp();
        }
        parent.controller.TriggerHapticPulse(3999);
    }
コード例 #10
0
 private void Update()
 {
     if (m_CanExecuteButtons)
     {
         if (OnButtonPress.GetPersistentEventCount() > 0 && PlayerInput.Instance.Interact.Down)
         {
             OnButtonPress.Invoke();
         }
     }
 }
コード例 #11
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        occupants.Add(collision);

        // First Occupant Trigger
        if (occupants.Count == 1 && ZoneIsOccupied.GetPersistentEventCount() != 0)
        {
            ZoneIsOccupied.Invoke();
        }
    }
コード例 #12
0
 static public bool HasEvent(this UnityEvent evt)
 {
     if (evt != null && evt.GetPersistentEventCount() > 0 && !string.IsNullOrEmpty(evt.GetPersistentMethodName(0)))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #13
0
ファイル: ActionCommand.cs プロジェクト: Dann96/CatBoxEngine
 public override void InEditorUpdate(GameObject go)
 {
     for (int i = 0; i < action.GetPersistentEventCount(); i++)
     {
         GameObject ob = action.GetPersistentTarget(i) as GameObject;
         if (go && ob)
         {
             Debug.DrawLine(go.transform.position, ob.transform.position, Color.green);
         }
     }
 }
コード例 #14
0
 public static bool EventContainsPersistentListener <T0, T1, T2, T3>(UnityEvent <T0, T1, T2, T3> unityEvent, UnityAction <T0, T1, T2, T3> listener)
 {
     for (int i = unityEvent.GetPersistentEventCount() - 1; i >= 0; i--)
     {
         if (unityEvent.GetPersistentMethodName(i).Equals(listener.Method.Name) && unityEvent.GetPersistentTarget(i).Equals(listener.Target))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #15
0
 public override void Cleared()
 {
     Score.Points        += bonusPoints;
     Timer.timeRemaining += bonusTime;
     BonusDisplay.ShowBonus(ScoreTypes.ClearedArea, "Cleared " + areaName, bonusPoints);
     if (OnComplete.GetPersistentEventCount() > 0)
     {
         OnComplete.Invoke();
     }
     Notifications.SendNotification(notif);
 }
コード例 #16
0
    void ShowAllMethodsOfEvent <T>(UnityEvent <T> e)
    {
        var color = GUI.color;

        for (var i = 0; i < e.GetPersistentEventCount(); i++)
        {
            GUI.color = i % 2 == 0 ? Color.cyan : Color.yellow;
            GUILayout.Label(e.GetPersistentTarget(i).ToString() + "\n." + e.GetPersistentMethodName(i));
        }
        GUI.color = color;
    }
コード例 #17
0
 private void OnClick()
 {
     if (Execute.GetPersistentEventCount() > 0)
     {
         Execute.Invoke();
     }
     else
     {
         UIManager.Instance.OnBack();
     }
 }
コード例 #18
0
ファイル: Utils.cs プロジェクト: edwonedwon/Unity-Tools
 public static bool EventHasTarget(UnityEvent e)
 {
     for (int i = 0; i < e.GetPersistentEventCount(); i++)
     {
         if (e.GetPersistentTarget(i) != null)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #19
0
        public static void UnityEventField(UnityEvent unityEvent, SerializedProperty serializedEvent)
        {
            var lastRect = GUILayoutUtility.GetLastRect();
            lastRect.y += 20;
            
            EditorGUI.PropertyField(lastRect, serializedEvent, true);

            GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none,
                GUILayout.Height(90 +
                                 Mathf.Max(0, unityEvent.GetPersistentEventCount() - 1) * 42.5f));
        }
コード例 #20
0
ファイル: GameUI.cs プロジェクト: lhm980913/2021GGJMagicRadio
 public void CloseRadioMessage()
 {
     IsTrue = false;
     DuiHuaKuang.SetActive(false);
     timecount = 0;
     if (nextMessage.GetPersistentEventCount() != 0)
     {
         nextMessage.Invoke();
     }
     AudioController.Instance.TryPlayAudio(AudioType.标点击对话);
 }
コード例 #21
0
 void Die()
 {
     if (onDeath.GetPersistentEventCount() > 0)
     {
         onDeath.Invoke();
     }
     else
     {
         gameObject.SetActive(false);
     }
 }
コード例 #22
0
    public void PrintButtonListeners()
    {
        UnityEvent buttonEvent           = button.onClick;
        int        totalRegisteredEvents = buttonEvent.GetPersistentEventCount();

        for (int i = 0; i < totalRegisteredEvents; ++i)
        {
            Debug.Log("Component: " + buttonEvent.GetPersistentTarget(i));
            Debug.Log("Method Name: " + buttonEvent.GetPersistentMethodName(i));
        }
    }
コード例 #23
0
        public static void CopyEventData(UnityEvent source, UnityEvent target)
        {
            int listeners = source.GetPersistentEventCount();

            for (int i = 0; i < listeners; i++)
            {
                System.Reflection.MethodInfo info = UnityEventBase.GetValidMethodInfo(source.GetPersistentTarget(i), source.GetPersistentMethodName(i), new Type[] { typeof(float) });
                UnityAction execute = () => info.Invoke(source.GetPersistentTarget(i), new object[] { 180f });
                target.AddListener(execute);
            }
        }
コード例 #24
0
 static bool HasCall <T>(this UnityEvent <T> @event, UnityEngine.Object caller, string methodName)
 {
     for (int i = 0; i < @event.GetPersistentEventCount(); i++)
     {
         if (@event.GetPersistentTarget(i) == caller && @event.GetPersistentMethodName(i) == methodName)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #25
0
ファイル: DataBinding.cs プロジェクト: jayd16/pragmatic-unity
 protected static void AddEvent(UnityEvent <T> unityEvent, ref int index, UnityAction <T> unityAction)
 {
     if (index == -1)
     {
         UnityEventTools.AddPersistentListener(unityEvent, unityAction);
         index = unityEvent.GetPersistentEventCount() - 1;
     }
     else
     {
         UnityEventTools.RegisterPersistentListener(unityEvent, index, unityAction);
     }
 }
コード例 #26
0
 private void OnDrawGizmos()
 {
     if (debugOn)
     {
         Vector2 thisPos = transform.position;
         for (int i = 0; i < OnPressed.GetPersistentEventCount(); i++)
         {
             GameObject targetObject = OnPressed.GetPersistentTarget(i) as GameObject;
             Debug.DrawLine(thisPos, targetObject.transform.position, debugColor_link);
         }
     }
 }
コード例 #27
0
 public static bool IfNotAlready <T>(UnityEvent <T> @event, UnityEngine.Object target, UnityAction <T> action)
 {
     for (int i = 0; i < @event.GetPersistentEventCount(); ++i)
     {
         if (@event.GetPersistentTarget(i) == target && @event.GetPersistentMethodName(i) == action.Method.Name)
         {
             return(false);
         }
     }
     On(@event, target, action);
     return(true);
 }
コード例 #28
0
    /// <summary>
    /// Same as CheckUnityEventAction but allows to specify passing a param
    /// through the Event.
    /// </summary>
    public static bool CheckUnityEvent <T>(this UnityEvent <T> unityEvent)
    {
        for (int i = 0; i < unityEvent.GetPersistentEventCount(); i++)
        {
            if (unityEvent.GetPersistentTarget(i) != null)
            {
                return(true);
            }
        }

        return(false);
    }
コード例 #29
0
    private void UpdateResponsesCallState()
    {
        for (int i = 0; i < response.GetPersistentEventCount(); i++)
        {
            response.SetPersistentListenerState(i, enableInEditor ? UnityEventCallState.EditorAndRuntime : UnityEventCallState.RuntimeOnly);
        }

        for (int i = 0; i < responseWithData.GetPersistentEventCount(); i++)
        {
            responseWithData.SetPersistentListenerState(i, enableInEditor ? UnityEventCallState.EditorAndRuntime : UnityEventCallState.RuntimeOnly);
        }
    }
コード例 #30
0
ファイル: UnityEventExtension.cs プロジェクト: tkdals9082/KSM
        public static void AddPersistentListener <T0, T1, T2, T3>(this UnityEvent <T0, T1, T2, T3> e, UnityAction <T0, T1, T2, T3> action)
        {
            object persistentCallsObject = null;

            if (!UnityEventReflection.TryAccessPersistentCalls(e, ref persistentCallsObject))
            {
                return;
            }
            int index = e.GetPersistentEventCount();

            UnityEventReflection.AddPersistentListner(persistentCallsObject, index, action.Target as UnityEngine.Object, action.Method);
        }