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; }
public BTInputProperty(string propertyName, string type) { PropertyName = propertyName; TypeName = type; InputData = DevilCfg.DefaultTypeValue(TypeName); DefaultValue = InputData; }
public void ParseData(string data) { if (Properties.Length > 0) { JObject obj = JsonConvert.DeserializeObject <JObject>(data); if (obj != null) { for (int i = 0; i < Properties.Length; i++) { Properties[i].InputData = DevilCfg.ReguexTypeValue(Properties[i].TypeName, obj.Value <string>(Properties[i].PropertyName), Properties[i].DefaultValue); } } } UpdatePropertiesInfo(); }
public static void OnUnityLoaded() { IsInited = false; DevilEditorUtility.ReleaseCache(); titleStyle.alignment = TextAnchor.MiddleCenter; titleStyle.richText = true; titleStyle.fontSize = 13; titleStyle.wordWrap = false; titleStyle.fontStyle = FontStyle.Bold; titleStyle.normal.textColor = Color.green; titleStyle.onHover.textColor = Color.yellow; contentStyle.alignment = TextAnchor.MiddleCenter; contentStyle.richText = true; contentStyle.fontSize = 10; contentStyle.wordWrap = false; contentStyle.fontStyle = FontStyle.Normal; contentStyle.normal.textColor = Color.white; contentStyle.onHover.textColor = Color.white; string txt = "ABCDEFG"; Vector2 size = SizeOfTitle(txt); TitleHeight = size.y; size = SizeOfContent(txt); ContentHeight = size.y; EditorPrefs.SetBool("Devil.Editor.first", false); string[] assets = AssetDatabase.FindAssets("t:script Installizer"); string ends = "/DevilFramework/Editor/Installizer.cs"; foreach (string s in assets) { string path = AssetDatabase.GUIDToAssetPath(s); if (path.EndsWith(ends)) { path = path.Substring(0, path.Length - ends.Length); EditorPrefs.SetString("Devil.Root", path); InstallRoot = path; Debug.Log("Devil Framework install at path: " + path); } } DevilCfg.LoadConfiguration(); BehaviourModuleManager.GetOrNewInstance().Load(); IsInited = true; OnReloaded(); }
void LoadModules() { XmlElement cfg = DevilCfg.CfgAtPath("behaviour-category"); XmlElement child = cfg == null ? null : cfg.FirstChild as XmlElement; Color c; while (child != null) { if (ColorUtility.TryParseHtmlString(DevilCfg.CfgValue("color", "#404040", child), out c)) { mCategoryStyle[child.Name] = c; } child = child.NextSibling as XmlElement; } mModules.Clear(); mComposites.Clear(); mDecorators.Clear(); string[] scripts = AssetDatabase.FindAssets("t:script", DevilCfg.AIImportFolder); foreach (string guid in scripts) { string path = AssetDatabase.GUIDToAssetPath(guid); ParseAILibs(path); } GlobalUtil.Sort(mModules, (x, y) => x.Category.CompareTo(y.Category) * 10000 + (x.SortOrder - y.SortOrder)); string dcate = null; string ccate = null; for (int i = 0; i < mModules.Count; i++) { BehaviourMeta meta = mModules[i]; if (meta.NodeType == EBTNodeType.condition || meta.NodeType == EBTNodeType.service) { mDecorators.Add(meta); if (dcate != meta.Category) { dcate = meta.Category; } } else { mComposites.Add(meta); if (ccate != meta.Category) { ccate = meta.Category; } } } }
public bool ReguexData() { if (mIsDataDirty) { mIsDataDirty = false; string reg = DevilCfg.ReguexTypeValue(TypeName, mInputData, DefaultValue); bool dirty = reg != mInputData; if (dirty) { mInputData = reg; } else { DefaultValue = reg; } return(dirty); } else { return(false); } }