浏览代码

Merged in latest from Staging

/main/staging/Open_beta_Update
当前提交
140c3348
共有 21 个文件被更改,包括 1312 次插入61 次删除
  1. 2
      Assets/Prefabs/UI/JoinCreateCanvas.prefab
  2. 2
      Assets/Prefabs/UI/RenamePopup.prefab
  3. 130
      Assets/Scenes/mainScene.unity
  4. 59
      Assets/Scripts/Game/GameManager.cs
  5. 45
      Assets/Scripts/Infrastructure/LogHandler.cs
  6. 1001
      Assets/Prefabs/UI/PopUpUI.prefab
  7. 7
      Assets/Prefabs/UI/PopUpUI.prefab.meta
  8. 32
      Assets/Scripts/Infrastructure/LogHandlerSettings.cs
  9. 11
      Assets/Scripts/Infrastructure/LogHandlerSettings.cs.meta
  10. 25
      Assets/Scripts/UI/PopUpUI.cs
  11. 11
      Assets/Scripts/UI/PopUpUI.cs.meta
  12. 8
      Assets/StreamingAssets.meta
  13. 3
      Assets/TextMesh Pro/Fonts.meta.private.0
  14. 7
      Assets/TextMesh Pro/Fonts.meta.private.0.meta
  15. 3
      Assets/TextMesh Pro/Resources.meta.private.0
  16. 7
      Assets/TextMesh Pro/Resources.meta.private.0.meta
  17. 3
      Assets/TextMesh Pro/Shaders.meta.private.0
  18. 7
      Assets/TextMesh Pro/Shaders.meta.private.0.meta
  19. 3
      Assets/TextMesh Pro/Sprites.meta.private.0
  20. 7
      Assets/TextMesh Pro/Sprites.meta.private.0.meta

2
Assets/Prefabs/UI/JoinCreateCanvas.prefab


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

2
Assets/Prefabs/UI/RenamePopup.prefab


m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 1
m_PresetInfoIsWorld: 0
--- !u!225 &7663265756039998349
CanvasGroup:
m_ObjectHideFlags: 0

130
Assets/Scenes/mainScene.unity


m_Script: {fileID: 11500000, guid: 5b3b588e7ae40ec4ca35fdb9404513ab, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1095306254
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1095306259}
- component: {fileID: 1095306258}
- component: {fileID: 1095306257}
- component: {fileID: 1095306256}
- component: {fileID: 1095306255}
m_Layer: 5
m_Name: LogManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1095306255
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1095306254}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 089231d71bcfb8d479b4f8b778b1026f, type: 3}
m_Name:
m_EditorClassIdentifier:
m_editorLogVerbosity: 0
m_popUpPrefab: {fileID: 2974111728825125460, guid: 79d6084439b78bb4eaf5232cb953fd87, type: 3}
m_reaction:
m_logMessageCallback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1095306255}
m_TargetAssemblyTypeName: LobbyRelaySample.LogHandlerSettings, LobbyRelaySample
m_MethodName: SpawnErrorPopup
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
--- !u!114 &1095306256
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1095306254}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &1095306257
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1095306254}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 1
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!223 &1095306258
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1095306254}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 25
m_SortingLayerID: 0
m_SortingOrder: 1
m_TargetDisplay: 0
--- !u!224 &1095306259
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1095306254}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &1217229506 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 354886978664675623, guid: f1d618bdc6f1813449d428126e640aa5, type: 3}

59
Assets/Scripts/Game/GameManager.cs


/// </summary>
public class GameManager : MonoBehaviour, IReceiveMessages
{
[SerializeField]
[Tooltip("Only logs of this level or higher will appear in the console.")]
private LogMode m_logMode = LogMode.Critical;
[SerializeField]
private List<LocalGameStateObserver> m_GameStateObservers = new List<LocalGameStateObserver>();
[SerializeField]

[SerializeField]
private List<LobbyServiceDataObserver> m_LobbyServiceObservers = new List<LobbyServiceDataObserver>();
#endregion
private LocalGameState m_localGameState = new LocalGameState();

private bool m_coolingDown;
/// <summary>Rather than a setter, this is usable in-editor. It won't accept an enum, however.</summary>
public void SetLobbyColorFilter(int color) { m_lobbyColorFilter = (LobbyColor)color; }
public void SetLobbyColorFilter(int color){ m_lobbyColorFilter = (LobbyColor)color; }
private void Awake()
{
// Do some arbitrary operations to instantiate singletons.

LogHandler.Get().mode = m_logMode;
Locator.Get.Provide(new Auth.Identity(OnAuthSignIn));
Application.wantsToQuit += OnWantToQuit;
}

foreach (var userObs in m_LocalUserObservers)
userObs.BeginObserving(m_localUser);
}
#endregion
/// <summary>

