public static void CreateRuntimeEditor(GameObject commandsPanel, string name)
        {
            if (!Object.FindObjectOfType <EventSystem>())
            {
                GameObject es = new GameObject();
                es.AddComponent <EventSystem>();
                es.AddComponent <StandaloneInputModule>();
                es.name = "EventSystem";
            }

            GameObject go = new GameObject();

            go.name = name;
            SplineRuntimeEditor srtEditor = go.AddComponent <SplineRuntimeEditor>();

            GameObject uiEditorGO = RTEditorMenu.InstantiateRuntimeEditor();

            uiEditorGO.transform.SetParent(go.transform, false);

            RuntimeEditor rtEditor = uiEditorGO.GetComponent <RuntimeEditor>();

            UnityEventTools.AddPersistentListener(rtEditor.Closed, new UnityAction(srtEditor.OnClosed));


            Placeholder[] placeholders = uiEditorGO.GetComponentsInChildren <Placeholder>(true);
            Placeholder   cmd          = placeholders.Where(p => p.Id == Placeholder.CommandsPlaceholder).First();

            commandsPanel.transform.SetParent(cmd.transform, false);

            Undo.RegisterCreatedObjectUndo(go, "Battlehub.Spline.CreateRuntimeEditor");
        }
        public static void AddPersistentListener(this UnityEvent uEvent, Action action)
        {
            MethodInfo  targetInfo     = UnityEventBase.GetValidMethodInfo(action.Target, action.Method.Name, new Type[0]);
            UnityAction methodDelegate = Delegate.CreateDelegate(typeof(UnityAction), action.Target, targetInfo) as UnityAction;

            UnityEventTools.AddPersistentListener(uEvent, methodDelegate);
        }
        private GameObject CreateFileOpen()
        {
            FileOpenFactory factory = Undoable.AddComponent <FileOpenFactory>(disposable);

            factory.parent = parent;
            GameObject panel = factory.Generate();

            fileOpenInstance = panel;
            GameObject fileOpenContainer = panel.transform.parent.gameObject;

            fileOpenContainer.transform.localPosition = fileOpenLocalPosition;
            fileOpen = fileOpenInstance.transform.Find("DrivesPanel").GetComponent <FileOpen>();

#if UNITY_EDITOR
            var onOpen = fileOpen.onOpen;
            for (int i = 0; i < onOpen.GetPersistentEventCount(); i++)
            {
                UnityEventTools.RemovePersistentListener(onOpen, 0);
            }
            UnityEventTools.AddPersistentListener(onOpen, fileManager.Open);
            fileOpen.onOpen = onOpen;
#endif

            return(panel);
        }
Beispiel #4
0
    void Reset()
    {
        var button = this.GetComponent <Button>();

        RemoveAllPersistentListener(button.onClick);
        UnityEventTools.AddPersistentListener(button.onClick, BackScreen);
    }
Beispiel #5
0
 public static void CB_COMP_vBreakableObject(GameObject target)
 {
     if (target.GetComponent <vBreakableObject>())
     {
         if (!target.GetComponent <NetworkBreakObject>())
         {
             target.AddComponent <NetworkBreakObject>();
         }
         E_Helpers.SetObjectIcon(target, E_Core.h_genericIcon);
         if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vBreakableObject>().OnBroken, "BreakObject", target.GetComponent <NetworkBreakObject>()))
         {
             UnityEventTools.AddPersistentListener(target.GetComponent <vBreakableObject>().OnBroken, target.GetComponent <NetworkBreakObject>().BreakObject);
         }
     }
     if (target.GetComponentInChildren <vBreakableObject>())
     {
         foreach (vBreakableObject bo in target.GetComponentsInChildren <vBreakableObject>())
         {
             if (!bo.gameObject.GetComponent <NetworkBreakObject>())
             {
                 bo.gameObject.AddComponent <NetworkBreakObject>();
             }
             if (!E_PlayerEvents.HasUnityEvent(bo.OnBroken, "BreakObject", bo.gameObject.GetComponent <NetworkBreakObject>()))
             {
                 UnityEventTools.AddPersistentListener(bo.OnBroken, bo.gameObject.GetComponent <NetworkBreakObject>().BreakObject);
             }
             E_Helpers.SetObjectIcon(bo.gameObject, E_Core.h_genericIcon);
         }
     }
 }
