2021.2.0a21 Texture Instantiation Issue (+Repro)

Instantiating textures is broken in the latest alpha. Here’s what’s happening:

And here’s the class for testing.

using UnityEngine;
public class Repro_2021_2_0a21_Texture_Instantiation : MonoBehaviour
{
  [Header("Select a readable texture to test instantiation:")]
  public Texture2D originalTexture;
  [Header("After instantiation, double-click to view result:")]
  public Texture2D instantiatedTexture;

  void OnValidate()
  {
    Dispose();
    if (originalTexture != null)
    {
      if (originalTexture.isReadable)
      {
        instantiatedTexture = Instantiate(originalTexture);
      } else
      {
        Debug.LogError("You must first enable Read/Write in texture import settings.");
      }
    }
  }
  void OnDestroy()
  {
    Dispose();
  }
  void Dispose()
  {
    if (instantiatedTexture != null) DestroyImmediate(instantiatedTexture);
    instantiatedTexture = null;
  }
}

Drag-drop or select any texture which has ‘read/write’ enabled into the top property, result will appear in the bottom one.

Edit: Note this only happens in the Editor - both Edit Mode and Play Mode - but NOT in builds.

I’ve found a solution - in 0a21 call .Apply then it’s fine (or appears to be… I haven’t looked any deeper than the thumbnails matching in the repro):

instantiatedTexture = Instantiate(originalTexture);
#if UNITY_EDITOR
instantiatedTexture.Apply();
#endif

Edit: Added the #if/#endif to skip the call in builds.