Replace object instance with another in C#

后端 未结 4 1069
长情又很酷
长情又很酷 2021-02-13 05:17

In this question I would like to find out if and how this is possible. This technique would seem extremely bad practice but it seems that the API (UnityEditor) that I am using,

4条回答
  •  無奈伤痛
    2021-02-13 05:57

    No, that's not possible.

    To actually change all references to an object, you would have to freeze all threads in the process, and access their register sets and stack. That's what the garbage collector does, but it's not possible for regular code.

    What the method most likely does is to make a deep copy of one object onto the other.

提交回复
热议问题