private void LoadTaskIcon() { mTask.NodeData.Icon = null; TaskIconAttribute[] array; if ((array = (mTask.GetType().GetCustomAttributes(typeof(TaskIconAttribute), false) as TaskIconAttribute[])).Length > 0) { mTask.NodeData.Icon = BehaviorDesignerUtility.LoadIcon(array[0].IconPath); } if (mTask.NodeData.Icon == null) { string iconName = string.Empty; if (mTask.GetType().IsSubclassOf(typeof(Runtime.Tasks.Action))) { iconName = "{SkinColor}ActionIcon"; } else if (mTask.GetType().IsSubclassOf(typeof(Conditional))) { iconName = "{SkinColor}ConditionalIcon"; } else if (mTask.GetType().IsSubclassOf(typeof(Composite))) { iconName = "{SkinColor}CompositeIcon"; } else if (mTask.GetType().IsSubclassOf(typeof(Decorator))) { iconName = "{SkinColor}DecoratorIcon"; } else { iconName = "{SkinColor}EntryIcon"; } mTask.NodeData.Icon = BehaviorDesignerUtility.LoadIcon(iconName); } }
// Token: 0x06000150 RID: 336 RVA: 0x0000BAE4 File Offset: 0x00009CE4 public static void Save(BehaviorSource behaviorSource) { BinarySerialization.fieldIndex = 0; BinarySerialization.taskSerializationData = new TaskSerializationData(); BinarySerialization.fieldSerializationData = BinarySerialization.taskSerializationData.fieldSerializationData; if (behaviorSource.Variables != null) { for (int i = 0; i < behaviorSource.Variables.Count; i++) { BinarySerialization.taskSerializationData.variableStartIndex.Add(BinarySerialization.fieldSerializationData.startIndex.Count); BinarySerialization.SaveSharedVariable(behaviorSource.Variables[i], 0); } } if (!object.ReferenceEquals(behaviorSource.EntryTask, null)) { BinarySerialization.SaveTask(behaviorSource.EntryTask, -1); } if (!object.ReferenceEquals(behaviorSource.RootTask, null)) { BinarySerialization.SaveTask(behaviorSource.RootTask, 0); } if (behaviorSource.DetachedTasks != null) { for (int j = 0; j < behaviorSource.DetachedTasks.Count; j++) { BinarySerialization.SaveTask(behaviorSource.DetachedTasks[j], -1); } } BinarySerialization.taskSerializationData.Version = "1.5.7"; behaviorSource.TaskData = BinarySerialization.taskSerializationData; if (behaviorSource.Owner != null && !behaviorSource.Owner.Equals(null)) { BehaviorDesignerUtility.SetObjectDirty(behaviorSource.Owner.GetObject()); } }
private static bool AddVariable(IVariableSource variableSource, string variableName, int variableTypeIndex, bool fromGlobalVariablesWindow) { SharedVariable item = VariableInspector.CreateVariable(variableTypeIndex, variableName, fromGlobalVariablesWindow); List <SharedVariable> list = (variableSource == null) ? null : variableSource.GetAllVariables(); if (list == null) { list = new List <SharedVariable>(); } list.Add(item); GUI.FocusControl("Add"); if (fromGlobalVariablesWindow && variableSource == null) { GlobalVariables globalVariables = ScriptableObject.CreateInstance(typeof(GlobalVariables)) as GlobalVariables; string text = BehaviorDesignerUtility.GetEditorBaseDirectory(null).Substring(6, BehaviorDesignerUtility.GetEditorBaseDirectory(null).Length - 13); string str = text + "/Resources/BehaviorDesignerGlobalVariables.asset"; if (!Directory.Exists(Application.dataPath + text + "/Resources")) { Directory.CreateDirectory(Application.dataPath + text + "/Resources"); } if (!File.Exists(Application.dataPath + str)) { AssetDatabase.CreateAsset(globalVariables, "Assets" + str); EditorUtility.DisplayDialog("Created Global Variables", "Behavior Designer Global Variables asset created:\n\nAssets" + text + "/Resources/BehaviorDesignerGlobalVariables.asset\n\nNote: Copy this file to transfer global variables between projects.", "OK"); } variableSource = globalVariables; } variableSource.SetAllVariables(list); return(true); }
private void DrawSynchronizedVariables(VariableSynchronizer variableSynchronizer) { GUI.enabled = (true); if (variableSynchronizer.SynchronizedVariables == null || variableSynchronizer.SynchronizedVariables.Count == 0) { return; } Rect lastRect = GUILayoutUtility.GetLastRect(); lastRect.x = (-5f); lastRect.y = (lastRect.y + (lastRect.height + 1f)); lastRect.height = (2f); lastRect.width = (lastRect.width + 20f); GUI.DrawTexture(lastRect, BehaviorDesignerUtility.LoadTexture("ContentSeparator", true)); GUILayout.Space(6f); for (int i = 0; i < variableSynchronizer.SynchronizedVariables.Count; i++) { VariableSynchronizer.SynchronizedVariable synchronizedVariable = variableSynchronizer.SynchronizedVariables[i]; if (synchronizedVariable.global) { if (GlobalVariables.Instance.GetVariable(synchronizedVariable.variableName) == null) { variableSynchronizer.SynchronizedVariables.RemoveAt(i); break; } } else if (synchronizedVariable.behavior.GetVariable(synchronizedVariable.variableName) == null) { variableSynchronizer.SynchronizedVariables.RemoveAt(i); break; } EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.LabelField(synchronizedVariable.variableName, new GUILayoutOption[] { GUILayout.MaxWidth(120f) }); if (GUILayout.Button(BehaviorDesignerUtility.LoadTexture((!synchronizedVariable.setVariable) ? "RightArrowButton" : "LeftArrowButton", true), BehaviorDesignerUtility.ButtonGUIStyle, new GUILayoutOption[] { GUILayout.Width(22f) }) && !Application.isPlaying) { synchronizedVariable.setVariable = !synchronizedVariable.setVariable; } EditorGUILayout.LabelField(string.Format("{0} ({1})", synchronizedVariable.targetName, synchronizedVariable.synchronizationType.ToString()), new GUILayoutOption[] { GUILayout.MinWidth(120f) }); GUILayout.FlexibleSpace(); if (GUILayout.Button(BehaviorDesignerUtility.LoadTexture("DeleteButton.png", true), BehaviorDesignerUtility.ButtonGUIStyle, new GUILayoutOption[] { GUILayout.Width(22f) })) { variableSynchronizer.SynchronizedVariables.RemoveAt(i); EditorGUILayout.EndHorizontal(); break; } GUILayout.Space(2f); EditorGUILayout.EndHorizontal(); GUILayout.Space(2f); } GUILayout.Space(4f); }
private void CalculateNodeCommentRect(Rect nodeRect) { bool flag = false; if (mTask.NodeData.WatchedFields != null && this.mTask.NodeData.WatchedFields.Count > 0) { string text = string.Empty; string text2 = string.Empty; for (int i = 0; i < this.mTask.NodeData.WatchedFields.Count; i++) { FieldInfo fieldInfo = this.mTask.NodeData.WatchedFields[i]; text = text + BehaviorDesignerUtility.SplitCamelCase(fieldInfo.Name) + ": \n"; text2 = text2 + ((fieldInfo.GetValue(this.mTask) == null) ? "null" : fieldInfo.GetValue(this.mTask).ToString()) + "\n"; } float num; float num2; BehaviorDesignerUtility.TaskCommentGUIStyle.CalcMinMaxWidth(new GUIContent(text), out num, out num2); float num3; BehaviorDesignerUtility.TaskCommentGUIStyle.CalcMinMaxWidth(new GUIContent(text2), out num, out num3); float num4 = num2; float num5 = num3; float num6 = Mathf.Min(220f, num2 + num3 + 20f); if (num6 == 220f) { num4 = num2 / (num2 + num3) * 220f; num5 = num3 / (num2 + num3) * 220f; } this.watchedFieldRect = new Rect(nodeRect.xMax + 4f, nodeRect.y, num6 + 8f, nodeRect.height); this.watchedFieldNamesRect = new Rect(nodeRect.xMax + 6f, nodeRect.y + 4f, num4, nodeRect.height - 8f); this.watchedFieldValuesRect = new Rect(nodeRect.xMax + 6f + num4, nodeRect.y + 4f, num5, nodeRect.height - 8f); flag = true; } if (!this.mTask.NodeData.Comment.Equals(string.Empty)) { if (this.isParent) { float num7; float num8; BehaviorDesignerUtility.TaskCommentGUIStyle.CalcMinMaxWidth(new GUIContent(this.mTask.NodeData.Comment), out num7, out num8); float num9 = Mathf.Min(220f, num8 + 20f); if (flag) { this.commentRect = new Rect(nodeRect.xMin - 12f - num9, nodeRect.y, num9 + 8f, nodeRect.height); this.commentLabelRect = new Rect(nodeRect.xMin - 6f - num9, nodeRect.y + 4f, num9, nodeRect.height - 8f); } else { this.commentRect = new Rect(nodeRect.xMax + 4f, nodeRect.y, num9 + 8f, nodeRect.height); this.commentLabelRect = new Rect(nodeRect.xMax + 6f, nodeRect.y + 4f, num9, nodeRect.height - 8f); } } else { float num10 = Mathf.Min(100f, BehaviorDesignerUtility.TaskCommentGUIStyle.CalcHeight(new GUIContent(this.mTask.NodeData.Comment), nodeRect.width - 4f)); this.commentRect = new Rect(nodeRect.x, nodeRect.yMax + 4f, nodeRect.width, num10 + 4f); this.commentLabelRect = new Rect(nodeRect.x, nodeRect.yMax + 4f, nodeRect.width - 4f, num10); } } }
public void OnGUI() { this.mScrollPosition = EditorGUILayout.BeginScrollView(this.mScrollPosition, new GUILayoutOption[0]); if (this.mErrorDetails != null && this.mErrorDetails.Count > 0) { for (int i = 0; i < this.mErrorDetails.Count; i++) { ErrorDetails errorDetails = this.mErrorDetails[i]; if (errorDetails != null && !(errorDetails.NodeDesigner == null) && errorDetails.NodeDesigner.Task != null) { string text = string.Empty; switch (errorDetails.Type) { case BehaviorDesigner.Editor.ErrorDetails.ErrorType.RequiredField: text = string.Format("The task {0} ({1}, index {2}) requires a value for the field {3}.", new object[] { errorDetails.TaskFriendlyName, errorDetails.TaskType, errorDetails.NodeDesigner.Task.ID, BehaviorDesignerUtility.SplitCamelCase(errorDetails.FieldName) }); break; case BehaviorDesigner.Editor.ErrorDetails.ErrorType.SharedVariable: text = string.Format("The task {0} ({1}, index {2}) has a Shared Variable field ({3}) that is marked as shared but is not referencing a Shared Variable.", new object[] { errorDetails.TaskFriendlyName, errorDetails.TaskType, errorDetails.NodeDesigner.Task.ID, BehaviorDesignerUtility.SplitCamelCase(errorDetails.FieldName) }); break; case BehaviorDesigner.Editor.ErrorDetails.ErrorType.MissingChildren: text = string.Format("The {0} task ({1}, index {2}) is a parent task which does not have any children", errorDetails.TaskFriendlyName, errorDetails.TaskType, errorDetails.NodeDesigner.Task.ID); break; case BehaviorDesigner.Editor.ErrorDetails.ErrorType.UnknownTask: text = string.Format("The task at index {0} is unknown. Has a task been renamed or deleted?", errorDetails.NodeDesigner.Task.ID); break; } EditorGUILayout.LabelField(text, (i % 2 != 0) ? BehaviorDesignerUtility.ErrorListDarkBackground : BehaviorDesignerUtility.ErrorListLightBackground, new GUILayoutOption[] { GUILayout.Height(30f), GUILayout.Width((float)(Screen.width - 7)) }); } } } else if (!BehaviorDesignerPreferences.GetBool(BDPreferences.ErrorChecking)) { EditorGUILayout.LabelField("Enable realtime error checking from the preferences to view the errors.", BehaviorDesignerUtility.ErrorListLightBackground, new GUILayoutOption[0]); } else { EditorGUILayout.LabelField("The behavior tree has no errors.", BehaviorDesignerUtility.ErrorListLightBackground, new GUILayoutOption[0]); } EditorGUILayout.EndScrollView(); }
public void OnEnable() { this.m_WelcomeScreenImage = BehaviorDesignerUtility.LoadTexture("WelcomeScreenHeader.png", false, this); this.m_SamplesImage = BehaviorDesignerUtility.LoadIcon("WelcomeScreenSamplesIcon.png", this); this.m_DocImage = BehaviorDesignerUtility.LoadIcon("WelcomeScreenDocumentationIcon.png", this); this.m_VideoImage = BehaviorDesignerUtility.LoadIcon("WelcomeScreenVideosIcon.png", this); this.m_ForumImage = BehaviorDesignerUtility.LoadIcon("WelcomeScreenForumIcon.png", this); this.m_ContactImage = BehaviorDesignerUtility.LoadIcon("WelcomeScreenContactIcon.png", this); }
private static void ExportTexture(string path, bool skin = false) { var icon = BehaviorDesignerUtility.LoadTexture(path, skin); if (icon != null) { //icon.Resize (16, 16, TextureFormat.ARGB32, false); var data = icon.EncodeToPNG(); File.WriteAllBytes("Assets/DebugSystem/Icons/" + path, data); AssetDatabase.Refresh(); } }
private void Init() { taskName = BehaviorDesignerUtility.SplitCamelCase(mTask.GetType().Name.ToString()); isParent = mTask.GetType().IsSubclassOf(typeof(ParentTask)); if (isParent) { outgoingNodeConnections = new List <NodeConnection>(); } mRectIsDirty = (mCacheIsDirty = true); mIncomingRectIsDirty = true; mOutgoingRectIsDirty = true; }
// Token: 0x06000185 RID: 389 RVA: 0x0000D694 File Offset: 0x0000B894 public override void OnInspectorGUI() { ExternalBehavior externalBehavior = this.target as ExternalBehavior; if (externalBehavior == null) { return; } if (ExternalBehaviorInspector.DrawInspectorGUI(externalBehavior.BehaviorSource, true, ref this.mShowVariables)) { BehaviorDesignerUtility.SetObjectDirty(externalBehavior); } }
public Vector2 GetAbsolutePosition() { Vector2 vector = this.mTask.NodeData.Offset; if (this.parentNodeDesigner != null) { vector += this.parentNodeDesigner.GetAbsolutePosition(); } if (BehaviorDesignerPreferences.GetBool(BDPreferences.SnapToGrid)) { vector.Set(BehaviorDesignerUtility.RoundToNearest(vector.x, 10f), BehaviorDesignerUtility.RoundToNearest(vector.y, 10f)); } return(vector); }
private static void SaveFields(object obj, string namePrefix) { FieldInfo[] allFields = TaskUtility.GetAllFields(obj.GetType()); for (int i = 0; i < allFields.Length; i++) { if (!BehaviorDesignerUtility.HasAttribute(allFields[i], typeof(NonSerializedAttribute)) && ((!allFields[i].IsPrivate && !allFields[i].IsFamily) || BehaviorDesignerUtility.HasAttribute(allFields[i], typeof(SerializeField))) && (!(obj is ParentTask) || !allFields[i].Name.Equals("children"))) { object value = allFields[i].GetValue(obj); if (!object.ReferenceEquals(value, null)) { BinarySerialization.SaveField(allFields[i].FieldType, namePrefix + allFields[i].Name, value, allFields[i]); } } } }
private static Texture2D LoadTaskTexture(string imageName) { if (BehaviorDesignerUtility.textureCache.ContainsKey(imageName)) { return(BehaviorDesignerUtility.textureCache[imageName]); } Texture2D texture2D = null; Stream rStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(imageName); texture2D = new Texture2D(0, 0, TextureFormat.RGBA32, false, true); texture2D.LoadImage(BehaviorDesignerUtility.ReadToEnd(rStream)); texture2D.hideFlags = HideFlags.HideAndDontSave; return(texture2D); }
// Token: 0x060001F5 RID: 501 RVA: 0x0001253C File Offset: 0x0001073C public static void Save(GlobalVariables variables) { if (variables == null) { return; } JSONSerialization.variableSerializationData = new VariableSerializationData(); JSONSerialization.fieldSerializationData = JSONSerialization.variableSerializationData.fieldSerializationData; Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary.Add("Variables", JSONSerialization.SerializeVariables(variables.Variables, ref JSONSerialization.fieldSerializationData.unityObjects)); JSONSerialization.variableSerializationData.JSONSerialization = MiniJSON.Serialize(dictionary); variables.VariableData = JSONSerialization.variableSerializationData; variables.Version = "1.5.7"; BehaviorDesignerUtility.SetObjectDirty(variables); }
public void DrawTaskList(BehaviorDesignerWindow window, bool enabled) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUI.SetNextControlName("Search"); string value = GUILayout.TextField(this.mSearchString, GUI.skin.FindStyle("ToolbarSeachTextField"), new GUILayoutOption[0]); if (this.mFocusSearch) { GUI.FocusControl("Search"); this.mFocusSearch = false; } if (!this.mSearchString.Equals(value)) { this.mSearchString = value; this.Search(BehaviorDesignerUtility.SplitCamelCase(this.mSearchString).ToLower().Replace(" ", string.Empty), this.mCategoryList); } if (GUILayout.Button(string.Empty, (!this.mSearchString.Equals(string.Empty)) ? GUI.skin.FindStyle("ToolbarSeachCancelButton") : GUI.skin.FindStyle("ToolbarSeachCancelButtonEmpty"), new GUILayoutOption[0])) { this.mSearchString = string.Empty; this.Search(string.Empty, this.mCategoryList); GUI.FocusControl(null); } GUILayout.EndHorizontal(); BehaviorDesignerUtility.DrawContentSeperator(2); GUILayout.Space(4f); this.mScrollPosition = GUILayout.BeginScrollView(this.mScrollPosition, new GUILayoutOption[0]); GUI.enabled = (enabled); if (this.mCategoryList.Count > 1) { this.DrawCategory(window, this.mCategoryList[1]); } if (this.mCategoryList.Count > 3) { this.DrawCategory(window, this.mCategoryList[3]); } if (this.mCategoryList.Count > 0) { this.DrawCategory(window, this.mCategoryList[0]); } if (this.mCategoryList.Count > 2) { this.DrawCategory(window, this.mCategoryList[2]); } GUI.enabled = (true); GUILayout.EndScrollView(); }
// Token: 0x06000147 RID: 327 RVA: 0x0000B4B4 File Offset: 0x000096B4 public override void OnInspectorGUI() { Behavior behavior = this.target as Behavior; if (behavior == null) { return; } bool flag = false; if (BehaviorInspector.DrawInspectorGUI(behavior, base.serializedObject, true, ref flag, ref this.mShowOptions, ref this.mShowVariables)) { BehaviorDesignerUtility.SetObjectDirty(behavior); if (flag && BehaviorDesignerWindow.instance != null && behavior.GetBehaviorSource().BehaviorID == BehaviorDesignerWindow.instance.ActiveBehaviorID) { BehaviorDesignerWindow.instance.LoadBehavior(behavior.GetBehaviorSource(), false, false); } } }
public static object DrawFields(Task task, object obj, GUIContent guiContent) { if (obj == null) { return(null); } List <Type> baseClasses = FieldInspector.GetBaseClasses(obj.GetType()); BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; for (int i = baseClasses.Count - 1; i > -1; i--) { FieldInfo[] fields = baseClasses[i].GetFields(bindingAttr); for (int j = 0; j < fields.Length; j++) { if (!BehaviorDesignerUtility.HasAttribute(fields[j], typeof(NonSerializedAttribute)) && !BehaviorDesignerUtility.HasAttribute(fields[j], typeof(HideInInspector)) && ((!fields[j].IsPrivate && !fields[j].IsFamily) || BehaviorDesignerUtility.HasAttribute(fields[j], typeof(SerializeField))) && (!(obj is ParentTask) || !fields[j].Name.Equals("children"))) { if (guiContent == null) { string name = fields[j].Name; BehaviorDesigner.Runtime.Tasks.TooltipAttribute[] array; if ((array = (fields[j].GetCustomAttributes(typeof(BehaviorDesigner.Runtime.Tasks.TooltipAttribute), false) as BehaviorDesigner.Runtime.Tasks.TooltipAttribute[])).Length > 0) { guiContent = new GUIContent(BehaviorDesignerUtility.SplitCamelCase(name), array[0].Tooltip); } else { guiContent = new GUIContent(BehaviorDesignerUtility.SplitCamelCase(name)); } } EditorGUI.BeginChangeCheck(); object value = FieldInspector.DrawField(task, guiContent, fields[j], fields[j].GetValue(obj)); if (EditorGUI.EndChangeCheck()) { fields[j].SetValue(obj, value); GUI.changed = true; } guiContent = null; } } } return(obj); }
// Token: 0x06000151 RID: 337 RVA: 0x0000BC20 File Offset: 0x00009E20 public static void Save(GlobalVariables globalVariables) { if (globalVariables == null) { return; } BinarySerialization.fieldIndex = 0; globalVariables.VariableData = new VariableSerializationData(); if (globalVariables.Variables == null || globalVariables.Variables.Count == 0) { return; } BinarySerialization.fieldSerializationData = globalVariables.VariableData.fieldSerializationData; for (int i = 0; i < globalVariables.Variables.Count; i++) { globalVariables.VariableData.variableStartIndex.Add(BinarySerialization.fieldSerializationData.startIndex.Count); BinarySerialization.SaveSharedVariable(globalVariables.Variables[i], 0); } globalVariables.Version = "1.5.7"; BehaviorDesignerUtility.SetObjectDirty(globalVariables); }
private bool Search(string searchString, List <TaskList.CategoryList> categoryList) { bool result = searchString.Equals(string.Empty); for (int i = 0; i < categoryList.Count; i++) { bool flag = false; categoryList[i].Visible = false; if (categoryList[i].Subcategories != null && this.Search(searchString, categoryList[i].Subcategories)) { categoryList[i].Visible = true; result = true; } if (BehaviorDesignerUtility.SplitCamelCase(categoryList[i].Name).ToLower().Replace(" ", string.Empty).Contains(searchString)) { result = true; flag = true; categoryList[i].Visible = true; if (categoryList[i].Subcategories != null) { this.MarkVisible(categoryList[i].Subcategories); } } if (categoryList[i].Tasks != null) { for (int j = 0; j < categoryList[i].Tasks.Count; j++) { categoryList[i].Tasks[j].Visible = searchString.Equals(string.Empty); if (flag || categoryList[i].Tasks[j].Name.ToLower().Replace(" ", string.Empty).Contains(searchString)) { categoryList[i].Tasks[j].Visible = true; result = true; categoryList[i].Visible = true; } } } } return(result); }
public void DrawNodeComment(Vector2 offset) { if (this.mTask.NodeData.Comment.Length != this.prevCommentLength) { this.prevCommentLength = this.mTask.NodeData.Comment.Length; this.mRectIsDirty = true; } if (this.mTask.NodeData.WatchedFields != null && this.mTask.NodeData.WatchedFields.Count != this.prevWatchedFieldsLength) { this.prevWatchedFieldsLength = this.mTask.NodeData.WatchedFields.Count; this.mRectIsDirty = true; } if (this.mTask.NodeData.Comment.Equals(string.Empty) && (this.mTask.NodeData.WatchedFields == null || this.mTask.NodeData.WatchedFields.Count == 0)) { return; } if (this.mTask.NodeData.WatchedFields != null && this.mTask.NodeData.WatchedFields.Count > 0) { string text = string.Empty; string text2 = string.Empty; for (int i = 0; i < this.mTask.NodeData.WatchedFields.Count; i++) { FieldInfo fieldInfo = this.mTask.NodeData.WatchedFields[i]; text = text + BehaviorDesignerUtility.SplitCamelCase(fieldInfo.Name) + ": \n"; text2 = text2 + ((fieldInfo.GetValue(this.mTask) == null) ? "null" : fieldInfo.GetValue(this.mTask).ToString()) + "\n"; } GUI.Box(this.watchedFieldRect, string.Empty, BehaviorDesignerUtility.TaskDescriptionGUIStyle); GUI.Label(this.watchedFieldNamesRect, text, BehaviorDesignerUtility.TaskCommentRightAlignGUIStyle); GUI.Label(this.watchedFieldValuesRect, text2, BehaviorDesignerUtility.TaskCommentLeftAlignGUIStyle); } if (!this.mTask.NodeData.Comment.Equals(string.Empty)) { GUI.Box(this.commentRect, string.Empty, BehaviorDesignerUtility.TaskDescriptionGUIStyle); GUI.Label(this.commentLabelRect, this.mTask.NodeData.Comment, BehaviorDesignerUtility.TaskCommentGUIStyle); } }
// Token: 0x060001F4 RID: 500 RVA: 0x000123A8 File Offset: 0x000105A8 public static void Save(BehaviorSource behaviorSource) { behaviorSource.CheckForSerialization(false, null); JSONSerialization.taskSerializationData = new TaskSerializationData(); JSONSerialization.fieldSerializationData = JSONSerialization.taskSerializationData.fieldSerializationData; Dictionary <string, object> dictionary = new Dictionary <string, object>(); if (behaviorSource.EntryTask != null) { dictionary.Add("EntryTask", JSONSerialization.SerializeTask(behaviorSource.EntryTask, true, ref JSONSerialization.fieldSerializationData.unityObjects)); } if (behaviorSource.RootTask != null) { dictionary.Add("RootTask", JSONSerialization.SerializeTask(behaviorSource.RootTask, true, ref JSONSerialization.fieldSerializationData.unityObjects)); } if (behaviorSource.DetachedTasks != null && behaviorSource.DetachedTasks.Count > 0) { Dictionary <string, object>[] array = new Dictionary <string, object> [behaviorSource.DetachedTasks.Count]; for (int i = 0; i < behaviorSource.DetachedTasks.Count; i++) { array[i] = JSONSerialization.SerializeTask(behaviorSource.DetachedTasks[i], true, ref JSONSerialization.fieldSerializationData.unityObjects); } dictionary.Add("DetachedTasks", array); } if (behaviorSource.Variables != null && behaviorSource.Variables.Count > 0) { dictionary.Add("Variables", JSONSerialization.SerializeVariables(behaviorSource.Variables, ref JSONSerialization.fieldSerializationData.unityObjects)); } JSONSerialization.taskSerializationData.Version = "1.5.7"; JSONSerialization.taskSerializationData.JSONSerialization = MiniJSON.Serialize(dictionary); behaviorSource.TaskData = JSONSerialization.taskSerializationData; if (behaviorSource.Owner != null && !behaviorSource.Owner.Equals(null)) { BehaviorDesignerUtility.SetObjectDirty(behaviorSource.Owner.GetObject()); } }
private static bool DrawHeader(IVariableSource variableSource, bool fromGlobalVariablesWindow, ref float variableStartPosition, ref string variableName, ref bool focusNameField, ref int variableTypeIndex, ref int selectedVariableIndex, ref string selectedVariableName, ref int selectedVariableTypeIndex) { if (VariableInspector.sharedVariableStrings == null) { VariableInspector.FindAllSharedVariableTypes(true); } EditorGUIUtility.labelWidth = 150f; GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(4f); EditorGUILayout.LabelField("Name", new GUILayoutOption[] { GUILayout.Width(70f) }); GUI.SetNextControlName("Name"); variableName = EditorGUILayout.TextField(variableName, new GUILayoutOption[] { GUILayout.Width(212f) }); if (focusNameField) { GUI.FocusControl("Name"); focusNameField = false; } GUILayout.EndHorizontal(); GUILayout.Space(2f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(4f); GUILayout.Label("Type", new GUILayoutOption[] { GUILayout.Width(70f) }); variableTypeIndex = EditorGUILayout.Popup(variableTypeIndex, VariableInspector.sharedVariableStrings, EditorStyles.toolbarPopup, new GUILayoutOption[] { GUILayout.Width(163f) }); GUILayout.Space(8f); bool flag = false; bool flag2 = VariableInspector.VariableNameValid(variableSource, variableName); bool enabled = GUI.enabled; GUI.enabled = (flag2 && enabled); GUI.SetNextControlName("Add"); if (GUILayout.Button("Add", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(40f) }) && flag2) { flag = VariableInspector.AddVariable(variableSource, variableName, variableTypeIndex, fromGlobalVariablesWindow); if (flag) { selectedVariableIndex = variableSource.GetAllVariables().Count - 1; selectedVariableName = variableName; selectedVariableTypeIndex = variableTypeIndex; variableName = string.Empty; } } GUILayout.Space(6f); GUILayout.EndHorizontal(); if (!fromGlobalVariablesWindow) { GUI.enabled = true; GUILayout.Space(3f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(5f); if (GUILayout.Button("Global Variables", EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(284f) })) { GlobalVariablesWindow.ShowWindow(); } GUILayout.EndHorizontal(); } BehaviorDesignerUtility.DrawContentSeperator(2); GUILayout.Space(4f); if (variableStartPosition == -1f && Event.current.type == EventType.Repaint) { variableStartPosition = GUILayoutUtility.GetLastRect().yMax; } GUI.enabled = enabled; return(flag); }
public bool DrawNode(Vector2 offset, bool drawSelected, bool disabled) { if (drawSelected != this.mSelected) { return(false); } if (ToString().Length != prevFriendlyNameLength) { prevFriendlyNameLength = ToString().Length; mRectIsDirty = true; } Rect rect = Rectangle(offset, false, false); UpdateCache(rect); bool flag = (this.mTask.NodeData.PushTime != -1f && this.mTask.NodeData.PushTime >= this.mTask.NodeData.PopTime) || (this.isEntryDisplay && this.outgoingNodeConnections.Count > 0 && this.outgoingNodeConnections[0].DestinationNodeDesigner.Task.NodeData.PushTime != -1f); bool flag2 = this.mIdentifyUpdateCount != -1; bool result = this.prevRunningState != flag; float num = (!BehaviorDesignerPreferences.GetBool(BDPreferences.FadeNodes)) ? 0.01f : 0.5f; float num2 = 0f; if (flag2) { if (2000 - this.mIdentifyUpdateCount < 500) { num2 = (float)(2000 - this.mIdentifyUpdateCount) / 500f; } else { num2 = 1f; } if (this.mIdentifyUpdateCount != -1) { this.mIdentifyUpdateCount++; if (this.mIdentifyUpdateCount > 2000) { this.mIdentifyUpdateCount = -1; } } result = true; } else if (flag) { num2 = 1f; } else if ((this.mTask.NodeData.PopTime != -1f && num != 0f && Time.realtimeSinceStartup - this.mTask.NodeData.PopTime < num) || (this.isEntryDisplay && this.outgoingNodeConnections.Count > 0 && this.outgoingNodeConnections[0].DestinationNodeDesigner.Task.NodeData.PopTime != -1f && Time.realtimeSinceStartup - this.outgoingNodeConnections[0].DestinationNodeDesigner.Task.NodeData.PopTime < num)) { if (this.isEntryDisplay) { num2 = 1f - (Time.realtimeSinceStartup - this.outgoingNodeConnections[0].DestinationNodeDesigner.Task.NodeData.PopTime) / num; } else { num2 = 1f - (Time.realtimeSinceStartup - this.mTask.NodeData.PopTime) / num; } result = true; } if (!this.isEntryDisplay && !this.prevRunningState && this.parentNodeDesigner != null) { this.parentNodeDesigner.BringConnectionToFront(this); } this.prevRunningState = flag; if (num2 != 1f) { GUI.color = ((!disabled && !this.mTask.NodeData.Disabled) ? Color.white : this.grayColor); GUIStyle backgroundGUIStyle; if (BehaviorDesignerPreferences.GetBool(BDPreferences.CompactMode)) { backgroundGUIStyle = ((!this.mSelected) ? BehaviorDesignerUtility.GetTaskCompactGUIStyle(this.mTask.NodeData.ColorIndex) : BehaviorDesignerUtility.GetTaskSelectedCompactGUIStyle(this.mTask.NodeData.ColorIndex)); } else { backgroundGUIStyle = ((!this.mSelected) ? BehaviorDesignerUtility.GetTaskGUIStyle(this.mTask.NodeData.ColorIndex) : BehaviorDesignerUtility.GetTaskSelectedGUIStyle(this.mTask.NodeData.ColorIndex)); } this.DrawNodeTexture(rect, BehaviorDesignerUtility.GetTaskConnectionTopTexture(this.mTask.NodeData.ColorIndex), BehaviorDesignerUtility.GetTaskConnectionBottomTexture(this.mTask.NodeData.ColorIndex), backgroundGUIStyle, BehaviorDesignerUtility.GetTaskBorderTexture(this.mTask.NodeData.ColorIndex)); } if (num2 > 0f) { GUIStyle backgroundGUIStyle2; Texture2D iconBorderTexture; if (flag2) { if (BehaviorDesignerPreferences.GetBool(BDPreferences.CompactMode)) { if (this.mSelected) { backgroundGUIStyle2 = BehaviorDesignerUtility.TaskIdentifySelectedCompactGUIStyle; } else { backgroundGUIStyle2 = BehaviorDesignerUtility.TaskIdentifyCompactGUIStyle; } } else if (this.mSelected) { backgroundGUIStyle2 = BehaviorDesignerUtility.TaskIdentifySelectedGUIStyle; } else { backgroundGUIStyle2 = BehaviorDesignerUtility.TaskIdentifyGUIStyle; } iconBorderTexture = BehaviorDesignerUtility.TaskBorderIdentifyTexture; } else { if (BehaviorDesignerPreferences.GetBool(BDPreferences.CompactMode)) { if (this.mSelected) { backgroundGUIStyle2 = BehaviorDesignerUtility.TaskRunningSelectedCompactGUIStyle; } else { backgroundGUIStyle2 = BehaviorDesignerUtility.TaskRunningCompactGUIStyle; } } else if (this.mSelected) { backgroundGUIStyle2 = BehaviorDesignerUtility.TaskRunningSelectedGUIStyle; } else { backgroundGUIStyle2 = BehaviorDesignerUtility.TaskRunningGUIStyle; } iconBorderTexture = BehaviorDesignerUtility.TaskBorderRunningTexture; } Color color = (!disabled && !this.mTask.NodeData.Disabled) ? Color.white : this.grayColor; color.a = num2; GUI.color = (color); Texture2D connectionTopTexture = null; Texture2D connectionBottomTexture = null; if (!this.isEntryDisplay) { if (flag2) { connectionTopTexture = BehaviorDesignerUtility.TaskConnectionIdentifyTopTexture; } else { connectionTopTexture = BehaviorDesignerUtility.TaskConnectionRunningTopTexture; } } if (this.isParent) { if (flag2) { connectionBottomTexture = BehaviorDesignerUtility.TaskConnectionIdentifyBottomTexture; } else { connectionBottomTexture = BehaviorDesignerUtility.TaskConnectionRunningBottomTexture; } } this.DrawNodeTexture(rect, connectionTopTexture, connectionBottomTexture, backgroundGUIStyle2, iconBorderTexture); GUI.color = (Color.white); } if (this.mTask.NodeData.Collapsed) { GUI.DrawTexture(this.nodeCollapsedTextureRect, BehaviorDesignerUtility.TaskConnectionCollapsedTexture); } if (!BehaviorDesignerPreferences.GetBool(BDPreferences.CompactMode)) { GUI.DrawTexture(iconTextureRect, mTask.NodeData.Icon); } if (this.mTask.NodeData.InterruptTime != -1f && Time.realtimeSinceStartup - this.mTask.NodeData.InterruptTime < 0.75f + num) { float a; if (Time.realtimeSinceStartup - this.mTask.NodeData.InterruptTime < 0.75f) { a = 1f; } else { a = 1f - (Time.realtimeSinceStartup - (this.mTask.NodeData.InterruptTime + 0.75f)) / num; } Color white = Color.white; white.a = a; GUI.color = (white); GUI.Label(rect, string.Empty, BehaviorDesignerUtility.TaskHighlightGUIStyle); GUI.color = (Color.white); } GUI.Label(this.titleRect, this.ToString(), BehaviorDesignerUtility.TaskTitleGUIStyle); if (this.mTask.NodeData.IsBreakpoint) { GUI.DrawTexture(this.breakpointTextureRect, BehaviorDesignerUtility.BreakpointTexture); } if (this.showReferenceIcon) { GUI.DrawTexture(this.referenceTextureRect, BehaviorDesignerUtility.ReferencedTexture); } if (this.hasError) { GUI.DrawTexture(this.errorTextureRect, BehaviorDesignerUtility.ErrorIconTexture); } if (this.mTask is Composite && (this.mTask as Composite).AbortType != AbortType.None) { switch ((this.mTask as Composite).AbortType) { case AbortType.Self: GUI.DrawTexture(this.conditionalAbortTextureRect, BehaviorDesignerUtility.ConditionalAbortSelfTexture); break; case AbortType.LowerPriority: GUI.DrawTexture(this.conditionalAbortLowerPriorityTextureRect, BehaviorDesignerUtility.ConditionalAbortLowerPriorityTexture); break; case AbortType.Both: GUI.DrawTexture(this.conditionalAbortTextureRect, BehaviorDesignerUtility.ConditionalAbortBothTexture); break; } } GUI.color = (Color.white); if (this.showHoverBar) { GUI.DrawTexture(this.disabledButtonTextureRect, (!this.mTask.NodeData.Disabled) ? BehaviorDesignerUtility.DisableTaskTexture : BehaviorDesignerUtility.EnableTaskTexture, (ScaleMode)2); if (this.isParent || this.mTask is BehaviorReference) { bool collapsed = this.mTask.NodeData.Collapsed; if (this.mTask is BehaviorReference) { collapsed = (this.mTask as BehaviorReference).collapsed; } GUI.DrawTexture(this.collapseButtonTextureRect, (!collapsed) ? BehaviorDesignerUtility.CollapseTaskTexture : BehaviorDesignerUtility.ExpandTaskTexture, (ScaleMode)2); } } return(result); }
private static bool DrawSelectedVariable(IVariableSource variableSource, ref List <SharedVariable> variables, SharedVariable sharedVariable, ref int selectedVariableIndex, ref string selectedVariableName, ref int selectedVariableTypeIndex, ref bool deleted) { bool result = false; GUILayout.BeginVertical(BehaviorDesignerUtility.SelectedBackgroundGUIStyle, new GUILayoutOption[0]); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("Name", new GUILayoutOption[] { GUILayout.Width(70f) }); EditorGUI.BeginChangeCheck(); selectedVariableName = GUILayout.TextField(selectedVariableName, new GUILayoutOption[] { GUILayout.Width(140f) }); if (EditorGUI.EndChangeCheck()) { if (VariableInspector.VariableNameValid(variableSource, selectedVariableName)) { variableSource.UpdateVariableName(sharedVariable, selectedVariableName); } result = true; } GUILayout.Space(10f); bool enabled = GUI.enabled; GUI.enabled = (enabled && selectedVariableIndex < variables.Count - 1); if (GUILayout.Button(BehaviorDesignerUtility.DownArrowButtonTexture, BehaviorDesignerUtility.PlainButtonGUIStyle, new GUILayoutOption[] { GUILayout.Width(19f) })) { SharedVariable value = variables[selectedVariableIndex + 1]; variables[selectedVariableIndex + 1] = variables[selectedVariableIndex]; variables[selectedVariableIndex] = value; selectedVariableIndex++; result = true; } GUI.enabled = (enabled && (selectedVariableIndex < variables.Count - 1 || selectedVariableIndex != 0)); GUILayout.Box(string.Empty, BehaviorDesignerUtility.ArrowSeparatorGUIStyle, new GUILayoutOption[] { GUILayout.Width(1f), GUILayout.Height(18f) }); GUI.enabled = (enabled && selectedVariableIndex != 0); if (GUILayout.Button(BehaviorDesignerUtility.UpArrowButtonTexture, BehaviorDesignerUtility.PlainButtonGUIStyle, new GUILayoutOption[] { GUILayout.Width(20f) })) { SharedVariable value2 = variables[selectedVariableIndex - 1]; variables[selectedVariableIndex - 1] = variables[selectedVariableIndex]; variables[selectedVariableIndex] = value2; selectedVariableIndex--; result = true; } GUI.enabled = enabled; if (GUILayout.Button(BehaviorDesignerUtility.VariableDeleteButtonTexture, BehaviorDesignerUtility.PlainButtonGUIStyle, new GUILayoutOption[] { GUILayout.Width(19f) }) && EditorUtility.DisplayDialog("Delete Variable", "Are you sure you want to delete this variable?", "Yes", "No")) { deleted = true; } GUILayout.EndHorizontal(); GUILayout.Space(2f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("Type", new GUILayoutOption[] { GUILayout.Width(70f) }); EditorGUI.BeginChangeCheck(); selectedVariableTypeIndex = EditorGUILayout.Popup(selectedVariableTypeIndex, VariableInspector.sharedVariableStrings, EditorStyles.toolbarPopup, new GUILayoutOption[] { GUILayout.Width(200f) }); if (EditorGUI.EndChangeCheck() && VariableInspector.sharedVariableTypesDict[sharedVariable.GetType().Name] != selectedVariableTypeIndex) { if (BehaviorDesignerWindow.instance != null) { BehaviorDesignerWindow.instance.RemoveSharedVariableReferences(sharedVariable); } sharedVariable = VariableInspector.CreateVariable(selectedVariableTypeIndex, sharedVariable.Name, sharedVariable.IsGlobal); variables[selectedVariableIndex] = sharedVariable; result = true; } GUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); GUILayout.Space(4f); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUI.enabled = VariableInspector.CanNetworkSync(sharedVariable.GetType().GetProperty("Value").PropertyType); EditorGUI.BeginChangeCheck(); sharedVariable.NetworkSync = EditorGUILayout.Toggle(new GUIContent("Network Sync", "Sync this variable over the network. Requires Unity 5.1 or greator. A NetworkIdentity must be attached to the behavior tree GameObject."), sharedVariable.NetworkSync, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { result = true; } GUILayout.EndHorizontal(); GUI.enabled = enabled; if (VariableInspector.DrawSharedVariable(variableSource, sharedVariable, true)) { result = true; } BehaviorDesignerUtility.DrawContentSeperator(4, 7); GUILayout.EndVertical(); GUILayout.Space(3f); return(result); }
public static bool DrawAllVariables(bool showFooter, IVariableSource variableSource, ref List <SharedVariable> variables, bool canSelect, ref List <float> variablePosition, ref int selectedVariableIndex, ref string selectedVariableName, ref int selectedVariableTypeIndex, bool drawRemoveButton, bool drawLastSeparator) { if (variables == null) { return(false); } bool result = false; if (canSelect && variablePosition == null) { variablePosition = new List <float>(); } for (int i = 0; i < variables.Count; i++) { SharedVariable sharedVariable = variables[i]; if (sharedVariable != null) { if (canSelect && selectedVariableIndex == i) { if (i == 0) { GUILayout.Space(2f); } bool flag = false; if (VariableInspector.DrawSelectedVariable(variableSource, ref variables, sharedVariable, ref selectedVariableIndex, ref selectedVariableName, ref selectedVariableTypeIndex, ref flag)) { result = true; } if (flag) { if (BehaviorDesignerWindow.instance != null) { BehaviorDesignerWindow.instance.RemoveSharedVariableReferences(sharedVariable); } variables.RemoveAt(i); if (selectedVariableIndex == i) { selectedVariableIndex = -1; } else if (selectedVariableIndex > i) { selectedVariableIndex--; } result = true; break; } } else { GUILayout.BeginHorizontal(new GUILayoutOption[0]); if (VariableInspector.DrawSharedVariable(variableSource, sharedVariable, false)) { result = true; } if (drawRemoveButton && GUILayout.Button(BehaviorDesignerUtility.VariableDeleteButtonTexture, BehaviorDesignerUtility.PlainButtonGUIStyle, new GUILayoutOption[] { GUILayout.Width(19f) }) && EditorUtility.DisplayDialog("Delete Variable", "Are you sure you want to delete this variable?", "Yes", "No")) { if (BehaviorDesignerWindow.instance != null) { BehaviorDesignerWindow.instance.RemoveSharedVariableReferences(sharedVariable); } variables.RemoveAt(i); if (canSelect) { if (selectedVariableIndex == i) { selectedVariableIndex = -1; } else if (selectedVariableIndex > i) { selectedVariableIndex--; } } result = true; break; } GUILayout.Space(10f); GUILayout.EndHorizontal(); if (i != variables.Count - 1 || drawLastSeparator) { BehaviorDesignerUtility.DrawContentSeperator(2, 7); } } GUILayout.Space(4f); if (canSelect && Event.current.type == EventType.Repaint) { if (variablePosition.Count <= i) { variablePosition.Add(GUILayoutUtility.GetLastRect().yMax); } else { variablePosition[i] = GUILayoutUtility.GetLastRect().yMax; } } } } if (canSelect && variables.Count < variablePosition.Count) { for (int j = variablePosition.Count - 1; j >= variables.Count; j--) { variablePosition.RemoveAt(j); } } if (showFooter && variables.Count > 0) { GUI.enabled = true; GUILayout.Label("Select a variable to change its properties.", BehaviorDesignerUtility.LabelWrapGUIStyle, new GUILayoutOption[0]); } return(result); }
// Token: 0x060001FA RID: 506 RVA: 0x0001290C File Offset: 0x00010B0C private static void SerializeFields(object obj, ref Dictionary <string, object> dict, ref List <Object> unityObjects) { FieldInfo[] allFields = TaskUtility.GetAllFields(obj.GetType()); for (int i = 0; i < allFields.Length; i++) { if (!BehaviorDesignerUtility.HasAttribute(allFields[i], typeof(NonSerializedAttribute)) && ((!allFields[i].IsPrivate && !allFields[i].IsFamily) || BehaviorDesignerUtility.HasAttribute(allFields[i], typeof(SerializeField))) && (!(obj is ParentTask) || !allFields[i].Name.Equals("children"))) { if (allFields[i].GetValue(obj) != null) { string key = (allFields[i].FieldType.Name + allFields[i].Name).ToString(); if (typeof(IList).IsAssignableFrom(allFields[i].FieldType)) { IList list = allFields[i].GetValue(obj) as IList; if (list != null) { List <object> list2 = new List <object>(); for (int j = 0; j < list.Count; j++) { if (list[j] == null) { list2.Add(null); } else { Type type = list[j].GetType(); if (list[j] is Task) { Task task = list[j] as Task; list2.Add(task.ID); } else if (list[j] is SharedVariable) { list2.Add(JSONSerialization.SerializeVariable(list[j] as SharedVariable, ref unityObjects)); } else if (list[j] is Object) { Object @object = list[j] as Object; if (!object.ReferenceEquals(@object, null) && @object != null) { list2.Add(unityObjects.Count); unityObjects.Add(@object); } } else if (type.Equals(typeof(LayerMask))) { list2.Add(((LayerMask)list[j]).value); } else if (type.IsPrimitive || type.IsEnum || type.Equals(typeof(string)) || type.Equals(typeof(Vector2)) || type.Equals(typeof(Vector3)) || type.Equals(typeof(Vector4)) || type.Equals(typeof(Quaternion)) || type.Equals(typeof(Matrix4x4)) || type.Equals(typeof(Color)) || type.Equals(typeof(Rect))) { list2.Add(list[j]); } else { Dictionary <string, object> item = new Dictionary <string, object>(); JSONSerialization.SerializeFields(list[j], ref item, ref unityObjects); list2.Add(item); } } } if (list2 != null) { dict.Add(key, list2); } } } else if (typeof(Task).IsAssignableFrom(allFields[i].FieldType)) { Task task2 = allFields[i].GetValue(obj) as Task; if (task2 != null) { if (BehaviorDesignerUtility.HasAttribute(allFields[i], typeof(InspectTaskAttribute))) { Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary.Add("Type", task2.GetType()); JSONSerialization.SerializeFields(task2, ref dictionary, ref unityObjects); dict.Add(key, dictionary); } else { dict.Add(key, task2.ID); } } } else if (typeof(SharedVariable).IsAssignableFrom(allFields[i].FieldType)) { if (!dict.ContainsKey(key)) { dict.Add(key, JSONSerialization.SerializeVariable(allFields[i].GetValue(obj) as SharedVariable, ref unityObjects)); } } else if (typeof(Object).IsAssignableFrom(allFields[i].FieldType)) { Object object2 = allFields[i].GetValue(obj) as Object; if (!object.ReferenceEquals(object2, null) && object2 != null) { dict.Add(key, unityObjects.Count); unityObjects.Add(object2); } } else if (allFields[i].FieldType.Equals(typeof(LayerMask))) { dict.Add(key, ((LayerMask)allFields[i].GetValue(obj)).value); } else if (allFields[i].FieldType.IsPrimitive || allFields[i].FieldType.IsEnum || allFields[i].FieldType.Equals(typeof(string)) || allFields[i].FieldType.Equals(typeof(Vector2)) || allFields[i].FieldType.Equals(typeof(Vector3)) || allFields[i].FieldType.Equals(typeof(Vector4)) || allFields[i].FieldType.Equals(typeof(Quaternion)) || allFields[i].FieldType.Equals(typeof(Matrix4x4)) || allFields[i].FieldType.Equals(typeof(Color)) || allFields[i].FieldType.Equals(typeof(Rect))) { dict.Add(key, allFields[i].GetValue(obj)); } else if (allFields[i].FieldType.Equals(typeof(AnimationCurve))) { AnimationCurve animationCurve = allFields[i].GetValue(obj) as AnimationCurve; Dictionary <string, object> dictionary2 = new Dictionary <string, object>(); if (animationCurve.keys != null) { Keyframe[] keys = animationCurve.keys; List <List <object> > list3 = new List <List <object> >(); for (int k = 0; k < keys.Length; k++) { list3.Add(new List <object> { keys[k].time, keys[k].value, keys[k].inTangent, keys[k].outTangent, keys[k].tangentMode }); } dictionary2.Add("Keys", list3); } dictionary2.Add("PreWrapMode", animationCurve.preWrapMode); dictionary2.Add("PostWrapMode", animationCurve.postWrapMode); dict.Add(key, dictionary2); } else { Dictionary <string, object> value = new Dictionary <string, object>(); JSONSerialization.SerializeFields(allFields[i].GetValue(obj), ref value, ref unityObjects); dict.Add(key, value); } } } } }
public SearchableType(Type type) { this.mType = type; this.mName = BehaviorDesignerUtility.SplitCamelCase(this.mType.Name); }
public static void DrawComponentSelector(VariableSynchronizerInspector.Synchronizer synchronizer, Type componentType, VariableSynchronizerInspector.ComponentListType listType) { bool flag = false; EditorGUI.BeginChangeCheck(); synchronizer.gameObject = (EditorGUILayout.ObjectField("GameObject", synchronizer.gameObject, typeof(GameObject), true, new GUILayoutOption[0]) as GameObject); if (EditorGUI.EndChangeCheck()) { flag = true; } if (synchronizer.gameObject == null) { GUI.enabled = (false); } switch (listType) { case VariableSynchronizerInspector.ComponentListType.Instant: if (flag) { if (synchronizer.gameObject != null) { synchronizer.component = synchronizer.gameObject.GetComponent(componentType); } else { synchronizer.component = null; } } break; case VariableSynchronizerInspector.ComponentListType.Popup: { int num = 0; List <string> list = new List <string>(); Component[] array = null; list.Add("None"); if (synchronizer.gameObject != null) { array = synchronizer.gameObject.GetComponents(componentType); for (int i = 0; i < array.Length; i++) { if (array[i].Equals(synchronizer.component)) { num = list.Count; } string text = BehaviorDesignerUtility.SplitCamelCase(array[i].GetType().Name); int num2 = 0; for (int j = 0; j < list.Count; j++) { if (list[i].Equals(text)) { num2++; } } if (num2 > 0) { text = text + " " + num2; } list.Add(text); } } EditorGUI.BeginChangeCheck(); num = EditorGUILayout.Popup("Component", num, list.ToArray(), new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { if (num != 0) { synchronizer.component = array[num - 1]; } else { synchronizer.component = null; } } break; } case VariableSynchronizerInspector.ComponentListType.BehaviorDesignerGroup: if (synchronizer.gameObject != null) { Behavior[] components = synchronizer.gameObject.GetComponents <Behavior>(); if (components != null && components.Length > 1) { synchronizer.componentGroup = EditorGUILayout.IntField("Behavior Tree Group", synchronizer.componentGroup, new GUILayoutOption[0]); } synchronizer.component = VariableSynchronizerInspector.GetBehaviorWithGroup(components, synchronizer.componentGroup); } break; } }
public override void OnInspectorGUI() { VariableSynchronizer variableSynchronizer = this.target as VariableSynchronizer; if (variableSynchronizer == null) { return; } GUILayout.Space(5f); variableSynchronizer.UpdateInterval = (UpdateIntervalType)EditorGUILayout.EnumPopup("Update Interval", variableSynchronizer.UpdateInterval, new GUILayoutOption[0]); if (variableSynchronizer.UpdateInterval == UpdateIntervalType.SpecifySeconds) { variableSynchronizer.UpdateIntervalSeconds = EditorGUILayout.FloatField("Seconds", variableSynchronizer.UpdateIntervalSeconds, new GUILayoutOption[0]); } GUILayout.Space(5f); GUI.enabled = (!Application.isPlaying); this.DrawSharedVariableSynchronizer(this.sharedVariableSynchronizer, null); if (string.IsNullOrEmpty(this.sharedVariableSynchronizer.targetName)) { this.DrawSynchronizedVariables(variableSynchronizer); return; } EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.LabelField("Direction", new GUILayoutOption[] { GUILayout.MaxWidth(146f) }); if (GUILayout.Button(BehaviorDesignerUtility.LoadTexture((!this.setVariable) ? "RightArrowButton.png" : "LeftArrowButton.png", true, this), BehaviorDesignerUtility.ButtonGUIStyle, new GUILayoutOption[] { GUILayout.Width(22f) })) { this.setVariable = !this.setVariable; } EditorGUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); this.synchronizationType = (VariableSynchronizer.SynchronizationType)EditorGUILayout.EnumPopup("Type", this.synchronizationType, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.targetSynchronizer = new VariableSynchronizerInspector.Synchronizer(); } if (this.targetSynchronizer == null) { this.targetSynchronizer = new VariableSynchronizerInspector.Synchronizer(); } if (this.sharedVariableValueType == null && !string.IsNullOrEmpty(this.sharedVariableValueTypeName)) { this.sharedVariableValueType = TaskUtility.GetTypeWithinAssembly(this.sharedVariableValueTypeName); } switch (this.synchronizationType) { case VariableSynchronizer.SynchronizationType.BehaviorDesigner: this.DrawSharedVariableSynchronizer(this.targetSynchronizer, this.sharedVariableValueType); break; case VariableSynchronizer.SynchronizationType.Property: this.DrawPropertySynchronizer(this.targetSynchronizer, this.sharedVariableValueType); break; case VariableSynchronizer.SynchronizationType.Animator: this.DrawAnimatorSynchronizer(this.targetSynchronizer); break; case VariableSynchronizer.SynchronizationType.PlayMaker: this.DrawPlayMakerSynchronizer(this.targetSynchronizer, this.sharedVariableValueType); break; case VariableSynchronizer.SynchronizationType.uFrame: this.DrawuFrameSynchronizer(this.targetSynchronizer, this.sharedVariableValueType); break; } if (string.IsNullOrEmpty(this.targetSynchronizer.targetName)) { GUI.enabled = (false); } if (GUILayout.Button("Add", new GUILayoutOption[0])) { VariableSynchronizer.SynchronizedVariable item = new VariableSynchronizer.SynchronizedVariable(this.synchronizationType, this.setVariable, this.sharedVariableSynchronizer.component as Behavior, this.sharedVariableSynchronizer.targetName, this.sharedVariableSynchronizer.global, this.targetSynchronizer.component, this.targetSynchronizer.targetName, this.targetSynchronizer.global); variableSynchronizer.SynchronizedVariables.Add(item); EditorUtility.SetDirty(variableSynchronizer); this.sharedVariableSynchronizer = new VariableSynchronizerInspector.Synchronizer(); this.targetSynchronizer = new VariableSynchronizerInspector.Synchronizer(); } GUI.enabled = (true); this.DrawSynchronizedVariables(variableSynchronizer); }
public void Init() { this.mCategoryList = new List <TaskList.CategoryList>(); List <Type> list = new List <Type>(); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type[] types = assemblies[i].GetTypes(); for (int j = 0; j < types.Length; j++) { if (!types[j].Equals(typeof(BehaviorReference)) && !types[j].IsAbstract) { if (types[j].IsSubclassOf(typeof(BehaviorDesigner.Runtime.Tasks.Action)) || types[j].IsSubclassOf(typeof(Composite)) || types[j].IsSubclassOf(typeof(Conditional)) || types[j].IsSubclassOf(typeof(Decorator))) { list.Add(types[j]); } } } } list.Sort(new AlphanumComparator <Type>()); Dictionary <string, TaskList.CategoryList> dictionary = new Dictionary <string, TaskList.CategoryList>(); string text = string.Empty; int id = 0; for (int k = 0; k < list.Count; k++) { if (list[k].IsSubclassOf(typeof(BehaviorDesigner.Runtime.Tasks.Action))) { text = "Actions"; } else if (list[k].IsSubclassOf(typeof(Composite))) { text = "Composites"; } else if (list[k].IsSubclassOf(typeof(Conditional))) { text = "Conditionals"; } else { text = "Decorators"; } TaskCategoryAttribute[] array; if ((array = (list[k].GetCustomAttributes(typeof(TaskCategoryAttribute), false) as TaskCategoryAttribute[])).Length > 0) { text = text + "/" + array[0].Category; } string text2 = string.Empty; string[] array2 = text.Split(new char[] { '/' }); TaskList.CategoryList categoryList = null; TaskList.CategoryList categoryList2; for (int l = 0; l < array2.Length; l++) { if (l > 0) { text2 += "/"; } text2 += array2[l]; if (!dictionary.ContainsKey(text2)) { categoryList2 = new TaskList.CategoryList(array2[l], text2, this.PreviouslyExpanded(id), id++); if (categoryList == null) { this.mCategoryList.Add(categoryList2); } else { categoryList.addSubcategory(categoryList2); } dictionary.Add(text2, categoryList2); } else { categoryList2 = dictionary[text2]; } categoryList = categoryList2; } categoryList2 = dictionary[text2]; categoryList2.addTask(list[k]); } this.Search(BehaviorDesignerUtility.SplitCamelCase(this.mSearchString).ToLower().Replace(" ", string.Empty), this.mCategoryList); }