Author Topic: Constant asset reimporting in Unity 2020.1  (Read 177 times)

Hi we're using the latest Substance plugin (2.5.3) with Unity 2020.1.12f1. Although our project has only about 50 Substance materials at the moment, we get a 10s+ asset reimport every time we stop playing on Editor, even after running an empy scene.

The Editor profiler indicates the time is taken by Substance.Editor.EntryPoint.StateChange() reacting to PlayModeStateChanged() events.

Is this a known bug? Is there a known workaround or fix for it?

Thanks


As a workaround, we've implemented a script that removes the delegate before stopping playing on Editor:

Code: [Select]
public class SubstanceReimportBugWorkaround : MonoBehaviour
{

#if UNITY_EDITOR
    private void OnDestroy()
    {
        Substance.Game.Substance.ClearSubstanceList();

    var fieldInfo = typeof( EditorApplication  ).GetField( "playModeStateChanged", BindingFlags.NonPublic | BindingFlags.Static );
    var eventHandlerList = fieldInfo.GetValue( null ) as Delegate;

    var invocationList = eventHandlerList.GetInvocationList();
    for ( var index = 0; index < invocationList.Length; index++ )
    {
    var listener = invocationList[ index ];
    var declaringTypeFullName = listener.Method.DeclaringType.FullName;
    if ( declaringTypeFullName.ContainsFastIgnoreCase( "Substance" ) )
    {
LogEditor( $"[SubstanceReimportBugWorkaround] Removing {declaringTypeFullName} from EditorApplication.playModeStateChanged's invocation list to avoid unnecessary asset reimports...");
var playModeStateChangedAction = listener as Action< PlayModeStateChange >;

EditorApplication.playModeStateChanged -= playModeStateChangedAction;
    }
    }
    }
#endif
   
}

Hello @peter_futurlab
Sorry for late reply. One of our developers is looking at this issue. I will update you as soon as we figure out what the issue is.

So rare that it doesn't even happen.

 
Last Edit: November 24, 2020, 06:26:19 pm