浏览代码

Merge from staging.

/main/staging/ngo_more_cleanup
nathaniel.buck@unity3d.com 3 年前
当前提交
c0e1472f
共有 16 个文件被更改,包括 1163 次插入1084 次删除
  1. 98
      Assets/Prefabs/UI/JoinCreateCanvas.prefab
  2. 20
      Assets/Prefabs/UI/RenamePopup.prefab
  3. 8
      Assets/Scripts/Infrastructure/AsyncRequest.cs
  4. 4
      Assets/Scripts/Lobby/LobbyAPIInterface.cs
  5. 20
      Assets/Scripts/Lobby/LobbyAsyncRequests.cs
  6. 4
      Assets/Scripts/Tests/PlayMode/LobbyRoundtripTests.cs
  7. 18
      Assets/Scripts/UI/CreateMenuUI.cs
  8. 36
      Assets/Scripts/UI/JoinCreateLobbyUI.cs
  9. 19
      Assets/Scripts/UI/JoinMenuUI.cs
  10. 2
      Assets/Scripts/UI/UserNameUI.cs
  11. 16
      Assets/Scripts/Vivox/VivoxUserHandler.cs
  12. 1001
      Assets/Prefabs/UI/UserInteractionPanel.prefab
  13. 1001
      Assets/Prefabs/UI/PlayerInteractionPanel.prefab
  14. 0
      /Assets/Prefabs/UI/UserInteractionPanel.prefab.meta
  15. 0
      /Assets/Scripts/UI/UserNameUI.cs.meta
  16. 0
      /Assets/Scripts/UI/UserNameUI.cs

98
Assets/Prefabs/UI/JoinCreateCanvas.prefab


m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1034500561768382320}
m_TargetAssemblyTypeName: LobbyRooms.UI.UIPanelBase, LobbyRooms
m_MethodName: Show
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 1
m_CallState: 2
- m_Target: {fileID: 5643181761482593758}
m_TargetAssemblyTypeName: LobbyRooms.UI.UIPanelBase, LobbyRooms
m_MethodName: Hide
- m_Target: {fileID: 4578721078997909056}
m_TargetAssemblyTypeName: LobbyRelaySample.UI.JoinCreateLobbyUI, LobbyRelaySample
m_MethodName: SetCreateTab
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}

m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 29.1
m_fontSize: 40
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 1

m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1034500561768382320}
m_TargetAssemblyTypeName: LobbyRooms.UI.UIPanelBase, LobbyRooms
m_MethodName: Hide
- m_Target: {fileID: 4578721078997909056}
m_TargetAssemblyTypeName: LobbyRelaySample.UI.JoinCreateLobbyUI, LobbyRelaySample
m_MethodName: SetJoinTab
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}

m_StringArgument:
m_BoolArgument: 1
m_CallState: 2
- m_Target: {fileID: 5643181761482593758}
m_TargetAssemblyTypeName: LobbyRooms.UI.UIPanelBase, LobbyRooms
m_MethodName: Show
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 1
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &201442509941519423
MonoBehaviour:

m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 29.1
m_fontSize: 40
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 1

- component: {fileID: 5836614391142406753}
- component: {fileID: 5836614391142406752}
- component: {fileID: 4578721078997909056}
- component: {fileID: 6102798993520257211}
- component: {fileID: 6102798993520257211}
m_Layer: 5
m_Name: JoinCreateCanvas
m_TagString: Untagged

m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 1
m_PresetInfoIsWorld: 0
--- !u!114 &5836614391142406752
MonoBehaviour:
m_ObjectHideFlags: 0

m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!225 &6102798993520257211
CanvasGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5836614391142406755}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0
m_CurrentTab: 0
--- !u!114 &1512606419251751951
MonoBehaviour:
m_ObjectHideFlags: 0

m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!225 &6102798993520257211
CanvasGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5836614391142406755}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0
--- !u!1 &7348548600648247480
GameObject:
m_ObjectHideFlags: 0

