浏览代码

fix: adjust the timing of Multiverse readiness.

/main
当前提交
b97b7e50
共有 9 个文件被更改,包括 303 次插入1199 次删除
  1. 8
      Assets/Scripts/Gameplay/Lobby/MultiverseRoomAPI.cs
  2. 19
      Assets/Scripts/Gameplay/Lobby/MultiverseSDK.cs
  3. 10
      Assets/Scripts/Gameplay/Netcode/NetcodeBootstrap.cs
  4. 32
      ProjectSettings/EntitiesClientSettings.asset
  5. 36
      ProjectSettings/NetCodeClientSettings.asset
  6. 38
      ProjectSettings/NetCodeServerSettings.asset
  7. 1001
      ProjectSettings/ProjectSettings.asset
  8. 326
      ProjectSettings/QualitySettings.asset
  9. 32
      ProjectSettings/ShaderGraphSettings.asset

8
Assets/Scripts/Gameplay/Lobby/MultiverseRoomAPI.cs


private readonly string baseUrl = "https://s.unity.cn/service/rooms"; // room api url
// Please fill in the required fields
private readonly string appId = ""; // app id
private readonly string appSecret = ""; // app secret
private readonly string gameRegionId = ""; // game region id
private readonly string multiverseProfileId = ""; // multiverse profile id
private readonly string appId = "eb6feb70-2872-416c-846a-d850f64f45d5"; // app id
private readonly string appSecret = "c17e41a492f748f4a1e2fdc4c927f6e8"; // app secret
private readonly string gameRegionId = "7bba5ff1-b4a3-498c-9c0b-24cad73cff54"; // game region id
private readonly string multiverseProfileId = "8ea5c9bc-a214-47cf-98c4-4ad550e29ee7"; // multiverse profile id
public string IP { get; private set; } = "";
public ushort Port { get; private set; } = 0;

19
Assets/Scripts/Gameplay/Lobby/MultiverseSDK.cs


using System.Threading.Tasks;
using Unity.Cn.Multiverse;
using UnityEngine;
using UnityEngine.TextCore.Text;
namespace Unity.MegaCity.Gameplay
{

Application.Quit();
return;
}
Debug.Log("Multiverse is created");
}
await Task.Delay(3000); // wait 3 seconds for the server to be ready
public async void ReadyMultiverse()
{
// wait until multiverse created
while(m_Multiverse == null)
{
Debug.Log("m_Multiverse is null");
await Task.Delay(100);
}
// mark server as ready
bool ok = await m_Multiverse.Ready();
if (!ok)
{

var gs = await m_Multiverse.GameServer();
var gsAddress = gs.Status.Address;
var gsPort = gs.Status.Ports[0].Port;
Debug.Log("--------------------\n" +
"Multiverse Game Server\n" +
$"Address: {gsAddress}" + "\n" +
$"Port: {gsPort}" + "\n" +
"--------------------");
Debug.Log($"Multiverse is Ready, IP:{gsAddress}, Port:{gsPort}");
}
// Auto shutdown the multiverse in TTL seconds if there is no player connected.

10
Assets/Scripts/Gameplay/Netcode/NetcodeBootstrap.cs


public class NetCodeBootstrap : ClientServerBootstrap
{
public static NetworkEndpoint MegaCityServerIp => NetworkEndpoint.Parse("128.14.159.58", 7979);
public MultiverseSdk m_Multiverse;
/// <summary>
/// Limitation imposed to ensure UTP send/receiveQueueSize's are set appropriately.

private NativeList<float3> m_UsedPositions;
private Mathematics.Random m_Random;
private bool m_IsInitialized;
m_IsInitialized = false;
state.RequireForUpdate<PlayerSpawner>();
state.RequireForUpdate<SpawnPointElement>();
m_UsedPositions = new NativeList<float3>(Allocator.Persistent);

public void OnUpdate(ref SystemState state)
{
#if UNITY_SERVER && !UNITY_EDITOR
if(!m_IsInitialized)
{
m_IsInitialized = true;
MultiverseSDKWrapper.Instance.ReadyMultiverse();
}
#endif
var spawnBuffer = GetSingletonBuffer<SpawnPointElement>();
var prefab = GetSingleton<PlayerSpawner>().Player;
var cmdBuffer = new EntityCommandBuffer(Allocator.Temp);

32
ProjectSettings/EntitiesClientSettings.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e2ea235c1fcfe29488ed97c467a0da53, type: 3}
m_Name:
m_EditorClassIdentifier:
FilterSettings:
ExcludedBakingSystemAssemblies: []
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e2ea235c1fcfe29488ed97c467a0da53, type: 3}
m_Name:
m_EditorClassIdentifier:
FilterSettings:
ExcludedBakingSystemAssemblies: []

36
ProjectSettings/NetCodeClientSettings.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2e9c940b409a48c5acdcb17d07582bb1, type: 3}
m_Name:
m_EditorClassIdentifier:
FilterSettings:
ExcludedBakingSystemAssemblies: []
AdditionalScriptingDefines: []
ClientTarget: 0
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2e9c940b409a48c5acdcb17d07582bb1, type: 3}
m_Name:
m_EditorClassIdentifier:
FilterSettings:
ExcludedBakingSystemAssemblies: []
AdditionalScriptingDefines: []
ClientTarget: 0

