浏览代码

Ugh, I'm just getting really lost in this merge. Just gonna check this in reaaaal quick since this seems to be nearly correct and then make adjustments. It appears I no longer have the issue where it recurses forever and crashes, but it's not *quite* right on the Join menu refreshing logic.

/main/staging/rate_limit_data
nathaniel.buck@unity3d.com 3 年前
当前提交
a8327179
共有 7 个文件被更改,包括 64 次插入28 次删除
  1. 26
      Assets/Prefabs/UI/JoinContent.prefab
  2. 3
      Assets/Scenes/mainScene.unity
  3. 21
      Assets/Scripts/Game/GameManager.cs
  4. 12
      Assets/Scripts/Lobby/LobbyAsyncRequests.cs
  5. 1
      Assets/Scripts/UI/JoinCreateLobbyUI.cs
  6. 18
      Assets/Scripts/UI/JoinMenuUI.cs
  7. 11
      Assets/Scripts/UI/SpinnerUI.cs

26
Assets/Prefabs/UI/JoinContent.prefab


m_EditorClassIdentifier:
m_onVisibilityChange:
m_PersistentCalls:
m_Calls: []
m_LobbyButtonPrefab: {fileID: 7018369548608736188, guid: f6d35a456ba76a24587dce83bd088b7d, type: 3}
m_LobbyCodeField: {fileID: 8659642538454988273}
m_Calls:
- m_Target: {fileID: 1462126939442648229}
m_TargetAssemblyTypeName: LobbyRelaySample.UI.JoinMenuUI, LobbyRelaySample
m_MethodName: JoinMenuChangedVisibility
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_LobbyButtonPrefab: {fileID: 7018369548608736188, guid: f6d35a456ba76a24587dce83bd088b7d,
type: 3}
m_LobbyButtonParent: {fileID: 7824921818678239159}
--- !u!114 &7550446569341709048
MonoBehaviour:

propertyPath: m_Name
value: Spinner
objectReference: {fileID: 0}
- target: {fileID: 8141644855275361747, guid: c9b04951bd45e154b8096955d9bc8a0b, type: 3}
- target: {fileID: 7859013680193933450, guid: c9b04951bd45e154b8096955d9bc8a0b,
type: 3}
propertyPath: m_text
value: 'Error: Check the console log.'
objectReference: {fileID: 0}
- target: {fileID: 8141644855275361747, guid: c9b04951bd45e154b8096955d9bc8a0b,
type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}

3
Assets/Scenes/mainScene.unity


propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedComponents:
- {fileID: 4928485776352161055, guid: f1d618bdc6f1813449d428126e640aa5, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: f1d618bdc6f1813449d428126e640aa5, type: 3}
--- !u!114 &2637199315837045694 stripped
MonoBehaviour:

21
Assets/Scripts/Game/GameManager.cs


