private void DrawPropertySynchronizer(VariableSynchronizerInspector.Synchronizer synchronizer, Type valueType) { VariableSynchronizerInspector.DrawComponentSelector(synchronizer, typeof(Component), VariableSynchronizerInspector.ComponentListType.Popup); int num = 0; List <string> list = new List <string>(); list.Add("None"); if (synchronizer.component != null) { PropertyInfo[] properties = synchronizer.component.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); for (int i = 0; i < properties.Length; i++) { if (properties[i].PropertyType.Equals(valueType) && !properties[i].IsSpecialName) { if (properties[i].Name.Equals(synchronizer.targetName)) { num = list.Count; } list.Add(properties[i].Name); } } } EditorGUI.BeginChangeCheck(); num = EditorGUILayout.Popup("Property", num, list.ToArray(), new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { if (num != 0) { synchronizer.targetName = list[num]; } else { synchronizer.targetName = string.Empty; } } }
private void DrawAnimatorSynchronizer(VariableSynchronizerInspector.Synchronizer synchronizer) { VariableSynchronizerInspector.DrawComponentSelector(synchronizer, typeof(Animator), VariableSynchronizerInspector.ComponentListType.Instant); synchronizer.targetName = EditorGUILayout.TextField("Parameter Name", synchronizer.targetName, new GUILayoutOption[0]); }
private bool DrawSharedVariableSynchronizer(VariableSynchronizerInspector.Synchronizer synchronizer, Type valueType) { VariableSynchronizerInspector.DrawComponentSelector(synchronizer, typeof(Behavior), VariableSynchronizerInspector.ComponentListType.BehaviorDesignerGroup); int num = 0; int num2 = -1; string[] array = null; if (synchronizer.component != null) { Behavior behavior = synchronizer.component as Behavior; num = FieldInspector.GetVariablesOfType(valueType, synchronizer.global, synchronizer.targetName, behavior.GetBehaviorSource(), out array, ref num2, valueType == null); } else { array = new string[] { "None" }; } EditorGUI.BeginChangeCheck(); num = EditorGUILayout.Popup("Shared Variable", num, array, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { if (num != 0) { if (num2 != -1 && num >= num2) { synchronizer.targetName = array[num].Substring(8, array[num].Length - 8); synchronizer.global = true; } else { synchronizer.targetName = array[num]; synchronizer.global = false; } if (valueType == null) { SharedVariable variable; if (synchronizer.global) { variable = GlobalVariables.Instance.GetVariable(synchronizer.targetName); } else { Behavior behavior2 = synchronizer.component as Behavior; variable = behavior2.GetVariable(array[num]); } this.sharedVariableValueTypeName = variable.GetType().GetProperty("Value").PropertyType.FullName; this.sharedVariableValueType = null; } } else { synchronizer.targetName = null; } } if (string.IsNullOrEmpty(synchronizer.targetName)) { GUI.enabled = (false); } return(GUI.enabled); }
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; } }