38
ProjectSettings/NetCodeServerSettings.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70bae3f5df04479cba47f4cd56a60d53, type: 3}
m_Name:
m_EditorClassIdentifier:
FilterSettings:
ExcludedBakingSystemAssemblies:
- {fileID: 5897886265953266890, guid: 7a450cf7ca9694b5a8bfa3fd83ec635a, type: 3}
- {fileID: 5897886265953266890, guid: 7765a625d63c6194a81f79ce4fc46d4f, type: 3}
AdditionalScriptingDefines: []
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70bae3f5df04479cba47f4cd56a60d53, type: 3}
m_Name:
m_EditorClassIdentifier:
FilterSettings:
ExcludedBakingSystemAssemblies:
- {fileID: 5897886265953266890, guid: 7a450cf7ca9694b5a8bfa3fd83ec635a, type: 3}
- {fileID: 5897886265953266890, guid: 7765a625d63c6194a81f79ce4fc46d4f, type: 3}
AdditionalScriptingDefines: []

1001
ProjectSettings/ProjectSettings.asset
文件差异内容过多而无法显示
查看文件

326
ProjectSettings/QualitySettings.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!47 &1
QualitySettings:
m_ObjectHideFlags: 0
serializedVersion: 5
m_CurrentQuality: 2
m_QualitySettings:
- serializedVersion: 3
name: Low
pixelLightCount: 4
shadows: 2
shadowResolution: 2
shadowProjection: 1
shadowCascades: 4
shadowDistance: 150
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
skinWeights: 255
globalTextureMipmapLimit: 0
textureMipmapLimitSettings: []
anisotropicTextures: 1
antiAliasing: 0
softParticles: 1
softVegetation: 1
realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 1
useLegacyDetailDistribution: 1
vSyncCount: 0
lodBias: 1
maximumLODLevel: 0
enableLODCrossFade: 1
streamingMipmapsActive: 0
streamingMipmapsAddAllCameras: 1
streamingMipmapsMemoryBudget: 512
streamingMipmapsRenderersPerFrame: 512
streamingMipmapsMaxLevelReduction: 2
streamingMipmapsMaxFileIORequests: 1024
particleRaycastBudget: 256
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 16
asyncUploadPersistentBuffer: 1
resolutionScalingFixedDPIFactor: 1
customRenderPipeline: {fileID: 11400000, guid: 168a2336534e4e043b2a210b6f8d379a,
type: 2}
terrainQualityOverrides: 0
terrainPixelError: 1
terrainDetailDensityScale: 1
terrainBasemapDistance: 1000
terrainDetailDistance: 80
terrainTreeDistance: 5000
terrainBillboardStart: 50
terrainFadeLength: 5
terrainMaxTrees: 50
excludedTargetPlatforms: []
- serializedVersion: 3
name: Medium
pixelLightCount: 4
shadows: 2
shadowResolution: 2
shadowProjection: 1
shadowCascades: 4
shadowDistance: 150
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
skinWeights: 255
globalTextureMipmapLimit: 0
textureMipmapLimitSettings: []
anisotropicTextures: 1
antiAliasing: 0
softParticles: 1
softVegetation: 1
realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 1
useLegacyDetailDistribution: 1
vSyncCount: 1
lodBias: 2
maximumLODLevel: 0
enableLODCrossFade: 1
streamingMipmapsActive: 0
streamingMipmapsAddAllCameras: 1
streamingMipmapsMemoryBudget: 512
streamingMipmapsRenderersPerFrame: 512
streamingMipmapsMaxLevelReduction: 2
streamingMipmapsMaxFileIORequests: 1024
particleRaycastBudget: 256
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 16
asyncUploadPersistentBuffer: 1
resolutionScalingFixedDPIFactor: 1
customRenderPipeline: {fileID: 11400000, guid: 3e2e6bfc59709614ab90c0cd7d755e48,
type: 2}
terrainQualityOverrides: 0
terrainPixelError: 1
terrainDetailDensityScale: 1
terrainBasemapDistance: 1000
terrainDetailDistance: 80
terrainTreeDistance: 5000
terrainBillboardStart: 50
terrainFadeLength: 5
terrainMaxTrees: 50
excludedTargetPlatforms: []
- serializedVersion: 3
name: High
pixelLightCount: 4
shadows: 2
shadowResolution: 2
shadowProjection: 1
shadowCascades: 4
shadowDistance: 150
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
skinWeights: 255
globalTextureMipmapLimit: 0
textureMipmapLimitSettings: []
anisotropicTextures: 2
antiAliasing: 0
softParticles: 1
softVegetation: 1
realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 1
useLegacyDetailDistribution: 1
vSyncCount: 1
lodBias: 3
maximumLODLevel: 1
enableLODCrossFade: 1
streamingMipmapsActive: 0
streamingMipmapsAddAllCameras: 1
streamingMipmapsMemoryBudget: 512
streamingMipmapsRenderersPerFrame: 512
streamingMipmapsMaxLevelReduction: 2
streamingMipmapsMaxFileIORequests: 1024
particleRaycastBudget: 256
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 16
asyncUploadPersistentBuffer: 1
resolutionScalingFixedDPIFactor: 1
customRenderPipeline: {fileID: 11400000, guid: 36dd385e759c96147b6463dcd1149c11,
type: 2}
terrainQualityOverrides: 0
terrainPixelError: 1
terrainDetailDensityScale: 1
terrainBasemapDistance: 1000
terrainDetailDistance: 80
terrainTreeDistance: 5000
terrainBillboardStart: 50
terrainFadeLength: 5
terrainMaxTrees: 50
excludedTargetPlatforms: []
m_TextureMipmapLimitGroupNames: []
m_PerPlatformDefaultQuality:
Android: 0
PS4: 0
Server: 0
Standalone: 2
XboxOne: 0
iPhone: 0
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!47 &1
QualitySettings:
m_ObjectHideFlags: 0
serializedVersion: 5
m_CurrentQuality: 2
m_QualitySettings:
- serializedVersion: 3
name: Low
pixelLightCount: 4
shadows: 2
shadowResolution: 2
shadowProjection: 1
shadowCascades: 4
shadowDistance: 150
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
skinWeights: 255
globalTextureMipmapLimit: 0
textureMipmapLimitSettings: []
anisotropicTextures: 1
antiAliasing: 0
softParticles: 1
softVegetation: 1
realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 1
useLegacyDetailDistribution: 1
vSyncCount: 0
lodBias: 1
maximumLODLevel: 0
enableLODCrossFade: 1
streamingMipmapsActive: 0
streamingMipmapsAddAllCameras: 1
streamingMipmapsMemoryBudget: 512
streamingMipmapsRenderersPerFrame: 512
streamingMipmapsMaxLevelReduction: 2
streamingMipmapsMaxFileIORequests: 1024
particleRaycastBudget: 256
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 16
asyncUploadPersistentBuffer: 1
resolutionScalingFixedDPIFactor: 1
customRenderPipeline: {fileID: 11400000, guid: 168a2336534e4e043b2a210b6f8d379a,
type: 2}
terrainQualityOverrides: 0
terrainPixelError: 1
terrainDetailDensityScale: 1
terrainBasemapDistance: 1000
terrainDetailDistance: 80
terrainTreeDistance: 5000
terrainBillboardStart: 50
terrainFadeLength: 5
terrainMaxTrees: 50
excludedTargetPlatforms: []
- serializedVersion: 3
name: Medium
pixelLightCount: 4
shadows: 2
shadowResolution: 2
shadowProjection: 1
shadowCascades: 4
shadowDistance: 150
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
skinWeights: 255
globalTextureMipmapLimit: 0
textureMipmapLimitSettings: []
anisotropicTextures: 1
antiAliasing: 0
softParticles: 1
softVegetation: 1
realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 1
useLegacyDetailDistribution: 1
vSyncCount: 1
lodBias: 2
maximumLODLevel: 0
enableLODCrossFade: 1
streamingMipmapsActive: 0
streamingMipmapsAddAllCameras: 1
streamingMipmapsMemoryBudget: 512
streamingMipmapsRenderersPerFrame: 512
streamingMipmapsMaxLevelReduction: 2
streamingMipmapsMaxFileIORequests: 1024
particleRaycastBudget: 256
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 16
asyncUploadPersistentBuffer: 1
resolutionScalingFixedDPIFactor: 1
customRenderPipeline: {fileID: 11400000, guid: 3e2e6bfc59709614ab90c0cd7d755e48,
type: 2}
terrainQualityOverrides: 0
terrainPixelError: 1
terrainDetailDensityScale: 1
terrainBasemapDistance: 1000
terrainDetailDistance: 80
terrainTreeDistance: 5000
terrainBillboardStart: 50
terrainFadeLength: 5
terrainMaxTrees: 50
excludedTargetPlatforms: []
- serializedVersion: 3
name: High
pixelLightCount: 4
shadows: 2
shadowResolution: 2
shadowProjection: 1
shadowCascades: 4
shadowDistance: 150
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
skinWeights: 255
globalTextureMipmapLimit: 0
textureMipmapLimitSettings: []
anisotropicTextures: 2
antiAliasing: 0
softParticles: 1
softVegetation: 1
realtimeReflectionProbes: 0
billboardsFaceCameraPosition: 1
useLegacyDetailDistribution: 1
vSyncCount: 1
lodBias: 3
maximumLODLevel: 1
enableLODCrossFade: 1
streamingMipmapsActive: 0
streamingMipmapsAddAllCameras: 1
streamingMipmapsMemoryBudget: 512
streamingMipmapsRenderersPerFrame: 512
streamingMipmapsMaxLevelReduction: 2
streamingMipmapsMaxFileIORequests: 1024
particleRaycastBudget: 256
asyncUploadTimeSlice: 2
asyncUploadBufferSize: 16
asyncUploadPersistentBuffer: 1
resolutionScalingFixedDPIFactor: 1
customRenderPipeline: {fileID: 11400000, guid: 36dd385e759c96147b6463dcd1149c11,
type: 2}
terrainQualityOverrides: 0
terrainPixelError: 1
terrainDetailDensityScale: 1
terrainBasemapDistance: 1000
terrainDetailDistance: 80
terrainTreeDistance: 5000
terrainBillboardStart: 50
terrainFadeLength: 5
terrainMaxTrees: 50
excludedTargetPlatforms: []
m_TextureMipmapLimitGroupNames: []
m_PerPlatformDefaultQuality:
Android: 0
PS4: 0
Server: 0
Standalone: 2
XboxOne: 0
iPhone: 0

32
ProjectSettings/ShaderGraphSettings.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: de02f9e1d18f588468e474319d09a723, type: 3}
m_Name:
m_EditorClassIdentifier:
customInterpolatorErrorThreshold: 32
customInterpolatorWarningThreshold: 16
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: de02f9e1d18f588468e474319d09a723, type: 3}
m_Name:
m_EditorClassIdentifier:
customInterpolatorErrorThreshold: 32
customInterpolatorWarningThreshold: 16
正在加载...
取消
保存