Using Unity 2023.1.3f1 and MPPM 0.1.1, I made a brand new project and enabled “enter play mode options” in the project settings Editor tab. I then proceeded to enable a “Player 2” Editor and entered playmode for good measure to check that everything works as designed.
My project only has one script, with a simple Start method of Debug.Log(“hi A”);
I have updated the A to B and waited for the editor to finish reloading domain, entered play mode… and while the main editor shows “B”, the “player 2” editor still shows “A”. This persists even if I try to leave and enter playmode numerous times.
Changing B to C will still result in the main window printing C, and the “player 2” window printing A.
Enabling domain reload, saving the project, and pressing play, does not resolve this issue.
Restarting the player2 window after enabling Domain reload works as designed, with the text changing due to domain reload on every enter-play session, I assume.
Is there any way to make the extra editor windows reload domain when the main editor does, to allow disabling domain reload, for faster iteration times, please?
If you want to do this quickly, simply copy the “YourProject/Library/PackageCache/com.unity.multiplayer.playmode” package somewhere else, open the package manager, add the package from disk, and then make any adjustments you want.
For example, I also wrote a small change to prevent the constant window closing and refreshing for the layout because it was driving me crazy.
Hopefully MPPM will update this quickly, because it is infuriating as far inefficiency goes.
I have same problem.
Using @Yoraiz0r’s method as a reference, I wrote a script that calls for an update via reflection from the outside without having to directly modify the package.
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
internal class ForceSyncVirtualPlayer : AssetPostprocessor
{
private const string SessionStateKey = "ForceSyncVirtualPlayer.CachedTotalCount";
private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload)
{
var totalCount = importedAssets.Length + deletedAssets.Length + movedAssets.Length + movedFromAssetPaths.Length;
if (!didDomainReload)
{
SessionState.SetInt(SessionStateKey, totalCount);
return;
}
var cachedTotalCount = SessionState.GetInt(SessionStateKey, 0);
if (cachedTotalCount == 0) return;
_targetType ??= Type.GetType("Unity.Multiplayer.Playmode.VirtualProjects.Editor.AssetDatabaseCallbacks, Unity.Multiplayer.Playmode.VirtualProjects.Editor");
if (_targetType == null)
{
Debug.LogError("Target type not found.");
return;
}
_eventField ??= _targetType.GetField("OnPostprocessAllAssetsCallback", BindingFlags.Static | BindingFlags.NonPublic);
if (_eventField == null)
{
Debug.LogError("Event field not found.");
return;
}
_eventDelegate = (Delegate) _eventField.GetValue(null);
if (_eventDelegate == null)
{
Debug.LogError("Event delegate not found.");
return;
}
_eventDelegate.DynamicInvoke(true, cachedTotalCount);
SessionState.EraseInt(SessionStateKey);
}
private static Type _targetType;
private static FieldInfo _eventField;
private static Delegate _eventDelegate;
}
Hi would you be able to try this again using either 1.3.0 pre-3 or 1.3.0. We fixed some things involving script syncing issues linked with domain reload.