コード例 #1
0
        public static bool HasUnityEvent(StringUnityEvent targetEvent, string HasMethodName, UnityEngine.Object hasTarget)
        {
            int count = targetEvent.GetPersistentEventCount();

            for (int i = 0; i < count; i++)
            {
                if (targetEvent.GetPersistentMethodName(i) == HasMethodName && targetEvent.GetPersistentTarget(i) == hasTarget)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
        public void RegisterAction(
            PlayerAction action,
            UnityAction <String> onDisplayStringChanged,
            UnityAction <Sprite> onDisplaySpriteChanged
            )
        {
            if (onDisplayStringChanged != null)
            {
                StringUnityEvent evnt = actionDisplayNameEvents.ContainsKey(action) ? actionDisplayNameEvents[action] : new StringUnityEvent();
                evnt.AddListener(onDisplayStringChanged);
                actionDisplayNameEvents[action] = evnt;
            }

            if (onDisplaySpriteChanged != null)
            {
                SpriteUnityEvent evnt = actionDisplaySpriteEvents.ContainsKey(action)
                    ? actionDisplaySpriteEvents[action]
                    : new SpriteUnityEvent();
                evnt.AddListener(onDisplaySpriteChanged);
                actionDisplaySpriteEvents[action] = evnt;
            }
        }
コード例 #3
0
/*AUTO SCRIPT*/ public void RemoveListener(StringUnityEvent listener)
/*AUTO SCRIPT*/ {
/*AUTO SCRIPT*/ unityEventListeners.TryRemove(listener);
/*AUTO SCRIPT*/ }
コード例 #4
0
ファイル: E_UI.cs プロジェクト: ZRace/ZRace
        public static void CB_AddFreeForAllModernUI()
        {
            if (EditorUtility.DisplayDialog("Are you sure?",
                                            "This will overwrite the settings for your teamName, initialTeamSpawnPointNames, " +
                                            "autoSpawnPlayer, and allowTeamDamaging options on your NetworkManager component. " +
                                            "Do you want to continue?",
                                            "Yes, Add ModernUI", "No"))
            {
                GameObject     ui = (GameObject.Find("ModernUI") != null) ? GameObject.Find("ModernUI") : E_Helpers.CreatePrefabFromPath("InvectorMultiplayer/UI/PreBuilt/ModernUI.prefab");
                NetworkManager nm = FindObjectOfType <NetworkManager>();
                ui.transform.SetParent(nm.transform);

                //Setup team settings
                nm.allowTeamDamaging = true;
                nm.teamName          = "";
                nm.initalTeamSpawnPointNames.Clear();
                nm.autoSpawnPlayer = false;

                //Capture Event Groups
                UnityEvent       joinRoomEvents           = nm.roomEvents._onJoinedRoom;
                UnityEvent       onLeftLobby              = nm.lobbyEvents._onLeftLobby;
                PlayerEvent      onPlayerEnter            = nm.playerEvents._onPlayerEnteredRoom;
                PlayerEvent      onPlayerLeft             = nm.playerEvents._onPlayerLeftRoom;
                StringUnityEvent joinRoomFailedEvents     = nm.roomEvents._onJoinRoomFailed;
                StringUnityEvent createRoomFailedEvents   = nm.roomEvents._onCreateRoomFailed;
                StringUnityEvent onDisconnected           = nm.otherEvents._onDisconnected;
                StringUnityEvent onConnectionFailedEvents = nm.otherEvents._onConnectionFail;
                StringUnityEvent photonFailedEvents       = nm.otherEvents._onFailedToConnectToPhoton;

                if (!E_PlayerEvents.HasUnityEvent(createRoomFailedEvents, "NetworkErrorOccured", ui.GetComponent <UICoreLogic>()))
                {
                    UnityEventTools.AddPersistentListener(createRoomFailedEvents, ui.GetComponent <UICoreLogic>().NetworkErrorOccured);
                }
                if (!E_PlayerEvents.HasUnityEvent(joinRoomFailedEvents, "NetworkErrorOccured", ui.GetComponent <UICoreLogic>()))
                {
                    UnityEventTools.AddPersistentListener(joinRoomFailedEvents, ui.GetComponent <UICoreLogic>().NetworkErrorOccured);
                }
                if (!E_PlayerEvents.HasUnityEvent(onDisconnected, "NetworkErrorOccured", ui.GetComponent <UICoreLogic>()))
                {
                    UnityEventTools.AddPersistentListener(onDisconnected, ui.GetComponent <UICoreLogic>().NetworkErrorOccured);
                }
                if (!E_PlayerEvents.HasUnityEvent(photonFailedEvents, "NetworkErrorOccured", ui.GetComponent <UICoreLogic>()))
                {
                    UnityEventTools.AddPersistentListener(photonFailedEvents, ui.GetComponent <UICoreLogic>().NetworkErrorOccured);
                }
                if (!E_PlayerEvents.HasUnityEvent(onConnectionFailedEvents, "NetworkErrorOccured", ui.GetComponent <UICoreLogic>()))
                {
                    UnityEventTools.AddPersistentListener(onConnectionFailedEvents, ui.GetComponent <UICoreLogic>().NetworkErrorOccured);
                }

                E_Helpers.SetObjectIcon(ui, E_Core.h_uiIcon);
                Debug.Log("Successfully added \"ModernUI\" and setup the UnityEvents in the \"Network Manager\" and the \"ModernUI\".");
                if (EditorUtility.DisplayDialog("Successfully Added ModernUI!",
                                                "The UICoreLogic has a \"selectablePlayers\" gameobject array that must be populated with your converted players that " +
                                                "are stored in the \"Resources\" folder. A helper menu option is available for you to automatically find " +
                                                "all of your converted players in the \"Resources\" folder and add it to this components array.\n\n" +
                                                "You can find this helper method under CB Games > UI > Add > All Player Prefabs To UICoreLogic.",
                                                "Thanks For The Tip!"))
                {
                    Selection.activeGameObject = ui.gameObject;
                }
            }
        }
コード例 #5
0
/*AUTO SCRIPT*/
/*AUTO SCRIPT*/ public void AddListener(StringUnityEvent listener)
/*AUTO SCRIPT*/ {
/*AUTO SCRIPT*/ unityEventListeners.TryAdd(listener);
/*AUTO SCRIPT*/ }