The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Adjust ServerSettings at runtime?

2011-12-09 20:06:01

My game connects to a central update server at startup, and I would like to be able to adjust any necessary Photon settings via this update server. For example, if Photon Cloud goes down I would like to be able to host my own server and temporarily point all my released games to it.

For some reason, Photon's ServerSettings seem to be stored as static members of a nonstatic serialized ScriptableObject. How do I access and change them at runtime? The code I have:

Results in this error:


2011-12-09 22:12:04

don't use the settings at all but PhotonNetwork.Connect and you don't have the problem (I don't touch the settings and even unhooked its annoying automatic code that shows you that stupid configuration screen on every leave of play mode if you refuse to configure it as you never use the connect with settings function)

2011-12-09 23:17:25

Fair enough ;)

Thanks for the tip!

2011-12-15 10:32:17

The settings are not exactly built to be modified at runtime. We simply didn't see this usecase. The settings file and wizard is just one (simple) way to connect - using Connect() directly is as good.

2019-02-07 09:35:27

When I connect to Best Region and Random Room, I am at the mercy of Photon server settings. This caused the player characters to end up in different regions and hence could not be in one room.
To avoid it I am trying to 'Connecttoregion'. When I do this, it is giving error on ap Id. I am searching for pun connect call with programmatic control of app settings. I thought I could get all app settings using "PhotonNetwork.PhotonServerSettings.AppSettings;" and then update the same with what I changed i.e. the region.
I am not able to find any api that updates it.

Or is there any other way to achieve this? I want to be able to connect to specific region. connecttoregion returns with error on App Id.


2019-02-07 11:05:43

Hi @Ishwar,

As we have explicitly added to the "Migration Notes".
In PUN2, ONLY PhotonNetwork.ConnectUsingSettings() makes use of PhotonServerSettings.

If you want to connect a specific region, set it in PhotonServerSettings.AppSettings.FixedRegion (in Editor or via code) first then call PhotonNetwork.ConnectUsingSettings().

2019-02-07 12:01:58

Thanks a lot. I just found that 'PhotonNetwork.PhotonServerSettings.AppSettings' returns me the reference (not a copy). Hence the below code worked for me.

Unless you suggest any down side to this, I will use this. Thanks!

2019-07-13 23:04:01

Thank you!

Back to top