Beispiel #6
0
 public static void CB_COMP_vHealthController(GameObject target)
 {
     if (target.GetComponent <vHealthController>())
     {
         if (!target.GetComponent <SyncHealthController>())
         {
             target.AddComponent <SyncHealthController>();
         }
         E_Helpers.SetObjectIcon(target, E_Core.h_genericIcon);
         vHealthController hc = target.GetComponent <vHealthController>();
         if (!E_PlayerEvents.HasUnityEvent(hc.onReceiveDamage, "SendDamageOverNetwork", target.GetComponent <SyncHealthController>()))
         {
             UnityEventTools.AddPersistentListener(hc.onReceiveDamage, target.GetComponent <SyncHealthController>().SendDamageOverNetwork);
         }
     }
     if (target.GetComponentInChildren <vHealthController>())
     {
         foreach (vHealthController hc in target.GetComponentsInChildren <vHealthController>())
         {
             if (!hc.gameObject.GetComponent <SyncHealthController>())
             {
                 hc.gameObject.AddComponent <SyncHealthController>();
             }
             E_Helpers.SetObjectIcon(hc.gameObject, E_Core.h_genericIcon);
             if (!E_PlayerEvents.HasUnityEvent(hc.onReceiveDamage, "SendDamageOverNetwork", hc.gameObject.GetComponent <SyncHealthController>()))
             {
                 UnityEventTools.AddPersistentListener(hc.onReceiveDamage, hc.gameObject.GetComponent <SyncHealthController>().SendDamageOverNetwork);
             }
         }
     }
 }
Beispiel #7
0
        private void Reset()
        {
            // Finds the fisrt parent object with a CanvasMenu component and sets the _fromMenu field to that menu.
            for (Transform parent = transform.parent; parent != null && parent.transform is RectTransform; parent = parent.parent)
            {
                if (parent.TryGetComponent <CanvasMenu>(out CanvasMenu menu))
                {
                    _fromMenu = menu;
                    break;
                }
            }

            // Adds the transition to the button's click event.
            var onClick = GetComponent <Button>().onClick;

            int removeAt = -1;

            for (int i = 0; i < onClick.GetPersistentEventCount(); i++)
            {
                if (onClick.GetPersistentMethodName(i) == nameof(Transition))
                {
                    removeAt = i;
                    break;
                }
            }

            if (removeAt < 0)
            {
                UnityEventTools.AddPersistentListener(GetComponent <Button>().onClick, new UnityAction(Transition));
            }
        }
