开发者

x = something(x) as something(x)

开发者 https://www.devze.com 2023-01-23 14:03 出处:网络
In Unity3D, which supports mono 2.6ish, for a gui element, 开发者_运维百科I\'d write this SomeProperty = GUI.FloatField(SomeProperty);

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消