|
I tried to translate a script from C# to UnityScript (javascript?). The C# code works perfect... but my "translation" throws this error: "Cannot Convert 'PlayerDataClass' to 'void'" Surely I made something wrong in the "translation" and I don't know what it is... The original code in C#: My UnityScript translation: "return capture" is where the console tells me it's wrong. Thanks in advance to anyone willing to help me.
(comments are locked)
|
|
The constructor in a class can't return anything. The correct translation of is In this case you have a function called "Constructor", but it's not actually a constructor. I'd recommend creating a proper constructor instead. Yep, actually the function should be called something like CreateClone() since that's what it does. An alternative would be to implement a copy-constructor which is a true constructor that takes a reference to an existing instance. Or if you don't actually need it as class you could turn it into a struct, but i guess that's not what you want.
Aug 07 '12 at 11:19 PM
Bunny83
So perfectly correct and precise as always Eric5h5! Thanks a lot! :D
Aug 07 '12 at 11:36 PM
BLF-Games
(comments are locked)
|

Good you have that return at the end, otherwise it would probably compile and your applicatrion would crash since you call the constructor from within the constructor --> endless recursive function call --> stack overflow.