Ejemplo n.º 1
0
    private static void DoVariablesMenu(GameObject go, string fsmName, UIHint hint)
    {
        GenericMenu genericMenu = new GenericMenu();

        using (List <Skill> .Enumerator enumerator = SkillEditor.FsmList.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                Skill current = enumerator.get_Current();
                if (current.get_GameObject() == go && current.get_Name() == fsmName)
                {
                    NamedVariable[] names = current.get_Variables().GetNames(SkillVariable.GetVariableType(hint));
                    NamedVariable[] array = names;
                    for (int i = 0; i < array.Length; i++)
                    {
                        NamedVariable namedVariable = array[i];
                        genericMenu.AddItem(new GUIContent(namedVariable.get_Name()), false, new GenericMenu.MenuFunction2(StringEditor.SetStringValue), namedVariable.get_Name());
                    }
                }
            }
        }
        if (genericMenu.GetItemCount() == 0)
        {
            genericMenu.AddDisabledItem(new GUIContent(Strings.get_Label_None()));
        }
        genericMenu.ShowAsContext();
    }
Ejemplo n.º 2
0
        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]);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static void MoveToLocal(object userdata)
        {
            NamedVariable namedVariable = userdata as NamedVariable;

            if (namedVariable != null && SkillEditor.SelectedFsm != null)
            {
                SkillVariables variables = SkillEditor.SelectedFsm.get_Variables();
                if (variables.Contains(namedVariable.get_Name()))
                {
                    Dialogs.OkDialog(Strings.get_Dialog_Make_Local_Variable(), Strings.get_Dialog_Error_Variable_with_same_name_already_exists());
                    return;
                }
                SkillVariable.AddVariable(variables, namedVariable.Clone());
                SkillEditor.SelectedFsm.Reinitialize();
                SkillEditor.SetFsmDirty();
                SkillEditor.VariableManager.Reset();
                SkillEditor.RepaintAll();
            }
        }
 private static void CheckParameterType(Type type, object fieldValue)
 {
     if (type == null)
     {
         return;
     }
     if (type == typeof(SkillGameObject))
     {
         FsmErrorChecker.CheckFsmGameObjectParameter((SkillGameObject)fieldValue);
     }
     else
     {
         if (type == typeof(SkillOwnerDefault))
         {
             FsmErrorChecker.CheckOwnerDefaultParameter((SkillOwnerDefault)fieldValue);
         }
         else
         {
             if (type == typeof(GameObject))
             {
                 FsmErrorChecker.CheckGameObjectParameter((GameObject)fieldValue);
             }
             else
             {
                 if (type == typeof(SkillEvent))
                 {
                     FsmErrorChecker.CheckFsmEventParameter((SkillEvent)fieldValue);
                 }
                 else
                 {
                     if (type == typeof(SkillString))
                     {
                         FsmErrorChecker.CheckFsmStringParameter((SkillString)fieldValue);
                     }
                     else
                     {
                         if (type == typeof(string))
                         {
                             FsmErrorChecker.CheckStringParameter((string)fieldValue);
                         }
                         else
                         {
                             if (type.get_IsArray())
                             {
                                 Array array = (Array)fieldValue;
                                 if (array != null)
                                 {
                                     Type elementType = type.GetElementType();
                                     for (int i = 0; i < array.get_Length(); i++)
                                     {
                                         FsmErrorChecker.CheckParameterType(elementType, array.GetValue(i));
                                     }
                                 }
                             }
                             else
                             {
                                 Object @object = fieldValue as Object;
                                 if (@object != null)
                                 {
                                     FsmErrorChecker.CheckObjectParameter(@object);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (type.IsSubclassOf(typeof(NamedVariable)))
     {
         if (FsmEditorSettings.CheckForRequiredField && FsmErrorChecker.IsRequiredField())
         {
             if (fieldValue == null)
             {
                 FsmErrorChecker.AddRequiredFieldError();
                 return;
             }
             NamedVariable namedVariable = (NamedVariable)fieldValue;
             if ((namedVariable.get_UseVariable() || FsmErrorChecker.IsVariableField()) && string.IsNullOrEmpty(namedVariable.get_Name()))
             {
                 FsmErrorChecker.AddRequiredFieldError();
                 return;
             }
         }
     }
     else
     {
         if (type == typeof(SkillVar) && FsmEditorSettings.CheckForRequiredField && FsmErrorChecker.IsRequiredField())
         {
             SkillVar fsmVar = (SkillVar)fieldValue;
             if (fsmVar.useVariable && (fsmVar.get_NamedVar() == null || fsmVar.get_NamedVar().get_IsNone()))
             {
                 FsmErrorChecker.AddRequiredFieldError();
             }
         }
     }
 }