void OnDestroy() { // if material is from a sprite collection if (needMaterialInstance && spriteCollection == null) DestroyImmediate(materialInst); }