XDracam / unity-corelibrary

Collection of classes and extension methods that make life with Unity3D more comfortable
MIT License
15 stars 3 forks source link

WithX / Y / Z extension methods for VectorProxies #64

Open Eregerog opened 4 years ago

Eregerog commented 4 years ago

Because this:

BaseBehaviour bb = //...
bb.Position.WithX(/*...*/);

does not compile

XDracam commented 4 years ago

The idea behind the WithFoo extension methods is to promote immutability, whereas the .Position utility promotes simple modification. Adding these methods to VectorProxy would return an immutable copy, potentially leading to bugs for people expecting to modify the state with this. On the other hand, having different semantics for the same method depending on which class it is called on is confusing as well. For now I guess you'll be fine with writing bb.Position.x = bb.Position.x + 17.