I have a iOS App created with React-Native that includes a Unity app that may be opened and closed several times during the use of the React-Native app.

The Unity app has a Photon Pun. All works very well the first time we open the Unity app.

But the Photon Pun does not connect properly to the master server the second time one opens Unity within the same process.

I figured out that the internal class PhotonHandler gets started and enabled when we first start Unity. It gets disabled when we stop Unity. But then it never enables again. The problem is maybe that the enabling happens through the constructor of PhotonNetwork. This is the stack trace:

Photon.Pun.PhotonHandler:OnEnable()
UnityEngine.GameObject:AddComponent()
Photon.Pun.PhotonHandler:get_Instance()
Photon.Pun.PhotonNetwork:StaticReset()
Photon.Pun.PhotonNetwork:.cctor()
PhotonManager:OnEnable()

Components get added and enabled in constructors and disabled when we run unloadApplication. But many game objects then remain disabled when we start Unity again because all instances are already created.

How can I enable them again?

A little bit of background

Unity is exported for iOS, built and the resulting UnityFramework is embedded into the iOS app.

We then start unity using unityFramework.runEmbedded(withArgc: CommandLine.argc, argv: CommandLine.unsafeArgv, appLaunchOpts: [:])

How we solved it on android

On Android we are able to start unity in a separate process and then completely kill this process while the main app keeps running. The problem disappeared there as soon as we did that.

I am happy for every little hint.

0

There are 0 best solutions below