private void DoGlobalVariablesTable() { if (SkillSearch.GetGlobalVariablesUsedCount(SkillEditor.SelectedFsm) == 0) { return; } GUILayout.Space(10f); SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]); GUILayout.BeginHorizontal(SkillEditorStyles.TableRowBox, new GUILayoutOption[0]); GUILayout.Label(SkillEditorContent.GlobalsLabel, new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.Label(SkillEditorContent.VariableUseCountLabel, new GUILayoutOption[0]); GUILayout.EndHorizontal(); List <NamedVariable> globalVariablesUsed = SkillSearch.GetGlobalVariablesUsed(SkillEditor.SelectedFsm); using (List <NamedVariable> .Enumerator enumerator = globalVariablesUsed.GetEnumerator()) { while (enumerator.MoveNext()) { NamedVariable current = enumerator.get_Current(); GUILayout.BeginHorizontal(SkillEditorStyles.TableRowBox, new GUILayoutOption[0]); GUIStyle tableRowText = SkillEditorStyles.TableRowText; if (GUILayout.Button(new GUIContent(current.get_Name(), current.get_Tooltip()), tableRowText, new GUILayoutOption[] { GUILayout.MinWidth(155f) })) { Keyboard.ResetFocus(); this.Deselect(); if (Event.get_current().get_button() == 1 || EditorGUI.get_actionKey()) { FsmVariablesEditor.DoGlobalVariableContextMenu(current); } } int globalVariablesUsageCount = SkillSearch.GetGlobalVariablesUsageCount(current); GUILayout.FlexibleSpace(); GUILayout.Label(globalVariablesUsageCount.ToString(CultureInfo.get_CurrentCulture()), tableRowText, new GUILayoutOption[0]); GUILayout.Space(10f); GUILayout.EndHorizontal(); if (FsmEditorSettings.DebugVariables) { SkillEditorGUILayout.ReadonlyTextField(current.ToString(), new GUILayoutOption[0]); } } } }
public SmoothSaveDataSource(NamedVariable fsmVariable, string key, bool isGlobal, Fsm fsm) { /* * Variables have three categories of identification * Type ID * Keyed Variable Type + Array + Key * Global Variable Type + Array + Variable Name + Global * Local Variable Type + Array + Variable Name + Local + Scene + Owner + FSM */ // Check common data if (fsmVariable == null) { throw new ArgumentNullException("fsmVariable", "Cannot create data source for null FSM variable"); } // Work around RawValue bug for array variables, case 1364 fsmVariable.ToString(); // Assign common properties _fsmVariable = fsmVariable; Key = StringEmptyToNull(key); if (_fsmVariable.VariableType == VariableType.Array) { IsArray = true; var realType = FsmUtility.GetVariableRealType(((FsmArray)_fsmVariable).ElementType); if (realType == typeof(bool)) { FsmVariableType = VariableType.Bool; } else if (realType == typeof(Color)) { FsmVariableType = VariableType.Color; } else if (realType == typeof(Enum)) { FsmVariableType = VariableType.Enum; } else if (realType == typeof(float)) { FsmVariableType = VariableType.Float; } else if (realType == typeof(int)) { FsmVariableType = VariableType.Int; } else if (realType == typeof(Quaternion)) { FsmVariableType = VariableType.Quaternion; } else if (realType == typeof(Rect)) { FsmVariableType = VariableType.Rect; } else if (realType == typeof(string)) { FsmVariableType = VariableType.String; } else if (realType == typeof(Vector2)) { FsmVariableType = VariableType.Vector2; } else if (realType == typeof(Vector3)) { FsmVariableType = VariableType.Vector3; } else { throw new NotSupportedException("Invalid FSM variable type: " + realType); } } else { FsmVariableType = fsmVariable.VariableType; } // If keyed, serialize and exit if (Key != null) { Serialize(); return; } // Assign global and local properties IsGlobal = isGlobal; FsmVariableName = fsmVariable.Name; // Check global and local data if (string.IsNullOrEmpty(FsmVariableName)) { throw new ArgumentNullException("fsmVariable.Name", "Cannot create global or FSM data source with null or empty FSM variable name"); } // If global, serialize and exit if (IsGlobal) { Serialize(); return; } // Check local data if (fsm == null) { throw new ArgumentNullException("fsm", "Cannot create FSM data source with null or empty FSM"); } // Assign local properties #if UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 SceneName = StringEmptyToNull(Application.loadedLevelName); #else SceneName = StringEmptyToNull(SceneManager.GetActiveScene().name); #endif OwnerName = StringEmptyToNull(fsm.OwnerName); FsmName = StringEmptyToNull(fsm.Name); // Check local data if (SceneName == null) { throw new NotSupportedException("Cannot create FSM data source without loaded scene"); } if (OwnerName == null) { throw new ArgumentNullException("fsm.OwnerName", "Cannot create FSM data source with null or empty owner name"); } if (FsmName == null) { throw new ArgumentNullException("fsm.Name", "Cannot create FSM data source with null or empty FSM name"); } // Serialize and exit Serialize(); }