本文整理汇总了C#中Operator.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Operator.GetValue方法的具体用法?C# Operator.GetValue怎么用?C# Operator.GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operator
的用法示例。
在下文中一共展示了Operator.GetValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawNodeInspector
public static void DrawNodeInspector(Operator op)
{
if (_TitleStyle == null) {
_TitleStyle = new GUIStyle();
_TitleStyle.fontSize = 16;
}
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(op.Title, _TitleStyle, GUILayout.Width(GraphEditor.SidebarWidth/2-20f));
if (op.IsGeometryOutput) {
EditorGUILayout.LabelField("(output)", GUILayout.Width(GraphEditor.SidebarWidth/2-20f));
} else {
if (GUILayout.Button("Output")) {
foreach (var kvp in GraphEditor.Template.Operators) {
kvp.Value.IsGeometryOutput = kvp.Value.GUID == op.GUID;
}
}
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space();
if (op.IsGeometryOutput) {
EditorGUILayout.LabelField("[Geometry Output]");
}
foreach (IOOutlet input in op.Inputs) {
// Value comes from outlet connection
foreach (IOConnection conn in GraphEditor.Template.Connections) {
if (op.GUID == conn.To.GUID && input.Name == conn.Input.Name) {
var valueFrom = System.String.Format("{0}.{1}", conn.From.Title, conn.Output.Name);
EditorGUILayout.LabelField(input.Name, valueFrom);
continue;
}
}
// Float input
if (input.DataType == typeof(System.Single)) {
float newValue = EditorGUILayout.FloatField(input.Name, op.GetValue<float>(input));
op.SetValue<float>(input, newValue);
}
// Integer field
else if (input.DataType == typeof(System.Int32)) {
int newValue = EditorGUILayout.IntField(input.Name, op.GetValue<int>(input));
op.SetValue<int>(input, newValue);
}
// Boolean input
else if (input.DataType == typeof(System.Boolean)) {
bool newValue = EditorGUILayout.Toggle(input.Name, op.GetValue<bool>(input));
op.SetValue<bool>(input, newValue);
}
// Enum input
else if (input.DataType.IsEnum) {
if (input.Member is System.Reflection.FieldInfo) {
object objValue = ((System.Reflection.FieldInfo) input.Member).GetValue(op);
string[] enumNames = System.Enum.GetNames(input.DataType);
System.Array enumValues = System.Enum.GetValues(input.DataType);
int selectedIndex = System.Array.IndexOf(enumValues, objValue);
selectedIndex = EditorGUILayout.Popup(input.Name, selectedIndex, enumNames);
((System.Reflection.FieldInfo) input.Member).SetValue(op, enumValues.GetValue(selectedIndex));
} else {
Debug.LogFormat("Enum {0} is not a field", input.Name);
}
}
// Vector2
else if (input.DataType == typeof(Vector2)) {
Vector2 newValue = EditorGUILayout.Vector2Field(input.Name, op.GetValue<Vector2>(input));
op.SetValue<Vector2>(input, newValue);
}
// Vector3
else if (input.DataType == typeof(Vector3)) {
Vector3 newValue = EditorGUILayout.Vector3Field(input.Name, op.GetValue<Vector3>(input));
op.SetValue<Vector3>(input, newValue);
}
// Unsupported
else {
EditorGUILayout.LabelField(input.Name, input.DataType.ToString());
}
}
if (GUILayout.Button("Delete Selection")) {
foreach (var node in GraphEditor.Selection.Nodes) {
GraphEditor.Template.RemoveOperator(node.Operator);
}
GraphEditor.Selection.Clear();
}
}