value: 0
objectReference: {fileID: 0}
- target: {fileID: 6473743066396215718, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_JoinCreateLobbyUI
value:
objectReference: {fileID: 4578721078997909056}
- target: {fileID: 6473743066396215718, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_onVisibilityChange.m_PersistentCalls.m_Calls.Array.size
value: 1
objectReference: {fileID: 0}

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7501121940441885946, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_fontSize
value: 21.3
objectReference: {fileID: 0}
- target: {fileID: 8319084566339912016, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
propertyPath: m_AnchorMax.y
value: 0

m_CorrespondingSourceObject: {fileID: 7255335463425698201, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
m_PrefabInstance: {fileID: 6308438907748136662}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1034500561768382320 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 6473743066396215718, guid: 328b912adedf1bc41a44f60a12723cc0, type: 3}
m_PrefabInstance: {fileID: 6308438907748136662}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8bea15db614f57749bb2bac5ae7811fa, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &6492536299820417403
PrefabInstance:
m_ObjectHideFlags: 0

propertyPath: m_JoinCodeField
value:
objectReference: {fileID: 2465479314273514634}
- target: {fileID: 1462126939442648229, guid: c308ffc2a02e5ab4bbe70a8b2e8108c6, type: 3}
propertyPath: m_JoinCreateLobbyUI
value:
objectReference: {fileID: 4578721078997909056}
- target: {fileID: 1462126939442648229, guid: c308ffc2a02e5ab4bbe70a8b2e8108c6, type: 3}
propertyPath: m_onVisibilityChange.m_PersistentCalls.m_Calls.Array.size
value: 2
objectReference: {fileID: 0}
- target: {fileID: 1462126939442648229, guid: c308ffc2a02e5ab4bbe70a8b2e8108c6, type: 3}
propertyPath: m_onVisibilityChange.m_PersistentCalls.m_Calls.Array.data[1].m_Mode
value: 0

20
Assets/Prefabs/UI/RenamePopup.prefab


- component: {fileID: 7751582925205826323}
- component: {fileID: 8901675253147492441}
m_Layer: 5
m_Name: Panel
m_Name: icon_highlights
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4299827590990313863}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}

m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: -10}
m_SizeDelta: {x: -200, y: 50}
m_Pivot: {x: 0.5, y: 1}
--- !u!222 &8624457953407905708

- component: {fileID: 8314980018121597183}
- component: {fileID: 7056713423232892002}
m_Layer: 5
m_Name: Panel
m_Name: icon_back
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4299827590990313863}
m_RootOrder: 2
m_RootOrder: 1
m_SizeDelta: {x: -10, y: -4}
m_SizeDelta: {x: -4, y: -4}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8314980018121597183
CanvasRenderer:

m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 4354914e98ed5184596c36700cb95cd6, type: 3}
m_Sprite: {fileID: 21300000, guid: 36961dea3482e5842938e6c4d5d8570a, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 557953118367534400}
- {fileID: 3886665443646860209}
- {fileID: 3886665443646860209}
m_Father: {fileID: 1113109783147550039}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

m_Name:
m_EditorClassIdentifier:
m_IgnoreLayout: 0
m_MinWidth: 50
m_MinWidth: 40
m_PreferredWidth: 50
m_PreferredWidth: 40
m_PreferredHeight: -1
m_FlexibleWidth: -1
m_FlexibleHeight: -1

8
Assets/Scripts/Infrastructure/AsyncRequest.cs


catch (Exception e)
{
ParseServiceException(e);
Exception eFull = new Exception($"Call stack before async call:\n{currentTrace}\n", e); // TODO: Are we still missing Relay exceptions after the update?
throw eFull;
UnityEngine.Debug.LogError($"AsyncRequest threw an exception. Call stack before async call:\n{currentTrace}\n"); // Note that we log here instead of creating a new Exception in case of a change in calling context during the async call. E.g. Relay has its own exception handling that would intercept this call stack.
throw;
}
finally
{ onComplete?.Invoke();

catch (Exception e)
{
ParseServiceException(e);
Exception eFull = new Exception($"Call stack before async call:\n{currentTrace}\n", e);
throw eFull;
UnityEngine.Debug.LogError($"AsyncRequest threw an exception. Call stack before async call:\n{currentTrace}\n");
throw;
}
finally
{ onComplete?.Invoke(result);

4
Assets/Scripts/Lobby/LobbyAPIInterface.cs


AsyncRequestLobby.Instance.DoRequest(task, onComplete);
}
public static void UpdateLobbyAsync(string lobbyId, Dictionary<string, DataObject> data, Action<Lobby> onComplete)
public static void UpdateLobbyAsync(string lobbyId, Dictionary<string, DataObject> data, bool shouldLock, Action<Lobby> onComplete)
UpdateLobbyOptions updateOptions = new UpdateLobbyOptions { Data = data };
UpdateLobbyOptions updateOptions = new UpdateLobbyOptions { Data = data , IsLocked = shouldLock};
var task = Lobbies.Instance.UpdateLobbyAsync(lobbyId, updateOptions);
AsyncRequestLobby.Instance.DoRequest(task, onComplete);
}

