public BTInputProperty(FieldInfo field, BTVariableAttribute attr) { if (string.IsNullOrEmpty(attr.Name)) { PropertyName = field.Name; } else { PropertyName = attr.Name; } if (string.IsNullOrEmpty(attr.TypePattern)) { TypeName = field.FieldType.Name; } else { TypeName = attr.TypePattern; } if (string.IsNullOrEmpty(attr.DefaultVallue)) { DefaultValue = DevilCfg.DefaultTypeValue(TypeName); } else { DefaultValue = attr.DefaultVallue; } InputData = DefaultValue; }
void GetPopNames(SerializedProperty property, BTVariableAttribute attr) { mVars.Clear(); var black = BehaviourTreeEditor.UsingBlackboard; if (attr != null && black != null) { for (int i = 0; i < black.Length; i++) { var v = black[i]; if (attr.VarClass != null) { if (attr.VarClass.FullName != v.typeDef) { continue; } if (attr.VarType == EVarType.List && !v.isList) { continue; } if (attr.VarType == EVarType.Variable && v.isList) { continue; } } mVars.Add(v); } } var len = mVars.Count + 1; AllocSize(len); mSelectedIndex = 0; if (attr.VarClass == null) { mPopNames[0].text = "[自定义]"; } else { mPopNames[0].text = string.Format("[自定义 {0} {1}]", attr.VarType, attr.VarClass.Name); } for (int i = 1; i < len; i++) { mPopNames[i].text = mVars[i - 1].name; if (Prop(p_name).stringValue == mPopNames[i].text) { mSelectedIndex = i; } } var id = property.serializedObject.targetObject.GetInstanceID(); if (id != pid) { pid = id; mCusCache = Prop(p_name).stringValue; } }
public BehaviourMeta(System.Type target) { //TargetType = target; Name = target.Name; DisplayName = Name; Namespace = target.Namespace; string iconPath = ""; if (target.IsSubclassOf(typeof(BTNodeBase))) { NodeType = EBTNodeType.controller; Category = "Composite"; iconPath = Installizer.InstallRoot + "/DevilFramework/Editor/Icons/composite.png"; } else if (target.IsSubclassOf(typeof(BTTaskBase))) { NodeType = EBTNodeType.task; Category = "Task"; iconPath = Installizer.InstallRoot + "/DevilFramework/Editor/Icons/task.png"; } else if (target.IsSubclassOf(typeof(BTConditionBase))) { NodeType = EBTNodeType.condition; Category = "Condition"; iconPath = Installizer.InstallRoot + "/DevilFramework/Editor/Icons/condition.png"; } else if (target.IsSubclassOf(typeof(BTServiceBase))) { NodeType = EBTNodeType.service; Category = "Service"; iconPath = Installizer.InstallRoot + "/DevilFramework/Editor/Icons/service.png"; } else { NodeType = EBTNodeType.invalid; Category = "Invalid"; } BTCompositeAttribute attr = Ref.GetCustomAttribute <BTCompositeAttribute>(target); if (attr != null) { if (!string.IsNullOrEmpty(attr.Title)) { DisplayName = attr.Title; } if (!string.IsNullOrEmpty(attr.Detail)) { SubTitle = attr.Detail; } if (!string.IsNullOrEmpty(attr.IconPath)) { iconPath = attr.IconPath; } if (!string.IsNullOrEmpty(attr.Category)) { Category = attr.Category; } HideProperty = attr.HideProperty; } FieldInfo[] fields = target.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); List <BTInputProperty> propperties = new List <BTInputProperty>(); for (int i = 0; i < fields.Length; i++) { BTVariableAttribute vatt = Ref.GetCustomAttribute <BTVariableAttribute>(fields[i]); if (vatt != null) { BTInputProperty pro = new BTInputProperty(fields[i], vatt); propperties.Add(pro); } } Icon = DevilEditorUtility.GetTexture(iconPath); Properties = propperties.ToArray(); NotDisplayName = string.Format("<b><color=yellow>NOT</color></b> {0}", DisplayName); SearchName = Name.ToLower() + " " + DisplayName.ToLower(); color = BehaviourModuleManager.GetOrNewInstance().GetCategoryColor(Category); }