void OnEnable()
    {
        AgentGroupSettings targ = (AgentGroupSettings)target;

        mNamesAsset = AgentGroupNamesEditor.GetGlobalAsset();

        string[] names = mNamesAsset.groupNames;

        // Make sure the names asset is initialized.
        if (names == null || names.Length != AgentGroupNames.MaxGroups)
        {
            names = new string[AgentGroupNames.MaxGroups];

            for (int i = 1; i < names.Length; i++)
            {
                names[i] = AgentGroupNames.Undefined;
            }

            names[0] = "Default";

            mNamesAsset.groupNames = names;

            EditorUtility.SetDirty(mNamesAsset);
        }

        // Make sure settings are defined for names.
        for (int i = 0; i < names.Length; i++)
        {
            if (names[i] == AgentGroupNames.Undefined || targ.GetGroupIndex((byte)i) >= 0)
            {
                continue;
            }

            targ.AddGroup((byte)i);

            EditorUtility.SetDirty(target);
        }

        // Initialize the show flags.

        if (mShowGroup == null || mShowGroup.Length != names.Length)
        {
            mShowGroup = new bool[names.Length];
        }

        mAvoidanceNames = CAINavEditorSettingsEditor.GetAvoidanceNames();

        mNewArea = NextUndefined();
    }
    void OnEnable()
    {
        AgentGroupSettings targ = (AgentGroupSettings)target;

        mNamesAsset = AgentGroupNamesEditor.GetGlobalAsset();

        string[] names = mNamesAsset.groupNames;

        // Make sure the names asset is initialized.
        if (names == null || names.Length != AgentGroupNames.MaxGroups)
        {
            names = new string[AgentGroupNames.MaxGroups];

            for (int i = 1; i < names.Length; i++)
            {
                names[i] = AgentGroupNames.Undefined;
            }

            names[0] = "Default";

            mNamesAsset.groupNames = names;

            EditorUtility.SetDirty(mNamesAsset);
        }

        // Make sure settings are defined for names.
        for (int i = 0; i < names.Length; i++)
        {
            if (names[i] == AgentGroupNames.Undefined || targ.GetGroupIndex((byte)i) >= 0)
                continue;

            targ.AddGroup((byte)i);

            EditorUtility.SetDirty(target);
        }

        // Initialize the show flags.

        if (mShowGroup == null || mShowGroup.Length != names.Length)
            mShowGroup = new bool[names.Length];

        mAvoidanceNames = CAINavEditorSettingsEditor.GetAvoidanceNames();

        mNewArea = NextUndefined();
    }
    /// <summary>
    /// Creates a new GUI control.
    /// </summary>
    /// <param name="label"></param>
    /// <returns></returns>
    public static NameGUIControl CreateGUIControl(string label)
    {
        AgentGroupNames settings = EditorUtil.GetGlobalAsset <AgentGroupNames>();

        return(new NameGUIControl(label, (string[])settings.groupNames.Clone()));
    }