Beispiel #8
0
    /// <summary>
    /// EDITOR ONLY
    /// </summary>
    public static void OnValidateOnlyAddEvent(this UnityEvent e, UnityAction action)
    {
#if UNITY_EDITOR
        UnityEventTools.RemovePersistentListener(e, action);
        UnityEventTools.AddPersistentListener(e, action);
#endif
    }
        private GameObject CreateFileSaveAs()
        {
            FileSaveAsFactory factory = Undoable.AddComponent <FileSaveAsFactory>(disposable);

            factory.parent   = parent;
            factory.keyboard = keyboard;
            GameObject panel = factory.Generate();

            fileSaveAsInstance = panel;
            GameObject fileSaveAsContainer = panel.transform.parent.gameObject;

            fileSaveAsContainer.transform.localPosition = fileSaveAsLocalPosition;
            fileSaveAs = fileSaveAsInstance.transform.Find("DrivesPanel").GetComponent <FileSaveAs>();
            fileManager.saveAsPanel = fileSaveAs;


#if UNITY_EDITOR
            var onSaveAs = fileSaveAs.onSaveAs;
            for (int i = 0; i < onSaveAs.GetPersistentEventCount(); i++)
            {
                UnityEventTools.RemovePersistentListener(onSaveAs, 0);
            }
            UnityEventTools.AddPersistentListener(onSaveAs, fileManager.SaveAs);
            fileSaveAs.onSaveAs = onSaveAs;
#endif

            return(panel);
        }
        public void SetupPersistentListeners(object runner)
        {
            UnityEventTools.AddPersistentListener((UnityEvent <ITest>)runner.GetType().GetField("testStartedEvent",
                                                                                                BindingFlags.NonPublic | BindingFlags.Instance).GetValue(runner), new UnityAction <ITest>(test =>
            {
                if (!(test is TestMethod))
                {
                    return;
                }
                ourLogger.Verbose("TestStarted : {0}", test.FullName);
                var internalEvent = new TestInternalEvent(TestEventsSender.GetIdFromNUnitTest(test), "", 0, Status.Running, TestEventsSender.GetIdFromNUnitTest(test.Parent));
                TestEventReceived(new TestEvent(EventType.TestStarted, internalEvent));
            })
                                                  );
            UnityEventTools.AddPersistentListener((UnityEvent <ITestResult>)runner.GetType().GetField("testFinishedEvent",
                                                                                                      BindingFlags.NonPublic | BindingFlags.Instance).GetValue(runner), new UnityAction <ITestResult>(result =>
            {
                if (!(result.Test is TestMethod))
                {
                    return;
                }

                var internalEvent = TestEventsSender.GetTestResult(result);
                TestEventReceived(new TestEvent(EventType.TestFinished, internalEvent));
            }));
            UnityEventTools.AddPersistentListener((UnityEvent <ITestResult>)runner.GetType().GetField("runFinishedEvent",
                                                                                                      BindingFlags.NonPublic | BindingFlags.Instance).GetValue(runner),
                                                  new UnityAction <ITestResult>(result =>
            {
                var internalEvent = new TestInternalEvent("", "", 0, Status.Success, "");
                TestEventReceived(new TestEvent(EventType.RunFinished, internalEvent));
            }));
        }
    private void InitialiseArrays()
    {
        inputHandler = player.GetComponent <AgentInputHandler>();
        int numberOfInputs = inputHandler.commandList.Length;

        menuElements    = new GameObject[numberOfInputs];
        menuElementText = new Text[numberOfInputs, 2];

        KeybindElementFactory keybindElementFactory = new KeybindElementFactory(KeybindMenuElement, this.transform);

        for (int i = 0; i < numberOfInputs; i++)
        {
            menuElements[i] = keybindElementFactory.GetNewInstance();

            Text[] tempTextHolder = menuElements[i].GetComponentsInChildren <Text>();
            for (int j = 0; j < 2; j++)
            {
                menuElementText[i, j] = tempTextHolder[j];
            }

            InputField inputField = menuElements[i].GetComponentInChildren <InputField>();

            UnityEventTools.AddPersistentListener(inputField.onValueChanged, inputHandler.commandList[i].ChangeKeycode);
        }
    }
        void AddEventToTpInput()
        {
            track = target as vHeadTrack;
            if (!track)
            {
                return;
            }

            var tpInput = track.GetComponent <vThirdPersonInput>();

            if (tpInput)
            {
                bool containsListener = false;
                for (int i = 0; i < tpInput.OnLateUpdate.GetPersistentEventCount(); i++)
                {
                    if (tpInput.OnLateUpdate.GetPersistentTarget(i).GetType().Equals(typeof(vHeadTrack)) && tpInput.OnLateUpdate.GetPersistentMethodName(i).Equals("UpdateHeadTrack"))
                    {
                        containsListener = true;
                        break;
                    }
                }
                if (!containsListener)
                {
                    UnityEventTools.AddPersistentListener(tpInput.OnLateUpdate, track.UpdateHeadTrack);
                    SerializedObject tpI = new SerializedObject(tpInput);
                    EditorUtility.SetDirty(tpInput);
                    tpI.ApplyModifiedProperties();
                }
            }
        }