20
Assets/Scripts/Lobby/LobbyAsyncRequests.cs


namespace LobbyRelaySample
{
/// <summary>
/// An abstraction layer between the direct calls into the Lobby API and the outcomes you actually want. E.g. you can request to get a readable list of
/// An abstraction layer between the direct calls into the Lobby API and the outcomes you actually want. E.g. you can request to get a readable list of
/// current lobbies and not need to make the query call directly.
/// </summary>
public class LobbyAsyncRequests

Lobby lobby = m_lastKnownLobby;
Dictionary<string, DataObject> dataCurr = lobby.Data ?? new Dictionary<string, DataObject>();
var shouldLock = false;
foreach (var dataNew in data)
{
// Special case: We want to be able to filter on our color data, so we need to supply an arbitrary index to retrieve later. Uses N# for numerics, instead of S# for strings.

dataCurr[dataNew.Key] = dataObj;
else
dataCurr.Add(dataNew.Key, dataObj);
//Special Use: Get the state of the Local lobby so we can lock it from appearing in queries if it's not in the "Lobby" State
if (dataNew.Key == "State")
{
Enum.TryParse(dataNew.Value, out LobbyState lobbyState);
shouldLock = lobbyState != LobbyState.Lobby;
}
LobbyAPIInterface.UpdateLobbyAsync(lobby.Id, dataCurr, (result) => {
LobbyAPIInterface.UpdateLobbyAsync(lobby.Id, dataCurr, shouldLock, (result) =>
{
if (result != null)
m_lastKnownLobby = result;
onComplete?.Invoke();

m_rateLimitQuery.EnqueuePendingOperation(caller);
return false;
}
Lobby lobby = m_lastKnownLobby;
if (lobby == null)
{

}
}
public override void CopyObserved(RateLimitCooldown oldObserved){/* This behavior isn't needed; we're just here for the OnChanged event management. */}
public override void CopyObserved(RateLimitCooldown oldObserved)
{
/* This behavior isn't needed; we're just here for the OnChanged event management. */
}
}
}
}

4
Assets/Scripts/Tests/PlayMode/LobbyRoundtripTests.cs


[UnityTest]
public IEnumerator OnCompletesOnFailure()
{
LogAssert.Expect(LogType.Exception, new Regex(".*400 Bad Request.*"));
if (!m_didSigninComplete)
yield return new WaitForSeconds(3);
if (!m_didSigninComplete)

LogAssert.ignoreFailingMessages = true; // Multiple errors will appears for the exception.
LobbyAPIInterface.CreateLobbyAsync("ThisStringIsInvalidHere", "lobby name", 123, false, m_mockUserData, (r) => { didComplete = (r == null); });
float timeout = 5;
while (didComplete == null && timeout > 0)

LogAssert.ignoreFailingMessages = false;
Assert.Greater(timeout, 0, "Timeout check");
Assert.NotNull(didComplete, "Should have called onComplete, even if the async request failed.");
Assert.True(didComplete, "The returned object will be null, so expect to need to handle it.");

18
Assets/Scripts/UI/CreateMenuUI.cs


/// </summary>
public class CreateMenuUI : UIPanelBase
{
private LocalLobby.LobbyData m_ServerRequestData = new LocalLobby.LobbyData{ LobbyName = "New Lobby", MaxPlayerCount = 4 };
public JoinCreateLobbyUI m_JoinCreateLobbyUI;
private LocalLobby.LobbyData m_ServerRequestData = new LocalLobby.LobbyData { LobbyName = "New Lobby", MaxPlayerCount = 4 };
Hide();
m_JoinCreateLobbyUI.m_OnTabChanged.AddListener(OnTabChanged);
void OnTabChanged(JoinCreateTabs tabState)
{
if (tabState == JoinCreateTabs.Create)
{
Show();
}
else
{
Hide();
}
}
public void SetServerName(string serverName)
{
m_ServerRequestData.LobbyName = serverName;

36
Assets/Scripts/UI/JoinCreateLobbyUI.cs


using System;
using UnityEngine;
using UnityEngine.Events;
public enum JoinCreateTabs
{
Join,
Create
}
public UnityEvent<JoinCreateTabs> m_OnTabChanged;
[SerializeField] //Serialized for Visisbility in Editor
JoinCreateTabs m_CurrentTab = JoinCreateTabs.Join;
public JoinCreateTabs CurrentTab
{
get => m_CurrentTab;
set
{
m_CurrentTab = value;
m_OnTabChanged?.Invoke(m_CurrentTab);
}
}
public void SetJoinTab()
{
CurrentTab = JoinCreateTabs.Join;
}
public void SetCreateTab()
{
CurrentTab = JoinCreateTabs.Create;
}
m_OnTabChanged?.Invoke(m_CurrentTab);
Show(false);
}
else

19
Assets/Scripts/UI/JoinMenuUI.cs


[SerializeField]
TMP_InputField m_JoinCodeField;
public JoinCreateLobbyUI m_JoinCreateLobbyUI;
/// <summary>
/// Key: Lobby ID, Value Lobby UI
/// </summary>

/// <summary>Contains some amount of information used to join an existing lobby.</summary>
LocalLobby.LobbyData m_LocalLobbySelected;
public override void Start()
{
base.Start();
m_JoinCreateLobbyUI.m_OnTabChanged.AddListener(OnTabChanged);
}
void OnTabChanged(JoinCreateTabs tabState)
{
if (tabState == JoinCreateTabs.Join)
{
Show();
}
else
{
Hide();
}
}
public void LobbyButtonSelected(LocalLobby lobby)
{

2
Assets/Scripts/UI/UserNameUI.cs


/// <summary>
/// Displays the player's name.
/// </summary>
public class PlayerNameUI : ObserverPanel<LobbyUser>
public class UserNameUI : ObserverPanel<LobbyUser>
{
[SerializeField]
TMP_Text m_TextField;

16
Assets/Scripts/Vivox/VivoxUserHandler.cs


public void OnChannelJoined(IChannelSession channelSession) // Called after a connection is established, which begins once a lobby is joined.
{
//Check if we are muted or not
m_channelSession = channelSession;
m_channelSession.Participants.AfterKeyAdded += OnParticipantAdded;
m_channelSession.Participants.BeforeKeyRemoved += BeforeParticipantRemoved;

if (isThisUser)
{ m_vivoxId = keyEventArg.Key; // Since we couldn't construct the Vivox ID earlier, retrieve it here.
m_lobbyUserVolumeUI.IsLocalPlayer = participant.IsSelf;
m_lobbyUserVolumeUI.EnableVoice(true);
if(!participant.IsMutedForAll)
m_lobbyUserVolumeUI.EnableVoice(false);//Should check if user is muted or not.
else
m_lobbyUserVolumeUI.DisableVoice(false);
}
else
{
if(!participant.LocalMute)
m_lobbyUserVolumeUI.EnableVoice(false);//Should check if user is muted or not.
else
m_lobbyUserVolumeUI.DisableVoice(false);
private void BeforeParticipantRemoved(object sender, KeyEventArg<string> keyEventArg)
{
var source = (VivoxUnity.IReadOnlyDictionary<string, IParticipant>)sender;

1001
Assets/Prefabs/UI/UserInteractionPanel.prefab
文件差异内容过多而无法显示
查看文件

1001
Assets/Prefabs/UI/PlayerInteractionPanel.prefab
文件差异内容过多而无法显示
查看文件

/Assets/Prefabs/UI/PlayerInteractionPanel.prefab.meta → /Assets/Prefabs/UI/UserInteractionPanel.prefab.meta

/Assets/Scripts/UI/PlayerNameUI.cs.meta → /Assets/Scripts/UI/UserNameUI.cs.meta

/Assets/Scripts/UI/PlayerNameUI.cs → /Assets/Scripts/UI/UserNameUI.cs

正在加载...
取消
保存