I asked this question on Unity Answers, but yet again there was no response. Now I'm hoping someone on SO will happen to know the answer since it is a programming question.
There are quite a few of these questions, but I couldn't find any more recent than about 2009 and a lot has changed since then. So...
In Unity 5, is it possible to overload an operator (specifically the + operator) when using JavaScript/UnityScript?
-- Additional Information --
I have a class like so:
class Vector3Int
{
var x:int;
var y:int;
var z:int;
function Vector3Int(nX:int,nY:int,nZ:int)
{
x=nX;
y=nY;
z=nZ;
}
}
I wish to be able to do the following...
var position1:Vector3Int=new Vector3Int(5,39,-2);
var position2:Vector3Int=new Vector3Int(83,3,148);
print(position1+position2);
...and have the output be 88,42,146
.
i guess it wont be possible to add two class directly.try this code to add value of two class:
class to get sum of two classes
main class