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.