Skip to content

Commit 2ff8ce8

Browse files
committed
Put things back
1 parent 48caa1e commit 2ff8ce8

File tree

3 files changed

+185
-196
lines changed

3 files changed

+185
-196
lines changed

com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,6 +3079,191 @@ private void ProcessDeferredCreateObjectMessages()
30793079
DeferredObjectCreationList.Clear();
30803080
}
30813081

3082+
/// <summary>
3083+
/// The scene map type <see cref="SceneMap"/>.
3084+
/// </summary>
3085+
public enum MapTypes
3086+
{
3087+
/// <summary>
3088+
/// Denotes the server to client scene map type.
3089+
/// </summary>
3090+
ServerToClient,
3091+
/// <summary>
3092+
/// Denotes the client to server scene map type.
3093+
/// </summary>
3094+
ClientToServer
3095+
}
3096+
3097+
/// <summary>
3098+
/// Provides the status of a loaded scene
3099+
/// </summary>
3100+
public struct SceneMap : INetworkSerializable
3101+
{
3102+
/// <summary>
3103+
/// The scene mapping type <see cref="MapTypes"/>.
3104+
/// </summary>
3105+
public MapTypes MapType;
3106+
/// <summary>
3107+
/// The <see cref="UnityEngine.SceneManagement.Scene"/> struct of the scene mapped.
3108+
/// </summary>
3109+
public Scene Scene;
3110+
/// <summary>
3111+
/// When true, the scene is present.
3112+
/// </summary>
3113+
public bool ScenePresent;
3114+
/// <summary>
3115+
/// The name of the scene
3116+
/// </summary>
3117+
public string SceneName;
3118+
3119+
#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION
3120+
/// <summary>
3121+
/// The scene's server handle (a.k.a network scene handle)
3122+
/// </summary>
3123+
/// <remarks>
3124+
/// This is deprecated in favor of ServerSceneHandle
3125+
/// </remarks>
3126+
[Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> ServerSceneHandle")]
3127+
#else
3128+
/// <summary>
3129+
/// The scene's server handle (a.k.a network scene handle)
3130+
/// </summary>
3131+
#endif
3132+
public int ServerHandle;
3133+
3134+
#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION
3135+
/// <summary>
3136+
/// The mapped handled. This could be the ServerHandle or LocalHandle depending upon context (client or server).
3137+
/// </summary>
3138+
/// <remarks>
3139+
/// This is deprecated in favor of MappedLocalSceneHandle
3140+
/// </remarks>
3141+
[Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> MappedLocalSceneHandle")]
3142+
#else
3143+
/// <summary>
3144+
/// The mapped handled. This could be the ServerHandle or LocalHandle depending upon context (client or server).
3145+
/// </summary>
3146+
#endif
3147+
public int MappedLocalHandle;
3148+
3149+
#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION
3150+
/// <summary>
3151+
/// The local handle of the scene.
3152+
/// </summary>
3153+
/// <remarks>
3154+
/// This is deprecated in favor of LocalSceneHandle
3155+
/// </remarks>
3156+
[Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> LocalSceneHandle")]
3157+
#else
3158+
/// <summary>
3159+
/// The local handle of the scene.
3160+
/// </summary>
3161+
#endif
3162+
public int LocalHandle;
3163+
3164+
#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE
3165+
/// <summary>
3166+
/// The scene's server handle (a.k.a network scene handle)
3167+
/// </summary>
3168+
public SceneHandle ServerSceneHandle;
3169+
/// <summary>
3170+
/// The mapped handled. This could be the ServerSceneHandle or LocalSceneHandle depending upon context (client or server).
3171+
/// </summary>
3172+
public SceneHandle MappedLocalSceneHandle;
3173+
/// <summary>
3174+
/// The local handle of the scene.
3175+
/// </summary>
3176+
public SceneHandle LocalSceneHandle;
3177+
#endif
3178+
3179+
private NetworkSceneHandle m_ServerHandle;
3180+
private NetworkSceneHandle m_MappedLocalHandle;
3181+
private NetworkSceneHandle m_LocalHandle;
3182+
3183+
internal SceneMap(MapTypes mapType, Scene scene, bool isScenePresent, NetworkSceneHandle serverHandle, NetworkSceneHandle mappedLocalHandle)
3184+
{
3185+
MapType = mapType;
3186+
Scene = scene;
3187+
ScenePresent = isScenePresent;
3188+
SceneName = isScenePresent ? scene.name : "Not Present";
3189+
3190+
m_ServerHandle = serverHandle;
3191+
m_MappedLocalHandle = mappedLocalHandle;
3192+
m_LocalHandle = new NetworkSceneHandle(scene.handle);
3193+
3194+
#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE
3195+
ServerSceneHandle = serverHandle;
3196+
MappedLocalSceneHandle = mappedLocalHandle;
3197+
LocalSceneHandle = scene.handle;
3198+
#endif
3199+
3200+
#pragma warning disable CS0618 // Type or member is obsolete
3201+
#if SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG
3202+
ServerHandle = (int)m_ServerHandle.GetRawData();
3203+
MappedLocalHandle = (int)m_MappedLocalHandle.GetRawData();
3204+
LocalHandle = (int)m_LocalHandle.GetRawData();
3205+
#else
3206+
ServerHandle = m_ServerHandle.GetRawData();
3207+
MappedLocalHandle = m_MappedLocalHandle.GetRawData();
3208+
LocalHandle = m_LocalHandle.GetRawData();
3209+
#endif
3210+
#pragma warning restore CS0618 // Type or member is obsolete
3211+
}
3212+
3213+
/// <inheritdoc cref="INetworkSerializable.NetworkSerialize{T}(BufferSerializer{T})"/>
3214+
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
3215+
{
3216+
serializer.SerializeValue(ref MapType);
3217+
serializer.SerializeValue(ref ScenePresent);
3218+
if (serializer.IsReader)
3219+
{
3220+
SceneName = "Not Present";
3221+
}
3222+
if (ScenePresent)
3223+
{
3224+
serializer.SerializeValue(ref SceneName);
3225+
#pragma warning disable CS0618 // Type or member is obsolete
3226+
serializer.SerializeValue(ref LocalHandle);
3227+
}
3228+
serializer.SerializeValue(ref ServerHandle);
3229+
serializer.SerializeValue(ref MappedLocalHandle);
3230+
#pragma warning restore CS0618 // Type or member is obsolete
3231+
3232+
3233+
#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE
3234+
// Ensure the SceneHandles are valid to be serialized
3235+
if (serializer.IsWriter)
3236+
{
3237+
if (m_LocalHandle.IsEmpty() && LocalSceneHandle != SceneHandle.None)
3238+
{
3239+
m_LocalHandle = LocalSceneHandle;
3240+
}
3241+
if (m_ServerHandle.IsEmpty() && ServerSceneHandle != SceneHandle.None)
3242+
{
3243+
m_ServerHandle = ServerSceneHandle;
3244+
}
3245+
if (m_MappedLocalHandle.IsEmpty() && MappedLocalSceneHandle != SceneHandle.None)
3246+
{
3247+
m_MappedLocalHandle = MappedLocalSceneHandle;
3248+
}
3249+
}
3250+
3251+
// Serialize the INetworkSerializable representations
3252+
serializer.SerializeValue(ref m_LocalHandle);
3253+
serializer.SerializeValue(ref m_ServerHandle);
3254+
serializer.SerializeValue(ref m_MappedLocalHandle);
3255+
3256+
// If we're reading, convert back into the raw SceneHandle
3257+
if (serializer.IsReader)
3258+
{
3259+
ServerSceneHandle = m_ServerHandle;
3260+
ServerSceneHandle = m_LocalHandle;
3261+
ServerSceneHandle = m_MappedLocalHandle;
3262+
}
3263+
#endif
3264+
}
3265+
}
3266+
30823267
/// <summary>
30833268
/// Returns the list of all scene mappings when scene management is enabled.
30843269
/// </summary>

com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs

Lines changed: 0 additions & 193 deletions
This file was deleted.

com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs.meta

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)