- Home /
Question by
MapuHoB · Mar 04, 2015 at 04:50 PM ·
referencing
How to deep copy a collider2d
https://social.msdn.microsoft.com/Forums/en-US/9f9e8a80-9235-407f-85c8-598937940f17/how-to-remove-memory-reference-between-two-objects-in-c-20?forum=csharplanguage - Here in this link they explain very well for collections. I want to achieve same thing but for collider2d
someclass
{
private Collider2D col;
void Start()
{
col = collider2D;/*but from this point on if the collider2d values change so will the col values change but I want them to stay the same*/
}
}
Comment
Answer by Sapphire4D · Mar 04, 2015 at 05:09 PM
you dont plan on checking skype or turning phone on soon gg
public Collider2D Clone(Collider2D source)
{
IFormatter formatter = new BinaryFormatter();
Stream stream = new MemoryStream();
using (stream)
{
formatter.Serialize(stream, source);
stream.Seek(0, SeekOrigin.Begin);
return (Collider2D)formatter.Deserialize(stream);
}
}
Your answer
Follow this Question
Related Questions
Animation scripting 1 Answer
Can't activate my timer for shooting script? 2 Answers
point A to Point B 0 Answers
Deep Copy of ScriptableObject 1 Answer
A problem regarding accesing a variable in other script. 0 Answers