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); }
// Token: 0x060002BC RID: 700 RVA: 0x0001B100 File Offset: 0x00019300 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); variableSource.SetAllVariables(list); return(true); }
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); }