private void LoadTaskIcon() { Texture2D _icon = null; if (mEditorNode.mNode.GetType().IsSubclassOf(typeof(BTAction))) { _icon = BTEditorUtility.LoadTexture("ActionIcon.png"); } else { Type type = mEditorNode.mNode.GetType(); if (type == typeof(BTPrioritySelector)) { _icon = BTEditorUtility.PrioritySelectorIcon; } else if (type == typeof(BTNonePrioritySelector)) { _icon = BTEditorUtility.PrioritySelectorIcon; } else if (type == typeof(BTSequence)) { _icon = BTEditorUtility.SequenceIcon; } else if (type == typeof(BTParallel)) { _icon = BTEditorUtility.ParallelSelectorIcon; } else { _icon = BTEditorUtility.InverterIcon; } } mIcon = _icon; }
void DrawValue(BTNode _node, FieldInfo _field) { if (_field == null) { return; } try { GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(BTEditorUtility.SplitCamelCase(_field.Name) + ":", new GUILayoutOption[] { GUILayout.Width(100) }); if (_field.FieldType == typeof(int)) { var _val = EditorGUILayout.IntField((int)(_field.GetValue(_node))); _field.SetValue(_node, _val); } else if (_field.FieldType == typeof(float)) { var _val = EditorGUILayout.FloatField((float)(_field.GetValue(_node))); _field.SetValue(_node, _val); } else if (_field.FieldType == typeof(double)) { var _val = EditorGUILayout.DoubleField((float)(_field.GetValue(_node))); _field.SetValue(_node, _val); } else if (_field.FieldType == typeof(string)) { var _val = EditorGUILayout.TextField((string)(_field.GetValue(_node))); _field.SetValue(_node, _val); } else if (_field.FieldType.IsEnum) { var _val = EditorGUILayout.EnumPopup((Enum)(_field.GetValue(_node))); _field.SetValue(_node, _val); } else if (_field.FieldType == typeof(Vector2)) { var _val = EditorGUILayout.Vector2Field("", (Vector2)(_field.GetValue(_node))); _field.SetValue(_node, _val); } else if (_field.FieldType == typeof(Vector3)) { var _val = EditorGUILayout.Vector3Field("", (Vector3)(_field.GetValue(_node))); _field.SetValue(_node, _val); } else if (_field.FieldType == typeof(Vector4)) { var _val = EditorGUILayout.Vector4Field("", (Vector4)(_field.GetValue(_node))); _field.SetValue(_node, _val); } GUILayout.EndHorizontal(); } catch (Exception e) { Debugger.LogWarning(e.Message); } }