/// <summary> /// Function use to remove a specific button to the current category /// </summary> public void RemoveButton(CircularMenuButton _button) { buttonList.Remove(_button); if(parentMenu != null) parentMenu.UpdateButtonsNumber(); _button = null; }
/// <summary> /// Function use to add a button to the current category /// </summary> /// <returns> The created button </returns> public CircularMenuButton AddButton() { CircularMenuButton newButton = new CircularMenuButton(this); buttonList.Add(newButton); parentMenu.UpdateButtonsNumber(); return newButton; }
/// <summary> /// Function used to draw a cicular button gui /// </summary> /// <param name="_btn"></param> private void ShowCircularButtonGUI(CircularMenuButton _btn, bool showElementTocall, bool showTextures) { showElementTocall = true; showTextures = true; _btn.showInEditor = EditorGUILayout.Foldout(_btn.showInEditor, _btn.name); if (_btn.showInEditor) { EditorGUI.indentLevel += 1; EditorGUILayout.BeginVertical(); _btn.name = EditorGUILayout.TextField("Name", _btn.name); if (showElementTocall) { EditorGUILayout.LabelField("On click", EditorStyles.boldLabel); ShowCircularButtonSendMessageItem(_btn.OnClickMessage); EditorGUILayout.LabelField("On release", EditorStyles.boldLabel); ShowCircularButtonSendMessageItem(_btn.OnReleaseMessage ); } EditorGUILayout.EndVertical(); if(showTextures) ShowCicularButtonTextures(_btn); EditorGUI.indentLevel -= 1; } }
/// <summary> /// Function used to draw a button /// </summary> /// <param name="actualBtn">CircularMenu button you want to show</param> /// <param name="angleActuel">Angle position in the menu</param> private void DrawButton(CircularMenuButton actualBtn, float angleActuel) { Vector2 positionBtn = new Vector2(Mathf.Cos(angleActuel * Mathf.PI / 180) * actualCircleRadius, Mathf.Sin(angleActuel * Mathf.PI / 180) * actualCircleRadius); positionBtn.x = actualMenuPosition.x * Screen.width + (positionBtn.x - actualBtnSize / 2) * Screen.width; positionBtn.y = actualMenuPosition.y * Screen.height + (positionBtn.y - actualBtnSize / 2) * Screen.width; // On enregistre la position du bouton actualBtn.viewRectangle = new Rect(positionBtn.x, positionBtn.y, Screen.width * actualBtnSize, Screen.width * actualBtnSize); // On dessine le bouton /*if (GUI.Button(actualBtn.viewRectangle, "", actualBtn.buttonStyle)) actualBtn.Use();*/ GUI.Button(actualBtn.viewRectangle, "", actualBtn.buttonStyle); }
private void ShowCicularButtonTextures(CircularMenuButton _btn) { EditorGUILayout.BeginVertical(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Normal"); _btn.buttonStyle.normal.background = (Texture2D)EditorGUILayout.ObjectField(_btn.buttonStyle.normal.background, typeof(Texture2D), false); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Hover"); _btn.buttonStyle.hover.background = (Texture2D)EditorGUILayout.ObjectField(_btn.buttonStyle.hover.background, typeof(Texture2D), false); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Click"); _btn.buttonStyle.active.background = (Texture2D)EditorGUILayout.ObjectField(_btn.buttonStyle.active.background, typeof(Texture2D), false); EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); }