/// <summary> /// Will add the `WaitRefresh` to be called with the `teamsUpdated` and `voiceViewUpdated` delegates. /// </summary> protected virtual void OnEnable() { _prevPlayerCount = 0; logic = FindObjectOfType <UICoreLogic>(); logic.teamsUpdated += WaitRefresh; logic.voiceViewUpdated += WaitRefresh; }
/// <summary> /// Sets the loading image, loading desc and load title on the UICoreLogic component. /// </summary> public virtual void SetLoadingScreenItems() { logic = FindObjectOfType <UICoreLogic>(); if (logic != null) { logic.loadingImages = (LoadingImages.Count > 0) ? LoadingImages : logic.loadingImages; logic.loadingTitle = LoadingTitle; logic.loadingDesc = (LoadingDescriptions.Count > 0) ? LoadingDescriptions : logic.loadingDesc; } else { ui = FindObjectOfType <ExampleUI>(); if (ui != null) { if (LoadingImages.Count > 0) { ui.SetLoadingImages(LoadingImages); } ui.SetLoadingTitleText(LoadingTitle); ui.ResetLoadingBar(); if (LoadingDescriptions.Count > 0) { ui.SetLoadingDescriptionText(LoadingDescriptions); } } } }
/// <summary> /// Waits until the `UICoreLogic`'s room list is greater than zero. As soon as it is it calls the /// `GetRoomListFromUI` function. /// </summary> /// <returns></returns> protected virtual IEnumerator WaitForChange() { if (debugging == true) { Debug.Log("Waiting for a room list update"); } logic = (logic == null) ? FindObjectOfType <UICoreLogic>() : logic; yield return(new WaitUntil(() => logic.GetRoomList().Count > 0)); GetRoomListFromUI(); }
public static void CB_AddPlayersToExampleUI() { if (EditorUtility.DisplayDialog("About To Add Players", "This will scan all the prefabs in your root Resources folder and attempt to find all " + "of the player prefabs. Then it will assign these found prefabs to the \"players\" gameobject " + "array in the \"ExampleUI\" component. This will overwrite any settings currently there.\n\n" + "Do you want to continue?", "Continue", "Cancel")) { UICoreLogic ui = FindObjectOfType <UICoreLogic>(); if (ui == null) { if (EditorUtility.DisplayDialog("Missing ExampleUI", "You are missing an example UI from the scene. Please add it before trying this again.", "Okay")) { } } else { string[] prefabPaths = E_Helpers.GetAllPrefabs(false, true); GameObject target; List <GameObject> foundPlayers = new List <GameObject>(); foreach (string prefabPath in prefabPaths) { try { UnityEngine.Object prefab = AssetDatabase.LoadMainAssetAtPath(prefabPath); target = (GameObject)prefab; if (target.GetComponent <vThirdPersonController>()) { foundPlayers.Add(target); } } catch { continue; } } ui.selectablePlayers = foundPlayers.ToArray(); if (EditorUtility.DisplayDialog("Completed!", "The found player prefabs of the resources folder have been added to the ExampleUI. \n\n" + "Remember to save this to the prefab otherwise it will be removed when you click play.", "Great!")) { Selection.activeGameObject = ui.gameObject; } } } }
IEnumerator WaitForLogic() { if (randomMusic.Length < 1) { yield return(null); } yield return(new WaitUntil(() => NetworkManager.networkManager != null)); yield return(new WaitUntil(() => NetworkManager.networkManager.GetComponentInChildren <UICoreLogic>())); logic = NetworkManager.networkManager.GetComponentInChildren <UICoreLogic>(); Debug.Log(randomMusic[Random.Range(0, randomMusic.Length)]); logic.SetMusicAudio(randomMusic[Random.Range(0, randomMusic.Length)]); logic.SetMusicVolume(0); logic.SetFadeToVolume(volume); logic.FadeMusic(false); logic.PlayMusic(); }
/// <summary> /// Sets this component values with the `InstantiationData` for this component. Also /// adds the `RecievedPhotonEvent` function to the Photon's `EventReceived` delegate /// so it will be called anytime a PhotonEvent is received. /// </summary> protected virtual void Start() { logic = NetworkManager.networkManager.GetComponentInChildren <UICoreLogic>(); if (GetComponent <PhotonView>()) { object[] data = GetComponent <PhotonView>().InstantiationData; if (data != null) { foreach (Photon.Realtime.Player player in PhotonNetwork.PlayerList) { if (player.UserId == (string)data[0]) { SetPlayerContents(player); SetReadyState(logic.PlayerIsReady(player.UserId)); } } Transform parentToSet = StaticMethods.FindTargetChild((int[])data[1], logic.transform); transform.SetParent(parentToSet); transform.localScale = new Vector3(1, 1, 1); transform.position = Vector3.zero; } } PhotonNetwork.NetworkingClient.EventReceived += RecievedPhotonEvent; }
protected virtual void Start() { logic = FindObjectOfType <UICoreLogic>(); }
public override void OnInspectorGUI() { #region Core base.OnInspectorGUI(); UICoreLogic cl = (UICoreLogic)target; DrawTitleBar( "UI Core Logic", "This component is what almost everything in the UI calls. This is " + "also open enough that it exposes enough functions for you to use in your own UIs (hopefully).\n" + "Only one of these components should ever be in the scene at a time. If more than one \"UICoreLogic\" component " + "is found it could cause errors.", E_Core.h_uiIcon ); #endregion #region Session/Core Settings GUILayout.BeginHorizontal(_skin.customStyles[1]); GUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Core Options", _skin.textField); GUILayout.FlexibleSpace(); if (GUILayout.Button(EditorGUIUtility.FindTexture("d_AnimationWrapModeMenu"), _skin.label, GUILayout.Width(50))) { cl.e_show_core = !cl.e_show_core; } EditorGUILayout.EndHorizontal(); if (cl.e_show_core == true) { EditorGUILayout.PropertyField(defaultLevelIndex); EditorGUILayout.PropertyField(selectablePlayers, true); EditorGUILayout.PropertyField(sceneList, true); EditorGUILayout.PropertyField(debugging); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(5); #endregion #region Audio GUILayout.BeginHorizontal(_skin.customStyles[1]); GUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Sound Options", _skin.textField); GUILayout.FlexibleSpace(); if (GUILayout.Button(EditorGUIUtility.FindTexture("d_AnimationWrapModeMenu"), _skin.label, GUILayout.Width(50))) { cl.e_show_audio = !cl.e_show_audio; } EditorGUILayout.EndHorizontal(); if (cl.e_show_audio == true) { EditorGUILayout.PropertyField(musicSource); EditorGUILayout.PropertyField(soundSource); EditorGUILayout.PropertyField(mouseEnter); EditorGUILayout.PropertyField(mouseEnterVolume); EditorGUILayout.PropertyField(mouseExit); EditorGUILayout.PropertyField(mouseExitVolume); EditorGUILayout.PropertyField(mouseClick); EditorGUILayout.PropertyField(mouseClickVolume); EditorGUILayout.PropertyField(finalClick); EditorGUILayout.PropertyField(startVolume); EditorGUILayout.PropertyField(fadeInAudio); EditorGUILayout.PropertyField(fadeInSpeed); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(5); #endregion #region Loading Page GUILayout.BeginHorizontal(_skin.customStyles[1]); GUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Loading Page Options", _skin.textField); GUILayout.FlexibleSpace(); if (GUILayout.Button(EditorGUIUtility.FindTexture("d_AnimationWrapModeMenu"), _skin.label, GUILayout.Width(50))) { cl.e_show_loading = !cl.e_show_loading; } EditorGUILayout.EndHorizontal(); if (cl.e_show_loading == true) { EditorGUILayout.PropertyField(loadingParent); EditorGUILayout.PropertyField(loadingImages, true); EditorGUILayout.PropertyField(loadingImageDisplayTime); EditorGUILayout.PropertyField(loadingPageFadeSpeed); EditorGUILayout.PropertyField(loadingTitle); EditorGUILayout.PropertyField(loadingDesc, true); EditorGUILayout.PropertyField(mainLoadingImage); EditorGUILayout.PropertyField(loadingTitleText); EditorGUILayout.PropertyField(loadingDescText); EditorGUILayout.PropertyField(loadingBar); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(5); #endregion #region UnityEvents CBEditor.SetColorToEditorStyle(_originalHolder, _originalFoldout); GUILayout.BeginHorizontal(_skin.customStyles[1]); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("UI Events", _skin.textField); GUILayout.FlexibleSpace(); if (GUILayout.Button(EditorGUIUtility.FindTexture("d_AnimationWrapModeMenu"), _skin.label, GUILayout.Width(50))) { cl.e_show_events = !cl.e_show_events; } EditorGUILayout.EndHorizontal(); if (cl.e_show_events == true) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Start")) { cl.e_events_oneTime = true; cl.e_events_loading = false; cl.e_events_naming = false; cl.e_events_errors = false; cl.e_events_room = false; cl.e_show_countdown = false; cl.e_show_misc = false; } if (GUILayout.Button("Loading")) { cl.e_events_oneTime = false; cl.e_events_loading = true; cl.e_events_naming = false; cl.e_events_errors = false; cl.e_events_room = false; cl.e_show_countdown = false; cl.e_show_misc = false; } if (GUILayout.Button("Naming")) { cl.e_events_oneTime = false; cl.e_events_loading = false; cl.e_events_naming = true; cl.e_events_errors = false; cl.e_events_room = false; cl.e_show_countdown = false; cl.e_show_misc = false; } if (GUILayout.Button("Errors")) { cl.e_events_oneTime = false; cl.e_events_loading = false; cl.e_events_naming = false; cl.e_events_errors = true; cl.e_events_room = false; cl.e_show_countdown = false; cl.e_show_misc = false; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Room")) { cl.e_events_oneTime = false; cl.e_events_loading = false; cl.e_events_naming = false; cl.e_events_errors = false; cl.e_events_room = true; cl.e_show_countdown = false; cl.e_show_misc = false; } if (GUILayout.Button("Countdown")) { cl.e_events_oneTime = false; cl.e_events_loading = false; cl.e_events_naming = false; cl.e_events_errors = false; cl.e_events_room = false; cl.e_show_countdown = true; cl.e_show_misc = false; } if (GUILayout.Button("Misc")) { cl.e_events_oneTime = false; cl.e_events_loading = false; cl.e_events_naming = false; cl.e_events_errors = false; cl.e_events_room = false; cl.e_show_countdown = false; cl.e_show_misc = true; } EditorGUILayout.EndHorizontal(); GUI.skin = _original; if (cl.e_events_oneTime == true) { EditorGUILayout.HelpBox("This event is triggered only once when this object is first enabled. Called after OnAwake functions.", MessageType.Info); EditorGUILayout.PropertyField(OnStart); } else if (cl.e_events_loading == true) { EditorGUILayout.HelpBox("Called right after a new Unity scene has successfully loaded.", MessageType.Info); EditorGUILayout.PropertyField(OnSceneLoaded); EditorGUILayout.HelpBox("Called right when loading has started for the loading bar ui.", MessageType.Info); EditorGUILayout.PropertyField(OnStartLoading); EditorGUILayout.HelpBox("Called right when the loading bar, in the loading ui, indicates that " + "the loading of the new scene has completed.", MessageType.Info); EditorGUILayout.PropertyField(OnCompleteLevelLoading); } else if (cl.e_events_naming == true) { EditorGUILayout.HelpBox("When the user tries to enter an invalid name this is called.", MessageType.Info); EditorGUILayout.PropertyField(OnNameEnterFailed); EditorGUILayout.HelpBox("When the user enter a valid name this is called.", MessageType.Info); EditorGUILayout.PropertyField(OnNameEnterSuccess); } else if (cl.e_events_errors == true) { EditorGUILayout.HelpBox("Works only if you have enabled 'reconnect' in the NetworkManager. Called" + "whenever you're attempting to reconnect to your last room after having been disconnected.", MessageType.Info); EditorGUILayout.PropertyField(OnReconnecting); EditorGUILayout.HelpBox("When any sort of network error happens this is called.", MessageType.Info); EditorGUILayout.PropertyField(OnNetworkError); } else if (cl.e_events_room == true) { EditorGUILayout.HelpBox("When you attempt to host a room and that room creation fails, this is called.", MessageType.Info); EditorGUILayout.PropertyField(OnCreateRoomFailed); EditorGUILayout.HelpBox("When you attempt to host a room and that room creation succeeds, this is called.", MessageType.Info); EditorGUILayout.PropertyField(OnCreateRoomSuccess); EditorGUILayout.HelpBox("As soon as you attempt to join a PhotonRoom from the UI, this is called.", MessageType.Info); EditorGUILayout.PropertyField(OnWaitToJoinPhotonRoomsLobby); } else if (cl.e_show_countdown == true) { EditorGUILayout.HelpBox("When you recieve a STARTCOUNTDOWN event with a start timer of true, this is called with the countdown number you recieved.", MessageType.Info); EditorGUILayout.PropertyField(OnCountdownStarted); EditorGUILayout.HelpBox("When you recieve a STARTCOUNTDOWN event with a start timer of false, this is called with the countdown number you recieved.", MessageType.Info); EditorGUILayout.PropertyField(OnCountdownStopped); } else if (cl.e_show_misc == true) { EditorGUILayout.HelpBox("When you as the host start the session this is called. (Fired if calling the SendStartSession function).", MessageType.Info); EditorGUILayout.PropertyField(OnStartSession); EditorGUILayout.HelpBox("When you recieve a ROUNDTIME event with a time to set the round to. You can decide what to do with this time.", MessageType.Info); EditorGUILayout.PropertyField(OnReceiveRoundTime); EditorGUILayout.HelpBox("When the \"ResetEverything\" function is called, this is executed.", MessageType.Info); EditorGUILayout.PropertyField(OnResetEverything); } GUI.skin = _skin; } CBEditor.SetColorToEditorStyle(_skinHolder, _skinHolder); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(5); #endregion EndInspectorGUI(typeof(UICoreLogic)); }