public CircularMenuButton(CircularMenuCategory _parentCategory)
 {
     //parentCategory = _parentCategory;
     Clear();
 }
    /// <summary>
    /// Function used to draw the category name
    /// </summary>
    /// <param name="part">CircularMenuCategory you want to draw</param>
    /// <param name="angleDebut">Start angle of the category elements</param>
    /// <param name="angleFin">End angle of the category elements</param>
    private void DrawCategoryName(CircularMenuCategory part, float angleDebut, float angleFin)
    {
        if (part.showCategoryName && actualState == EtatMenu.Active)
        {
            float angleMedian = (angleFin - angleDebut) / 2 + angleDebut;
            float tempRayonCercle = actualCircleRadius * categoryNameRadius;

            Vector2 positionBtn = new Vector2(Mathf.Cos(angleMedian * Mathf.PI / 180) * tempRayonCercle, Mathf.Sin(angleMedian * Mathf.PI / 180) * tempRayonCercle);

            positionBtn.x = actualMenuPosition.x * Screen.width + (positionBtn.x - part.textLabelSize.x / 2) * Screen.width;
            positionBtn.y = actualMenuPosition.y * Screen.height + (positionBtn.y - part.textLabelSize.y / 2) * Screen.width;

            Vector2 pivot = positionBtn;
            pivot.x += part.textLabelSize.x / 2 * Screen.width;
            pivot.y += part.textLabelSize.y / 2 * Screen.width;

            Matrix4x4 tempMatrix = GUI.matrix;

            float clampAngle = (float)ClampRotation(angleMedian);

            float matrixRotationAngle = clampAngle + 90;

            if (categoryNameNoUpsidedown && clampAngle > 0 && clampAngle < 180)
            {
                if (clampAngle > 90)
                    matrixRotationAngle += 180;
                else
                    matrixRotationAngle -= 180;
            }

            GUIUtility.RotateAroundPivot(matrixRotationAngle, pivot);

            GUI.Box(new Rect(positionBtn.x, positionBtn.y, Screen.width * part.textLabelSize.x, Screen.width * part.textLabelSize.y), part.name, part.textStyle);

            GUI.matrix = tempMatrix;
        }
    }
 /// <summary>
 /// Function use to add a category to the menu
 /// </summary>
 /// <returns> The created category </returns>
 public CircularMenuCategory AddCategory()
 {
     CircularMenuCategory newCategory = new CircularMenuCategory(this);
     menuCategories.Add(newCategory);
     return newCategory;
 }
    /// <summary>
    /// Function use to remove a specific category to the menu
    /// </summary>
    public void RemoveCategory(CircularMenuCategory _category)
    {
        for (int i = 0; i < _category.buttonList.Count; i++)
            _category.RemoveButton(_category.buttonList[i]);

        menuCategories.Remove(_category);
        UpdateButtonsNumber();
        _category = null;

        System.GC.Collect();
    }
    /// <summary>
    /// Function called to draw a category gui
    /// </summary>
    /// <param name="_part"></param>
    private void ShowMenuCategory(CircularMenuCategory _part)
    {
        EditorGUILayout.BeginHorizontal();
        _part.showInEditor = EditorGUILayout.Foldout(_part.showInEditor, _part.name);
        if (GUILayout.Button("Remove '" + _part.name + "'"))
            _target.RemoveCategory(_part);
        EditorGUILayout.EndHorizontal();

        if (_part.showInEditor)
        {
            EditorGUI.indentLevel = 1;

            EditorGUILayout.BeginVertical();

            _part.name = EditorGUILayout.TextField("Name", _part.name);

            _part.showCategoryName = EditorGUILayout.BeginToggleGroup("Show category name", _part.showCategoryName);
            EditorGUI.indentLevel = 2;
            if (_part.showCategoryName)
            {
                _part.textLabelSize = EditorGUILayout.Vector2Field("Label size", _part.textLabelSize);
                _part.textStyle.font = (Font)EditorGUILayout.ObjectField("Title font", _part.textStyle.font, typeof(Font), false);
                _part.textStyle.alignment = (TextAnchor)EditorGUILayout.EnumPopup("Text alignement", _part.textStyle.alignment);
                _part.textStyle.fontSize = EditorGUILayout.IntField("Text size", _part.textStyle.fontSize);
                _part.textStyle.fontStyle = (FontStyle)EditorGUILayout.EnumPopup("Text style", _part.textStyle.fontStyle);
                _part.textStyle.normal.textColor = EditorGUILayout.ColorField("Text color", _part.textStyle.normal.textColor);
            }
            EditorGUI.indentLevel = 1;
            EditorGUILayout.EndToggleGroup();

            EditorGUILayout.LabelField("Buttons", EditorStyles.boldLabel);
            EditorGUI.indentLevel = 2;
            for (int i = 0; i < _part.buttonList.Count; i++)
            {
                ShowCircularButtonGUI(_part.buttonList[i],true,true);
                if (_part.buttonList[i].showInEditor)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("", EditorStyles.boldLabel);
                    if (GUILayout.Button("Clear"))
                        _part.buttonList[i].Clear();
                    if (GUILayout.Button("Remove button '" + _part.buttonList[i].name + "'"))
                        _part.RemoveButton(_part.buttonList[i]);
                    EditorGUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Add button to " + _part.name))
                _part.AddButton();
            EditorGUILayout.LabelField("");
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }

        EditorGUILayout.Separator();

        EditorGUI.indentLevel = 0;
        EditorGUILayout.Separator();
    }