Search Unity

Deleted

Discussion in 'Scripting' started by JWLewis777, May 19, 2019.

  1. JWLewis777

    JWLewis777

    Joined:
    May 17, 2015
    Posts:
    46
    Post Deleted
     
    Last edited: Feb 23, 2022
  2. Tortuap

    Tortuap

    Joined:
    Dec 4, 2013
    Posts:
    137
    When you do tempItem = item you are only assigning the reference value or variable item to the variable tempItem.

    If you want to copy the members of item into tempItem, at runtime in your standalone game, you'll need to either do a deep or a swallow copy of the object members. Or simply said, to copy each member one by one.

    Note that in the editor environment, but not in your standalone, you might make use of
    Code (CSharp):
    1.  
    2. UnityEditorInternal.ComponentUtility.CopyComponent(component);
    3. UnityEditorInternal.ComponentUtility.PasteComponentAsNew(_targetGO);
    4.