{
//参照だとダメ
// m_materials[name_list_curr].mainTexture = m_updatetex2d;
//ConvertTextureはダメ: 何も表示されない
//Graphics.ConvertTexture(m_updatetex2d, m_materials[name_list_curr].mainTexture);
// CopyTextureはdeepcopy:何も表示されない
//Graphics.CopyTexture(m_updatetex2d, m_materials[name_list_curr].mainTexture);
//SetPixelsによるdeepcopy
if (true)
{
var originalTexture = m_updatetex2d;
Texture2D copyTexture = new Texture2D(originalTexture.width, originalTexture.height, TextureFormat.ARGB32, false);
copyTexture.SetPixels32(originalTexture.GetPixels32());
copyTexture.Apply();
m_materials[name_list_curr].mainTexture = copyTexture;
}
// 外部テクスチャはコピーできない?
if (false)
{
int texid = getTextureID4Unity();
if (texid != -1)
{
IntPtr texidptr = new IntPtr(texid);
Texture2D nativeTexture = Texture2D.CreateExternalTexture(
tex_sizeX, tex_sizeY,
TextureFormat.ARGB32,
false, false,
texidptr
);
IntPtr nativeData = nativeTexture.GetNativeTexturePtr();
m_tex2d_2.UpdateExternalTexture(nativeData);
{
var originalTexture = m_tex2d_2;
Texture2D copyTexture = new Texture2D(originalTexture.width, originalTexture.height, TextureFormat.ARGB32, false);
copyTexture.SetPixels32(originalTexture.GetPixels32());
copyTexture.Apply();
m_materials[name_list_curr].mainTexture = copyTexture;
}
//m_materials[name_list_curr].mainTexture = m_tex2d_2;
}
}
}