{
var createLobbyData = (LocalLobby)msg;
LobbyAsyncRequests.Instance.CreateLobbyAsync(createLobbyData.LobbyName, createLobbyData.MaxPlayerCount, createLobbyData.Private, m_localUser, (r) =>
{ lobby.ToLocalLobby.Convert(r, m_localLobby);
OnCreatedLobby();
},
OnFailedJoin);
{ lobby.ToLocalLobby.Convert(r, m_localLobby);
OnCreatedLobby();
},
OnFailedJoin);
{ lobby.ToLocalLobby.Convert(r, m_localLobby);
OnJoinedLobby();
},
OnFailedJoin);
{ lobby.ToLocalLobby.Convert(r, m_localLobby);
OnJoinedLobby();
},
OnFailedJoin);
if (LobbyAsyncRequests.Instance.GetRateLimit(LobbyAsyncRequests.RequestType.Query).IsInCooldown)
{
//Debug.LogError("Cooldown!");
//return;
}
m_lobbyServiceData.State = LobbyQueryState.Fetching;
LobbyAsyncRequests.Instance.RetrieveLobbyListAsync(
qr => {

12
Assets/Scripts/Lobby/LobbyAsyncRequests.cs


/// Used for getting the list of all active lobbies, without needing full info for each.
/// </summary>
/// <param name="onListRetrieved">If called with null, retrieval was unsuccessful. Else, this will be given a list of contents to display, as pairs of a lobby code and a display string for that lobby.</param>
public void RetrieveLobbyListAsync(Action<QueryResponse> onListRetrieved, Action<Response<QueryResponse>> onError = null, LobbyColor limitToColor = LobbyColor.None)
/// <param name="isRecursive">Just as a backup to effectively batch together multiple retrievals into one if they arrive in rapid succession.</param>
public void RetrieveLobbyListAsync(Action<QueryResponse> onListRetrieved, Action<Response<QueryResponse>> onError = null, LobbyColor limitToColor = LobbyColor.None, bool isRecursive = false)
onListRetrieved?.Invoke(null);
m_pendingOperations.Enqueue(() => { RetrieveLobbyListAsync(onListRetrieved, onError, limitToColor); }); // With that assumption, retry the refresh after the limit, as though entering the join menu from the main menu.
if (!isRecursive)
{
m_pendingOperations.Enqueue(() => { RetrieveLobbyListAsync(onListRetrieved, onError, limitToColor, true); }); // With that assumption, retry the refresh after the limit, as though entering the join menu from the main menu.
UnityEngine.Debug.LogError("Enqueuing...");
}
else
UnityEngine.Debug.LogError("Blocking recursive call");
return;
}

1
Assets/Scripts/UI/JoinCreateLobbyUI.cs


if (observed.State == GameState.JoinMenu)
{
Show();
Locator.Get.Messenger.OnReceiveMessage(MessageType.QueryLobbies, null);
}
else
{

18
Assets/Scripts/UI/JoinMenuUI.cs


using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

{
[SerializeField]
LobbyButtonUI m_LobbyButtonPrefab;
[SerializeField]
TMP_InputField m_LobbyCodeField;
[SerializeField]
RectTransform m_LobbyButtonParent;

RemoveLobbyButton(m_LocalLobby[key]);
}
bool CanDisplay(LocalLobby lobby)
public void JoinMenuChangedVisibility(bool show)
{
if (show)
OnRefresh();
}
private bool CanDisplay(LocalLobby lobby)
{
return lobby.Data.State == LobbyState.Lobby && !lobby.Private;
}

/// </summary>
void AddNewLobbyButton(string lobbyCode, LocalLobby lobby)
private void AddNewLobbyButton(string lobbyCode, LocalLobby lobby)
{
var lobbyButtonInstance = Instantiate(m_LobbyButtonPrefab, m_LobbyButtonParent);
lobbyButtonInstance.GetComponent<LocalLobbyObserver>().BeginObserving(lobby);

m_LocalLobby.Add(lobbyCode, lobby);
}
void UpdateLobbyButton(string lobbyCode, LocalLobby lobby)
private void UpdateLobbyButton(string lobbyCode, LocalLobby lobby)
void RemoveLobbyButton(LocalLobby lobby)
private void RemoveLobbyButton(LocalLobby lobby)
{
var lobbyID = lobby.LobbyID;
var lobbyButton = m_LobbyButtons[lobbyID];

11
Assets/Scripts/UI/SpinnerUI.cs


errorTextVisibility.Show();
var errorString = new StringBuilder();
errorString.Append("Error");
var codeString = ": " + observed.lastErrorCode;
if (observed.lastErrorCode < 1)
codeString = ".";
errorString.Append(": ");
if (observed.lastErrorCode > 0)
{
errorString.Append(observed.lastErrorCode);
errorString.Append(", ");
}
errorString.Append("Check Unity Console Log for Details.");
errorString.Append(codeString);
errorText.SetText(errorString.ToString());
}
else if (observed.State == LobbyQueryState.Fetched)

正在加载...
取消
保存