I want to make a copy of an object (the object include a Texture2D), I tried using serializing and deserializing , but as the Texture2D class not is serialisable, not work, then I tried using reflection, but as Texture2D have not a empty constructor, not work.
Any idea of how I can solve the problem? Thanks.
You cannot serialize and deserialize unmanaged resources, which is what the Texture2D object wraps. The first question is what are you wanting to achieve by making a copy of the Texture2D object? Once it is created, it is essentially an immutable object. The only thing you can change is set the pixel data on the unmanaged resource. So just copy the reference.
And serializing/deserializing just to make a copy makes the game programmer part of me shudder. That it is also what Unity does to copy objects doesn’t make it any better.
Thanks, finally I used an alternative route to solve the problem, where not need make copy.