Beispiel #13
0
        static void Compute_ExecuteNode(ActionNode actionNode, Rect placeRect, bool isActive, bool haveWarning, bool haveError)
        {
            ExecuteNode executeNode     = (ExecuteNode)actionNode;
            string      typeName        = "> ";
            int         tmpCommentIndex = 90;
            string      detailsText     = "";

            #region task information
            // check there is any target
            if (executeNode.OnExecute == null)
            {
                return;
            }
            if (executeNode.OnExecute.GetPersistentEventCount() > 0)
            {
                var eventTarget = executeNode.OnExecute.GetPersistentTarget(0);

                // Get target component name.
                string componentName = GetComponentNameFromUnityEventTarget(actionNode, eventTarget);

                // Get target gameObject name.
                string gameObjectName = GetGameObjectNameFromUnityEventTarget(actionNode, eventTarget);

                // Get target methud name.
                string methodName   = executeNode.OnExecute.GetPersistentMethodName(0);
                string methodParams = "";

                // Set detailsText.
                if (eventTarget is IDetails)
                {
                    detailsText = ((IDetails)eventTarget).GetDetails(gameObjectName, componentName, methodName, methodParams);
                }
                else
                {
                    detailsText = string.Format(" [ {0} ] . {1} . {2}({3})", gameObjectName, componentName, methodName, methodParams);
                }
            }
            else if (executeNode.GetComponent <IDefaultExcute>() != null)
            {
                UnityEventTools.AddPersistentListener(executeNode.OnExecute, executeNode.GetComponent <IDefaultExcute>().DefaultExecute);
            }
            else
            {
                // Set detailsText.
                detailsText = string.Format(" [ --- ]");
            }
            #endregion

            #region show stuff
            ShowInformations_DefultStyle(actionNode,
                                         isActive,
                                         haveWarning,
                                         haveError,
                                         typeName,
                                         detailsText,
                                         placeRect,
                                         tmpCommentIndex,
                                         COLOR_NODE);
            #endregion
        }
Beispiel #14
0
    public static void AddListenersToLines()
    {
        CampaignPlayerController playerController = GameObject.Find("GameManager").GetComponent <CampaignPlayerController>();

        //Debug.Log("Player Controller: " + playerController);

        GameObject[] lineButtonsInLevel = GameObject.FindGameObjectsWithTag("LinePlacement");
        //Debug.Log("Line Buttons: " + lineButtonsInLevel.Length);


        foreach (GameObject obj in lineButtonsInLevel)
        {
            UnityEvent btnOnClick = obj.GetComponent <Button>().onClick;

            //Remove 2 empty listeners that are part of the prefab
            UnityEventTools.RemovePersistentListener(btnOnClick, 0);
            UnityEventTools.RemovePersistentListener(btnOnClick, 0);

            //Create Actions for methods to add
            UnityAction drawMethod    = new UnityAction(playerController.PlayerDrawLine);
            UnityAction destroyMethod = new UnityAction(playerController.DestroyStaticLine);

            //Add persistent listeners in editor
            UnityEventTools.AddPersistentListener(btnOnClick, drawMethod);
            UnityEventTools.AddPersistentListener(btnOnClick, destroyMethod);
        }

        EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        Debug.Log("Added listeners to " + lineButtonsInLevel.Length + " line buttons.");
    }
        private GameObject CreateToolsPanel()
        {
            ToolsExamplePanelFactory factory = Undoable.AddComponent <ToolsExamplePanelFactory>(disposable);

            factory.parent        = parent;
            factory.fileOpen      = fileOpen;
            factory.fileSaveAs    = fileSaveAs;
            factory.skyboxManager = skyboxManager;
            GameObject panel = factory.Generate();

            toolsInstance = panel;
            Vector3 localPosition = toolsInstance.transform.localPosition;

            localPosition.x = toolsLocalPosition.x;
            toolsInstance.transform.localPosition = localPosition;

#if UNITY_EDITOR
            var touchPadButtons = touchPadMenuController.touchPadButtons;
            for (int i = 0; i < touchPadButtons[0].onSelected.GetPersistentEventCount(); i++)
            {
                UnityEventTools.RemovePersistentListener(touchPadButtons[0].onSelected, 0);
            }
            UnityEventTools.AddPersistentListener(touchPadButtons[0].onSelected, toolsInstance.GetComponent <StandardPanel>().ToggleVisible);
            touchPadMenuController.touchPadButtons = touchPadButtons;
#endif

            return(panel);
        }
