- Home /
Question by
laian · Aug 11, 2014 at 02:46 AM ·
javascript
Best way to copy Struct-classes in UnityScript?
Basicallym, I have a lot of these in my code:
class Struct extends System.Object{
function Struct(other: Struct){
this.a = other.a;
this.b = other.b;
}
var a: int;
var b: int;
}
Is there a better way to do "copy construction" or "copy assignment"?
Comment
Best Answer
Answer by laian · Aug 15, 2014 at 08:09 PM
Figured it out:
class Struct extends System.Object{
var a: int;
var b: int;
Struct clone() {
return this.MemberwiseClone();
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613160323im_/https://answers.unity.com/themes/thub/images/avi.jpg)