{
if (type == MessageType.RenameRequest)
{ m_localUser.DisplayName = (string)msg;
{
m_localUser.DisplayName = (string)msg;
}
else if (type == MessageType.CreateLobbyRequest)
{

var createLobbyData = (LocalLobby)msg;
LobbyAsyncRequests.Instance.CreateLobbyAsync(createLobbyData.LobbyName, createLobbyData.MaxPlayerCount, createLobbyData.Private, m_localUser, (r) =>
{ lobby.ToLocalLobby.Convert(r, m_localLobby);
{
lobby.ToLocalLobby.Convert(r, m_localLobby);
OnCreatedLobby();
},
OnFailedJoin);

LocalLobby.LobbyData lobbyInfo = (LocalLobby.LobbyData)msg;
LobbyAsyncRequests.Instance.JoinLobbyAsync(lobbyInfo.LobbyID, lobbyInfo.LobbyCode, m_localUser, (r) =>
{ lobby.ToLocalLobby.Convert(r, m_localLobby);
{
lobby.ToLocalLobby.Convert(r, m_localLobby);
OnJoinedLobby();
},
OnFailedJoin);

return;
m_lobbyServiceData.State = LobbyQueryState.Fetching;
LobbyAsyncRequests.Instance.RetrieveLobbyListAsync(
qr => {
qr =>
{
er => {
er =>
{
long errorLong = 0;
if (er != null)
errorLong = er.Status;

}
else if (type == MessageType.ChangeGameState)
{ SetGameState((GameState)msg);
{
SetGameState((GameState)msg);
{ EmoteType emote = (EmoteType)msg;
{
EmoteType emote = (EmoteType)msg;
{ m_localUser.UserStatus = (UserStatus)msg;
{
m_localUser.UserStatus = (UserStatus)msg;
{ BeginCountDown();
{
BeginCountDown();
{ m_localLobby.State = LobbyState.Lobby;
{
m_localLobby.State = LobbyState.Lobby;
{ m_localUser.UserStatus = UserStatus.InGame;
{
m_localUser.UserStatus = UserStatus.InGame;
{ m_localLobby.State = LobbyState.Lobby;
{
m_localLobby.State = LobbyState.Lobby;
m_localLobby.CountDownTime = 0;
SetUserLobbyState();
}

LobbyAsyncRequests.Instance.EndTracking();
if (m_relaySetup != null)
{ Component.Destroy(m_relaySetup);
{
Component.Destroy(m_relaySetup);
{ Component.Destroy(m_relayClient);
{
Component.Destroy(m_relayClient);
m_relayClient = null;
}
}

StartCoroutine(RetryRelayConnection());
return;
}
m_relayClient = client;
OnReceiveMessage(MessageType.LobbyUserStatus, UserStatus.Lobby);
}

yield break;
m_localLobby.CountDownTime -= Time.deltaTime;
}
if (m_relayClient is RelayUtpHost)
(m_relayClient as RelayUtpHost).SendInGameState();
}

}
#region Teardown
/// <summary>
/// In builds, if we are in a lobby and try to send a Leave request on application quit, it won't go through if we're quitting on the same frame.
/// So, we need to delay just briefly to let the request happen (though we don't need to wait for the result).

m_localLobby = null;
}
}
#endregion
}
}

45
Assets/Scripts/Infrastructure/LogHandler.cs


using System;
using System.Collections.Generic;
using RelayException = Unity.Services.Relay.Http.HttpException;
using LobbyException = Unity.Services.Lobbies.Http.HttpException;
using UnityEngine.Events;
using Object = UnityEngine.Object;
namespace LobbyRelaySample

static LogHandler s_instance;
ILogHandler m_DefaultLogHandler = Debug.unityLogger.logHandler; // Store the default logger that prints to console.
ErrorReaction m_reaction;
public static LogHandler Get()
{

return s_instance;
}
public void SetLogReactions(ErrorReaction reactions)
{
m_reaction = reactions;
}
public void LogFormat(LogType logType, Object context, string format, params object[] args)
{
if (logType == LogType.Exception) // Exceptions are captured by LogException and should always be logged.

public void LogException(Exception exception, Object context)
{
LogReaction(exception);
}
private void LogReaction(Exception exception)
{
m_reaction?.Filter(exception);
}
}
/// <summary>
/// The idea here is to
/// </summary>
[Serializable]
public class ErrorReaction
{
public UnityEvent<string> m_logMessageCallback;
public void Filter(Exception exception)
{
string message = "";
var rawExceptionMessage = "";
//We want to Ensure the most relevant error message is on top
if (exception.InnerException != null)
rawExceptionMessage = exception.InnerException.ToString();
else
rawExceptionMessage = exception.ToString();
var firstLineIndex = rawExceptionMessage.IndexOf("\n");
var firstRelayString = rawExceptionMessage.Substring(0, firstLineIndex);
message = firstRelayString;
if (string.IsNullOrEmpty(message))
return;
m_logMessageCallback?.Invoke(message);
}
}
}

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

7
Assets/Prefabs/UI/PopUpUI.prefab.meta


fileFormatVersion: 2
guid: 79d6084439b78bb4eaf5232cb953fd87
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

32
Assets/Scripts/Infrastructure/LogHandlerSettings.cs


using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
namespace LobbyRelaySample
{
public class LogHandlerSettings : MonoBehaviour
{
[SerializeField]
[Tooltip("Only logs of this level or higher will appear in the console.")]
private LogMode m_editorLogVerbosity = LogMode.Critical;
[SerializeField]
private PopUpUI m_popUpPrefab;
[SerializeField]
private ErrorReaction m_errorReaction;
void Awake()
{
LogHandler.Get().mode = m_editorLogVerbosity;
LogHandler.Get().SetLogReactions(m_errorReaction);
}
public void SpawnErrorPopup(string errorMessage)
{
var popupInstance = Instantiate(m_popUpPrefab, transform);
popupInstance.ShowPopup(errorMessage, Color.red);
}
}
}

11
Assets/Scripts/Infrastructure/LogHandlerSettings.cs.meta


fileFormatVersion: 2
guid: 089231d71bcfb8d479b4f8b778b1026f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

25
Assets/Scripts/UI/PopUpUI.cs


using LobbyRelaySample.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UI;
namespace LobbyRelaySample
{
public class PopUpUI : MonoBehaviour
{
[SerializeField]
TMP_InputField m_popupText;
public void ShowPopup(string newText, Color textColor = default)
{
m_popupText.SetTextWithoutNotify(newText);
m_popupText.textComponent.color = textColor;
}
public void Delete()
{
Destroy(gameObject);
}
}
}

11
Assets/Scripts/UI/PopUpUI.cs.meta


fileFormatVersion: 2
guid: e5f1bc94a7a7b5249a02001abc3096ef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/StreamingAssets.meta


fileFormatVersion: 2
guid: 856fc4d990badc74a96656143dedb8e9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
Assets/TextMesh Pro/Fonts.meta.private.0


fileFormatVersion: 2
guid: 077401255185464e9b7bb889ed8280e7
timeCreated: 1620062128

7
Assets/TextMesh Pro/Fonts.meta.private.0.meta


fileFormatVersion: 2
guid: 8562a96ab261c68478bc71961f545c2f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
Assets/TextMesh Pro/Resources.meta.private.0


fileFormatVersion: 2
guid: 017af257aa3d4ade9644309997be39de
timeCreated: 1620062128

7
Assets/TextMesh Pro/Resources.meta.private.0.meta


fileFormatVersion: 2
guid: 4a3fdb949a9746940af94101f709f04d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
Assets/TextMesh Pro/Shaders.meta.private.0


fileFormatVersion: 2
guid: 5915fb622e8b4e7a9815228d467e7167
timeCreated: 1620062115

7
Assets/TextMesh Pro/Shaders.meta.private.0.meta


fileFormatVersion: 2
guid: d6a8cd862f117884db82bd4017125774
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
Assets/TextMesh Pro/Sprites.meta.private.0


fileFormatVersion: 2
guid: 347d77b9f27146049993e70fd2c3ca78
timeCreated: 1620062128

7
Assets/TextMesh Pro/Sprites.meta.private.0.meta


fileFormatVersion: 2
guid: e58181612d0ba9d4da4aeafea973c347
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存