Beispiel #16
0
 public static void CB_COMP_vLadderAction(GameObject target, ref List <string> log)
 {
     if (!target.GetComponent <vLadderAction>())
     {
         return;
     }
     if (!target.GetComponent <SyncPlayer>())
     {
         CB_COMP_SyncPlayer(target, ref log);
     }
     if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vLadderAction>().OnEnterLadder, "EnterLadder", target.GetComponent <SyncPlayer>()))
     {
         if (log != null)
         {
             log.Add("Adding 'EnterLadder' event to vLadderAction's 'OnEnterLadder' unityEvent.");
         }
         UnityEventTools.AddPersistentListener(target.GetComponent <vLadderAction>().OnEnterLadder, target.GetComponent <SyncPlayer>().EnterLadder);
     }
     if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vLadderAction>().OnExitLadder, "ExitLadder", target.GetComponent <SyncPlayer>()))
     {
         if (log != null)
         {
             log.Add("Adding 'ExitLadder' event to vLadderAction's 'OnExitLadder' unityEvent.");
         }
         UnityEventTools.AddPersistentListener(target.GetComponent <vLadderAction>().OnExitLadder, target.GetComponent <SyncPlayer>().ExitLadder);
     }
 }
 private static void SetListeners <T>(PlaymodeTestsController controller, TestRunnerListener eventHandler)
 {
     UnityEventTools.AddPersistentListener <string>(controller.testStartedEvent, new UnityAction <string>(eventHandler.TestStarted));
     UnityEventTools.AddPersistentListener <TestResult>(controller.testFinishedEvent, new UnityAction <TestResult>(eventHandler.TestFinished));
     UnityEventTools.AddPersistentListener <string, List <string> >(controller.runStartedEvent, new UnityAction <string, List <string> >(eventHandler.RunStarted));
     UnityEventTools.AddPersistentListener <List <TestResult> >(controller.runFinishedEvent, new UnityAction <List <TestResult> >(eventHandler.RunFinished));
 }
 private static void SetListeners(PlaymodeTestsController controller, ITestRunnerListener eventHandler)
 {
     UnityEventTools.AddPersistentListener(controller.testStartedEvent, eventHandler.TestStarted);
     UnityEventTools.AddPersistentListener(controller.testFinishedEvent, eventHandler.TestFinished);
     UnityEventTools.AddPersistentListener(controller.runStartedEvent, eventHandler.RunStarted);
     UnityEventTools.AddPersistentListener(controller.runFinishedEvent, eventHandler.RunFinished);
 }
Beispiel #19
0
 void C_vBreakableObject(GameObject target)
 {
     if (_cvBreakableObjects == false)
     {
         return;
     }
     if (target.GetComponent <vBreakableObject>())
     {
         E_Helpers.SetObjectIcon(target, E_Core.h_genericIcon);
         if (!target.GetComponent <NetworkBreakObject>())
         {
             target.AddComponent <NetworkBreakObject>();
         }
         bool sync = !FindObjectOfType <NetworkManager>().syncScenes;
         target.GetComponent <NetworkBreakObject>().GetType().GetField("syncCrossScenes", E_Helpers.allBindings).SetValue(target.GetComponent <NetworkBreakObject>(), sync);
         if (sync == true)
         {
             target.GetComponent <NetworkBreakObject>().GetType().GetField("holder", E_Helpers.allBindings).SetValue(target.GetComponent <NetworkBreakObject>(), target.transform);
         }
         if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vBreakableObject>().OnBroken, "BreakObject", target.GetComponent <NetworkBreakObject>()))
         {
             UnityEventTools.AddPersistentListener(target.GetComponent <vBreakableObject>().OnBroken, target.GetComponent <NetworkBreakObject>().BreakObject);
         }
     }
 }
