'PrefabStageUtility' does not exist in the namespace 'UnityEditor.Experimental.SceneManagement'

Options
I'm trying to Unity Cloud build to iOS and I get this error a lot when it tries to build. Happenes several times in the build out put

[Unity] Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditorUtils.cs(180,20): error CS0234: The type or namespace name 'PrefabStageUtility' does not exist in the namespace 'UnityEditor.Experimental.SceneManagement' (are you missing an assembly reference?)


Here is the whole thing if it helps...

7812: [Unity] Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs(191,13): warning CS0618: 'CompilationPipeline.assemblyCompilationStarted' is obsolete: 'Use compilationStarted, compilationFinished or assemblyCompilationFinished instead. Note that using any of these functions to do time measurements is a bad idea as they run async to actual compilation.'
7813: [Unity] Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs(192,13): warning CS0618: 'CompilationPipeline.assemblyCompilationStarted' is obsolete: 'Use compilationStarted, compilationFinished or assemblyCompilationFinished instead. Note that using any of these functions to do time measurements is a bad idea as they run async to actual compilation.'
7814: [Unity] Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs(217,13): warning CS0162: Unreachable code detected
7815: [Unity] Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditorUtils.cs(180,20): error CS0234: The type or namespace name 'PrefabStageUtility' does not exist in the namespace 'UnityEditor.Experimental.SceneManagement' (are you missing an assembly reference?)
7816: [Unity] Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditorUtils.cs(237,21): warning CS0618: 'UnityWebRequest.isNetworkError' is obsolete: 'UnityWebRequest.isNetworkError is deprecated. Use (UnityWebRequest.result == UnityWebRequest.Result.ConnectionError) instead.'
7817: [Unity] Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditorUtils.cs(237,41): warning CS0618: 'UnityWebRequest.isHttpError' is obsolete: 'UnityWebRequest.isHttpError is deprecated. Use (UnityWebRequest.result == UnityWebRequest.Result.ProtocolError) instead.'
7818: [Unity] *** Tundra build failed (0.35 seconds), 1 items updated, 324 evaluated
7819: [Unity] warning: Using obsolete custom response file 'mcs.rsp'. Please use 'csc.rsp' instead.
7820: [Unity] Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs(191,13): warning CS0618: 'CompilationPipeline.assemblyCompilationStarted' is obsolete: 'Use compilationStarted, compilationFinished or assemblyCompilationFinished instead. Note that using any of these functions to do time measurements is a bad idea as they run async to actual compilation.'
7821: [Unity] Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs(192,13): warning CS0618: 'CompilationPipeline.assemblyCompilationStarted' is obsolete: 'Use compilationStarted, compilationFinished or assemblyCompilationFinished instead. Note that using any of these functions to do time measurements is a bad idea as they run async to actual compilation.'
7822: [Unity] Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditor.cs(217,13): warning CS0162: Unreachable code detected
7823: [Unity] Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditorUtils.cs(180,20): error CS0234: The type or namespace name 'PrefabStageUtility' does not exist in the namespace 'UnityEditor.Experimental.SceneManagement' (are you missing an assembly reference?)
7824: [Unity] Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditorUtils.cs(237,21): warning CS0618: 'UnityWebRequest.isNetworkError' is obsolete: 'UnityWebRequest.isNetworkError is deprecated. Use (UnityWebRequest.result == UnityWebRequest.Result.ConnectionError) instead.'
7825: [Unity] Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditorUtils.cs(237,41): warning CS0618: 'UnityWebRequest.isHttpError' is obsolete: 'UnityWebRequest.isHttpError is deprecated. Use (UnityWebRequest.result == UnityWebRequest.Result.ProtocolError) instead.'
7826: [Unity] AssetDatabase: script compilation time: 27.870589s
7827: Aborting batchmode due to failure:
7828: Scripts have compiler errors.
7829: [Unity] Scripts have compiler errors.
7830: [Unity] AcceleratorClientConnectionCallback - disconnected - :0
7831: [Unity] =================================================================
7832: [Unity] Native Crash Reporting
7833: [Unity] =================================================================
7834: [Unity] Got a segv while executing native code. This usually indicates
7835: [Unity] a fatal error in the mono runtime or one of the native libraries
7836: [Unity] used by your application.
7837: [Unity] =================================================================
7838: [Unity] =================================================================
7839: [Unity] Native stacktrace:
7840: [Unity] =================================================================
7841: Unity ran in '112.577114' seconds
7842: ! Unity player export failed!
7843: ! build of 'default-ios' failed. exit
7844: Publishing build 1 of 16767642105799/4ca6d344-bb7b-433e-bace-8b6895afaf48 for target 'default-ios'...
7845: Zipping cache files from Library
7846: done.
7847: publishing finished successfully.
7848: uninstalling iOS credentials for 16767642105799/4ca6d344-bb7b-433e-bace-8b6895afaf48 - default-ios
7849: MAC verified OK
7850: Removing certificate...
7851: removing: /BUILD_PATH/Library/MobileDevice/Provisioning Profiles/219c2c1e-cc74-493b-90e0-ca396d10c0c7.mobileprovision
7852: Build failed. Please check the log for further details.
7853: Using /BUILD_PATH/.rvm/gems/ruby-2.4.2
7854: postbuildsteps finished successfully
7855: postbuildstatus finished successfully.
7856: Finished: FAILURE

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @MomasVII,

    What Unity version is this?
    What PUN version is this?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    "Assets/Photon/PhotonUnityNetworking/Code/Editor/PhotonEditorUtils.cs"

    did you move this file from its original path?

    "Assets/Photon/PhotonRealtime/Code/Editor/PhotonEditorUtils.cs"

    also looks like you use a Unity version between 2017.1 and 2020.2 but we need to know which version...
  • MomasVII
    Options
    I haven't moved the file.
    I'm using PUN2.20 and Unity 2019.3.10f
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    I see, I suggest you do a clean import of latest PUN 2: delete Assets\Photon folder then download and import latest PUN 2.
    To fix the error if you can't update:
    /// <summary>
    		/// Check if a GameObject is a prefab asset or part of a prefab asset, as opposed to an instance in the scene hierarchy
    		/// </summary>
    		/// <returns><c>true</c>, if a prefab asset or part of it, <c>false</c> otherwise.</returns>
    		/// <param name="go">The GameObject to check</param>
    		public static bool IsPrefab(GameObject go)
    		{
                #if UNITY_2018_3_OR_NEWER
                return UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetPrefabStage(go) != null || EditorUtility.IsPersistent(go);
                #else
                return EditorUtility.IsPersistent(go);
    			#endif
    		}
    

    You can ignore the other warnings.
  • Tobias
    Options
    You should update PUN and Unity.

    We fixed the obsolete code references.

    The error
    PhotonEditorUtils.cs(180,20): error CS0234: The type or namespace name 'PrefabStageUtility' does not exist in the namespace 'UnityEditor.Experimental.SceneManagement'
    
    is a non-problem in 2019.4.13, so I'd recommend moving to the LTS versions.
  • Robbysav
    Robbysav
    edited September 2021
    Options
    Did you every get this issue resolved? I am currently having the same issue with Unity 2020.3.6f1.

    I have the exact same error. Unity Version 2020.3.61f

    I went in and checked the file location "Assets/Photon/PhotonRealtime/Code/Editor/PhotonEditorUtils.cs" and the code change you posted above is already what is in there.

    I tried to delete and reimport Photon and still the same error.

    Should I just remove that portion from the script when it comes to PrefabStageUtility?

    Looking forward to hearing back.

    Thank you!
  • Tobias
    Options
    I *think* this is a problem with that Unity Editor version.
    I opened PUN 2.36 (which is 2.35 plus unrelated changes, not released here) in 2020.3.11f1 and there is no problem with this API. So .. for some reason, it seems Unity doesn't reference it in some versions.

    Let us know if this solves the problem or not. I might want to check if that version has a different path for the class or something. Can't find bug reports about this missing...
  • Robbysav
    Robbysav
    edited September 2021
    Options
    I changed the following in the PhotonEditorUtils.cs to this and it built fine with Cloud Build. No errors like shown in the original post.
    public static bool IsPrefab(GameObject go)
    		{
                #if UNITY_2018_3_OR_NEWER
                            return EditorUtility.IsPersistent(go);
                #else
                            return EditorUtility.IsPersistent(go);
                #endif
    
            }
    

    Is getting rid of the following going to cause any issues down the line?
    return UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetPrefabStage(go) != null || EditorUtility.IsPersistent(go);
    


    Looking forward to hearing back and wrapping this up for anyone else that might have an issue.

    Thank you,
  • Tobias
    Options
    It is a problem in Cloud Build then? Is the Cloud Build using the same version of Unity to build?

    I thin the special code for 2018.3 and up is covering some specific issues but I don't recall which one. Would have to check some logs.