Server Settings Don't Generate

Options
Using Unity 2019.2.21f1

When I import PUN from Asset Store, the Wizard doesn't start until I close and re open Unity.

Whenever I add the app ID or email to Wizard, server settings do not generate and I am unable to even setup to get things started. I have restarted multiple times and nothing has changed.

Comments

  • gekido
    gekido ✭✭
    Options
    Running into the same problem with a fresh project in 2019.4 LTS - entering my project ID and hitting 'setup project' throws a bunch of exceptions:

    NullReferenceException: Object reference not set to an instance of an object
    Photon.Pun.PhotonNetwork..cctor () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:992)
    Rethrow as TypeInitializationException: The type initializer for 'Photon.Pun.PhotonNetwork' threw an exception.
    Photon.Pun.PhotonEditor.UiSetupApp () (at Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs:403)
    Photon.Pun.PhotonEditor.OnGUI () (at Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs:319)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
    UnityEditor.HostView.Invoke (System.String methodName) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
    UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
    UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
    UnityEditor.DockArea.OldOnGUI () (at <78f1ad0f25c84e3ca853e639f50d95f5>:0)
    UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.EventDispatcher.OpenGate () (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <3736d7cfd1f845a5922f99478cb469e7>:0)
    UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <817eebdd70f8402280b9cb11fff8b976>:0)
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited June 2020
    Options
    Hi @Reality_Devs, @gekido,

    Thank you for choosing Photon!

    I assume this is the latest PUN 2 version right?

    do you have errors in the project when importing PUN 2?

    for the sake of testing could you replace PhotonNetwork.PhotonServerSettings property code with the following code, in "Assets\Photon\PhotonUnityNetworking\Code\PhotonNetwork.cs":
    public static ServerSettings PhotonServerSettings
            {
                get
                {
                    if (photonServerSettings == null)
                    {
                        photonServerSettings = (ServerSettings)Resources.Load(PhotonNetwork.ServerSettingsFileName, typeof(ServerSettings));
                        #if UNITY_EDITOR
                        if (photonServerSettings == null)
                        {
                            CreateSettings();
                        }
                        #endif
                    }
    
                    return photonServerSettings;
                }
                private set { photonServerSettings = value; }
            }
    

    The idea is to add a call to
    CreateSettings
    
    there to create the ScriptableObject file when it's not loaded.
    We will investigate why this is not done.
    You could help by adding a debug log to OnProjectChanged to see if it's called or not, in "Assets\Photon\PhotonUnityNetworking\Code\Editor\PhotonEditor.cs":
    private static void OnProjectChanged()
            {
                Debug.Log("OnProjectChanged");
    
  • Tobias
    Options
    @gekido , @Reality_Devs, which version of PUN do you use exactly?
    @Reality_Devs, do you get anything in the Editor Logs? Could you send them to developer@photonengine.com please?

    Maybe it is affected by a third party installation or Windows update (that happened before and makes these things hard to nail down).
    We will try to fix this asap but so far, did not reproduce the issue.

  • gekido
    gekido ✭✭
    Options
    The message I posted above was the only message that appeared. Strangely I opened up the same project a little while later and was able to generate the serversettings fine that time?
  • Tobias
    Options
    I could not reproduce the issue at all yet. I tried in various Unity versions including 2019.4.0f1. Importing from the Asset Store worked.
    Is your PUN version from the Asset Store the most recent?

    It may be a rare condition, where the UI system (a new one, by the way: UIElements) is drawing the old UI and accessing the PhotonNetwork. Maybe this is done in another sequence than with the older UI.

    We know that the PhotonNetwork constructor may run into trouble in some cases and are looking into solutions. We'll also check if newer Unity versions can support this better than 2017, which is our current baseline.

    Sorry for the issues.
    Usually, reopening Unity should not show the error a second time. Let us know if you experience something else.