Beispiel #20
0
        /// <summary>
        /// Replace Close button callback on Cancel instead of the Hide for the Dialog components in the specified GameObject.
        /// </summary>
        /// <param name="go">GameObject.</param>
        public static void FixDialogCloseButton(GameObject go)
        {
            var dialogs = go.GetComponentsInChildren <Dialog>(true);

            foreach (var dialog in dialogs)
            {
                var button_go = dialog.transform.Find("Header/CloseButton");
                if (button_go == null)
                {
                    continue;
                }

                var button = button_go.GetComponent <Button>();
                if (button == null)
                {
                    continue;
                }

                if (IsEventCallMethod(button.onClick, dialog, "Hide"))
                {
                    UnityEventTools.RemovePersistentListener(button.onClick, dialog.Hide);
                    UnityEventTools.AddPersistentListener(button.onClick, dialog.Cancel);
                }
            }
        }
    private void PUN_ConvertvItemCollection(GameObject obj)
    {
        if (obj.GetComponent <vItemCollection>())
        {
            vItemCollection org = obj.GetComponent <vItemCollection>();
            if (!obj.GetComponent <PhotonView>())
            {
                obj.AddComponent <PhotonView>();
            }
            if (!obj.GetComponent <PUN_ItemCollect>())
            {
                obj.AddComponent <PUN_ItemCollect>();
                for (int i = 0; i < obj.GetComponent <vItemCollection>().onDoActionWithTarget.GetPersistentEventCount(); i++)
                {
                    if (obj.GetComponent <vItemCollection>().onDoActionWithTarget.GetPersistentMethodName(i) == "NetworkDestroy")
                    {
                        UnityEventTools.RemovePersistentListener(obj.GetComponent <vItemCollection>().onDoActionWithTarget, i);
                    }
                }
                obj.GetComponent <vItemCollection>().OnDoAction.AddListener(obj.GetComponent <PUN_ItemCollect>().NetworkDestory);
                UnityEventTools.AddPersistentListener(obj.GetComponent <vItemCollection>().OnDoAction, obj.GetComponent <PUN_ItemCollect>().NetworkDestory);
            }

            modified.Add(obj);
        }
    }
Beispiel #22
0
        void AddBlankerObject()
        {
            if (keyboardController.blanker != null)
            {
                Debug.Log("this object already has blanker");
                addBlanker = false;
                return;
            }
            var blankerObj = new GameObject("Blanker");
            var layouel    = blankerObj.AddComponent <LayoutElement>();

            layouel.ignoreLayout = true;
            blankerObj.transform.SetParent(transform);
            blankerObj.transform.FillParent();
            blankerObj.transform.SetAsFirstSibling();
            var rect = blankerObj.GetComponent <RectTransform>();

            rect.anchorMin = new Vector2(0, 1);
            rect.anchorMax = new Vector2(1, 1);
            rect.pivot     = new Vector2(0.5f, 0);
            rect.sizeDelta = new Vector2(0, 300);
            var img = blankerObj.AddComponent <Image>();

            img.color = new Color(0, 0, 0, 0.2f);
            var button = blankerObj.AddComponent <Button>();

            button.transform.localScale = Vector3.one * 2;

            UnityAction action = new UnityAction(keyboardController.Close);

            UnityEventTools.AddPersistentListener(button.onClick, action);
            keyboardController.blanker = button;
        }
    public override void OnInspectorGUI()
    {
        DirtableOverlayPanel dirtablePanel = target as DirtableOverlayPanel;

        DrawDefaultInspector();

        EditorGUILayout.Space();

        if (GUILayout.Button("Add SetDirty to all child inputfields' OnValueChanged", GUILayout.ExpandHeight(true), GUILayout.Height(50)))
        {
            UnityAction <string> dirtyAction = new UnityAction <string>(dirtablePanel.MarkDirty);
            bool alreadyListensToAction      = false;
            foreach (InputField IF in dirtablePanel.GetComponentsInChildren <InputField>(true))
            {
                alreadyListensToAction = false;
                for (int i = 0; i < IF.onValueChanged.GetPersistentEventCount(); i++)
                {
                    if (IF.onValueChanged.GetPersistentMethodName(i) == "MarkDirty")
                    {
                        alreadyListensToAction = true;
                        break;
                    }
                }
                if (alreadyListensToAction)
                {
                    continue;
                }
                UnityEventTools.AddPersistentListener(IF.onValueChanged, dirtyAction);
                Debug.Log("added event to IF: " + IF.transform.name);
            }
        }
    }
        void TryRegisterProperty(Toggle.ToggleEvent poller, UnityAction <bool> f)
        {
            var count = poller.GetPersistentEventCount();

            if (this._clean_empty_no_target_events && count > 0)
            {
                //poller.PollEvent.RemoveAllListeners(); // Only non-persistent listeners.
                for (var i = 0; i < count; i++)
                {
                    if (poller.GetPersistentTarget(i) == null || poller.GetPersistentMethodName(i) == null)
                    {
                        UnityEventTools.RemovePersistentListener(poller, i);
                    }
                }
            }

            count = poller.GetPersistentEventCount();
            if (count == 0)
            {
                UnityEventTools.AddPersistentListener(poller, f);
                poller.SetPersistentListenerState(0, this._unity_event_call_state);
            }
            else if (count > 0)
            {
        #if NEODROID_DEBUG
                if (this.Debugging)
                {
                    Debug.Log($"PollEvent on {poller} already has a listeners");
                }
        #endif
            }
        }
