I'm trying to keep my connection between the server and my clients, when the clients are switching the scene. How it could be possible?

有帮助吗?

解决方案

If the connection is tied to a MonoBehaviour you can just call DontDestroyOnLoad on that object.

Something like this

DontDestroyOnLoad( connectionObject );

You can read more about it here.

Note: you need to destroy the object by hand by calling Destroy when don't need it any more.

If the connection is not tied to a MonoBehaviour you need to keep a reference to it from an object that is not destroyed, for instance a Singleton.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top