x = something(x) as something(x)
In Unity3D, which supports mono 2.6ish, for a gui element, 开发者_运维百科I'd write this
SomeProperty = GUI.FloatField(SomeProperty);
However I would like to write something like
GUI.FloatFieldFor(SomeProperty);
How would I go about doing this? Note that SomeProperty is a float, and this GUI stuff goes in an OnGUI method which is called every frame, so I don't have to roll my own PropertyChanged event.
Not experienced in Mono or Unity3D, but you should be able to pass it by reference.
// Method
public void FloatFieldFor(ref float value)
{
value *= value; // or whatever
}
// Call method
GUI.FloatFieldFor(ref SomeProperty);
精彩评论