Beispiel #25
0
    static void ConnectNearTilePushedItems(
        Dictionary <Vector2, GameObject> tiles,
        Vector2 nearPosition,
        TileDirection direction,
        PushedItemsEventNode.EventType moveEvent,
        List <PlayerBase> playerBases
        )
    {
        var nearPlayerBase = playerBases.FirstOrDefault(playerBase => playerBase.Contains(nearPosition));

        if (nearPlayerBase != null)
        {
            var action = new UnityAction <PushedItemsEventNode.Data>(nearPlayerBase.Player.PullItems);

            UnityEventTools.AddPersistentListener(moveEvent, action);
        }
        else if (tiles.ContainsKey(nearPosition))
        {
            var nearTile      = tiles[nearPosition];
            var nearDirection = nearTile.GetComponent <TileDirection>();
            var action        = new UnityAction <PushedItemsEventNode.Data>(nearDirection.PullItems);

            UnityEventTools.AddPersistentListener(moveEvent, action);
        }
    }
Beispiel #26
0
 public static void CB_COMP_vItemManager(GameObject target, ref List <string> log)
 {
     if (!target.GetComponent <vItemManager>())
     {
         return;
     }
     if (!target.GetComponent <SyncPlayer>())
     {
         CB_COMP_SyncPlayer(target, ref log);
     }
     if (!E_PlayerEvents.HasUnityEvent(target.GetComponent <vItemManager>().onDropItem, "OnDropItem", target.GetComponent <SyncPlayer>()))
     {
         if (log != null)
         {
             log.Add(" * Adding OnDropItem Event to vItemManager");
         }
         UnityEventTools.AddPersistentListener(target.GetComponent <vItemManager>().onDropItem, target.GetComponent <SyncPlayer>().OnDropItem);
     }
     foreach (EquipPoint ep in target.GetComponent <vItemManager>().equipPoints)
     {
         CB_COMP_AddSyncObjComp(ep.handler.defaultHandler.gameObject, false, ep.equipPointName.ToLower().Contains("left"), false, false, false, true, ref log);
         foreach (Transform customHandler in ep.handler.customHandlers)
         {
             CB_COMP_AddSyncObjComp(customHandler.gameObject, false, ep.equipPointName.ToLower().Contains("left"), false, false, false, true, ref log);
         }
     }
 }
Beispiel #27
0
    private void Reset()
    {
        InputField field = GetComponent <InputField>();

        field.contentType = InputField.ContentType.IntegerNumber;
        UnityEventTools.AddPersistentListener(field.onValueChanged, OnValChangedCaller);
        UnityEventTools.AddPersistentListener(field.onEndEdit, OnEndEditCaller);
    }
Beispiel #28
0
 public void RefreshUnityEventBase()
 {
     if (selectedUnityEventBase is UnityEvent)
     {
         UnityEventTools.RemovePersistentListener((UnityEvent)selectedUnityEventBase, EventTriggerHandler);
         UnityEventTools.AddPersistentListener((UnityEvent)selectedUnityEventBase, EventTriggerHandler);
     }
 }
        public static void AddListenerIfNotExist <T>(this UnityEvent <T> evt, UnityAction <T> action)
        {
            if (evt.IndexOf(action) >= 0)
            {
                return;
            }

            UnityEventTools.AddPersistentListener(evt, action);
        }
Beispiel #30
0
        public void Bind(UnityEvent_string @event)
        {
#if UNITY_EDITOR
            UnityEventTools.AddPersistentListener(@event, GetAction <string>(target, methodName));
#else
            System.Reflection.MethodInfo targetinfo = UnityEvent.GetValidMethodInfo(target, setMethodName, new Type[0]);
            @event.AddListener((str) => targetinfo.Invoke(target, new object[] { str }));
#endif
        }