Problem raised: As the original scene manager required synchronizing all scenes from the server to the client, this is suitable for end-to-end game mode and is not common in C/S mode. Opening a room game requires dynamically creating new scenes, which was not supported by the original scene manager and needs to be implemented by oneself.

Change 1: Because it is to realize online games in the game hall on the Internet, the scene manager is replaced with a simple scene manager. In this simple scene manager, the client has only one scene, while the server has many scenes. The client selects the scene, and the server synchronizes the scene accordingly.

Change 2: It is agreed that all scenes have unique names, and an empty scene named Active is loaded on the server and set as Active Scene. That is to say, all dynamically created network objects are created by default in this empty scene. After creation, use SceneManager again MoveGameObject To Scene moves it to the specified scene. In the online environment, it is impossible for everyone to specify a specific activity scenario, as this can lead to conflicts. Once agreed upon, there will be no conflicts.

Change 3: Added a method to create, load, and merge scenes. Everyone knows about the game of opening a room. There is a room creator who names newly opened room scenes using a naming convention similar to "Room_player username". And this newly created scene is loaded as a fixed scene Room and merged into a new name "Room_Player Username". Similarly, the main game scene goes through the same process, loading a fixed Game scene and merging it into the newly created "Games_Player Username" scene. Then, the scene manager implements scene synchronization between the server and client.

The instance reference for the custom scene manager is NetworkManager Singleton.SceneManager, His method is as follows:

//Server loading scenario
//SceneName is the name of the scene
void SvrLoadScene(string sceneName);

//Server uninstallation scenario
//SceneName Scene Name
void SvrUnloadScene(string sceneName);

//The server creates a new scene and loads another scene, then merges the loaded scene with offset into the newly created scene.
//ID specifies the client ID
//DesScene Target Scene Name
//SrcScene Source Scene Name
//Offset "Scene offset
void SvrCreateAndMergeScene(ulong id,string desScene,string srcScene,Vector3 offset);

//Client switches to the current scene
//CurScene specifies the scene name
void ClientSwitchScene(string curScene);

//Scenario of switching a client on the server
//ID specifies the client ID
//CurScene specifies the scene name
void ServerSwitchScene(ulong id,string curScene);

//Set the default scenario, and when the client first connects to the server, the server will synchronize the default scenario with the client.
//DefaultScene Default Scene Name
void SetDefaultScene(string defaultScene);

//The server-side scene loading completion event is triggered when the server-side scene is loaded.
//Use NetworkManager.Singleton.SceneManager.OnServerSceneLoadComplete += OnServerSceneLoadComplete;
//Add an event trigger function.
OnServerSceneLoadComplete(string scname)

标签: none

已有 8 条评论

  1. 新车新盘 嘎嘎稳 嘎嘎靠谱

  2. 华纳总公司开户申请步骤?(▲18288362750?《?微信STS5099? 】【╃q 2704132802╃】

  3. 华纳东方明珠客服电话是多少?(▲18288362750?《?微信STS5099? 】
    如何联系华纳东方明珠客服?(▲18288362750?《?微信STS5099? 】
    华纳东方明珠官方客服联系方式?(▲18288362750?《?微信STS5099?
    华纳东方明珠客服热线?(▲18288362750?《?微信STS5099?
    华纳东方明珠24小时客服电话?(▲18288362750?《?微信STS5099? 】
    华纳东方明珠官方客服在线咨询?(▲18288362750?《?微信STS5099?

  4. 华纳东方明珠客服电话是多少?(??155--8729--1507?《?薇-STS5099】【?扣6011643?】
    华纳东方明珠开户专线联系方式?(??155--8729--1507?《?薇-STS5099】【?扣6011643?】

  5. 果博东方客服开户联系方式【182-8836-2750—】?薇- cxs20250806】
    果博东方公司客服电话联系方式【182-8836-2750—】?薇- cxs20250806】
    果博东方开户流程【182-8836-2750—】?薇- cxs20250806】
    果博东方客服怎么联系【182-8836-2750—】?薇- cxs20250806】

  6. 华纳圣淘沙开户步骤详解(183-8890-9465—?薇-STS5099【6011643】

    华纳圣淘沙公司开户流程全解析(183-8890-9465—?薇-STS5099【6011643】
    华纳圣淘沙公司账户注册指南(183-8890-9465—?薇-STS5099【6011643】
    新手如何开通华纳圣淘沙公司账户(183-8890-9465—?薇-STS5099【6011643】
    华纳圣淘沙企业开户标准流程(183-8890-9465—?薇-STS5099【6011643】
    华纳圣淘沙公司开户:从零到一(183-8890-9465—?薇-STS5099【6011643】
    官方指南:华纳圣淘沙公司开户流程(183-8890-9465—?薇-STS5099【6011643】
    华纳圣淘沙公司开户流程说明书(183-8890-9465—?薇-STS5099【6011643】

  7. 华纳圣淘沙公司开户新手教程

    零基础学会(183-8890-9465薇-STS5099)
    华纳圣淘沙公司开户

    华纳圣淘沙公司开户保姆级教程(183-8890-9465薇-STS5099)

    一步步教你开通华纳圣淘沙公司账户(183-8890-9465薇-STS5099)

    华纳圣淘沙公司开户分步图解

    首次开户必看:(183-8890-9465薇-STS5099)
    华纳圣淘沙全攻略

    华纳圣淘沙公司开户实操手册(183-8890-9465薇-STS5099)
    华纳圣淘沙开户流程视频教程

    手把手教学:(183-8890-9465薇-STS5099)
    华纳圣淘沙公司开户

    华纳圣淘沙公司开户完全指南(183-8890-9465薇-STS5099)

  8. 华纳圣淘沙公司开户新手教程

    零基础学会(183-8890-9465薇-STS5099)
    华纳圣淘沙公司开户

    华纳圣淘沙公司开户保姆级教程(183-8890-9465薇-STS5099)

    一步步教你开通华纳圣淘沙公司账户(183-8890-9465薇-STS5099)

    华纳圣淘沙公司开户分步图解

    首次开户必看:(183-8890-9465薇-STS5099)
    华纳圣淘沙全攻略

    华纳圣淘沙公司开户实操手册(183-8890-9465薇-STS5099)
    华纳圣淘沙开户流程视频教程

    手把手教学:(183-8890-9465薇-STS5099)
    华纳圣淘沙公司开户

    华纳圣淘沙公司开户完全指南(183-8890-9465薇-STS5099)

添加新评论