public void arrangeElementsInEditor(RMF_RadialMenu rm, bool reset)
    {
        if (reset) {

            for (int i = 0; i < rm.elements.Count; i++) {
                if (rm.elements[i] == null) {
                    Debug.LogError("Radial Menu: element " + i.ToString() + " in the radial menu " + rm.gameObject.name + " is null!");
                    continue;
                }
                RectTransform elemRt = rm.elements[i].GetComponent<RectTransform>();
                elemRt.rotation = Quaternion.Euler(0, 0, 0);

            }

            return;
        }

        for (int i = 0; i < rm.elements.Count; i++) {
            if (rm.elements[i] == null) {
                Debug.LogError("Radial Menu: element " + i.ToString() + " in the radial menu " + rm.gameObject.name + " is null!");
                continue;
            }
            RectTransform elemRt = rm.elements[i].GetComponent<RectTransform>();
            elemRt.rotation = Quaternion.Euler(0, 0, -((360f / (float)rm.elements.Count) * i) - rm.globalOffset);

        }
    }
Beispiel #2
0
    void Awake()
    {
        rt = gameObject.GetComponent <RectTransform>();

        if (gameObject.GetComponent <CanvasGroup>() == null)
        {
            cg = gameObject.AddComponent <CanvasGroup>();
        }
        else
        {
            cg = gameObject.GetComponent <CanvasGroup>();
        }


        if (rt == null)
        {
            Debug.LogError("Radial Menu: Rect Transform for radial element " + gameObject.name + " could not be found. Please ensure this is an object parented to a canvas.");
        }

        if (button == null)
        {
            Debug.LogError("Radial Menu: No button attached to " + gameObject.name + "!");
        }

        parentRM = GetComponentInParent <RMF_RadialMenu>();
    }
    public void arrangeElementsInEditor(RMF_RadialMenu rm, bool reset)
    {
        if (reset)
        {
            for (int i = 0; i < rm.elements.Count; i++)
            {
                if (rm.elements[i] == null)
                {
                    Debug.LogError("Radial Menu: element " + i.ToString() + " in the radial menu " + rm.gameObject.name + " is null!");
                    continue;
                }
                RectTransform elemRt = rm.elements[i].GetComponent <RectTransform>();
                elemRt.rotation = Quaternion.Euler(0, 0, 0);
            }

            return;
        }


        for (int i = 0; i < rm.elements.Count; i++)
        {
            if (rm.elements[i] == null)
            {
                Debug.LogError("Radial Menu: element " + i.ToString() + " in the radial menu " + rm.gameObject.name + " is null!");
                continue;
            }
            RectTransform elemRt = rm.elements[i].GetComponent <RectTransform>();
            elemRt.rotation = Quaternion.Euler(0, 0, -((360f / (float)rm.elements.Count) * i) - rm.globalOffset);
        }
    }
Beispiel #4
0
    public override void Start()
    {
        base.Start();

        _menu = inventoryRadialMenu.GetComponent <RMF_RadialMenu>();
        _menu.SetAllChildrenEnabled(false);
        possibleInteractions = new Collider[_maxInteractionsToCheck];
    }
Beispiel #5
0
    public void arrangeElements()
    {
        _Initial();
        RMF_RadialMenu rm = this;



        /*for (int i = 0; i < rm.elements.Count; i++)
         * {
         *  if (rm.elements[i] == null)
         *  {
         *      Debug.LogError("Radial Menu: element " + i.ToString() + " in the radial menu " + rm.gameObject.name + " is null!");
         *      continue;
         *  }
         *  RectTransform elemRt = rm.elements[i].GetComponent<RectTransform>();
         *  elemRt.rotation = Quaternion.Euler(0, 0, -((360f / (float)rm.elements.Count) * i) - rm.globalOffset);
         *
         * }*/
    }
Beispiel #6
0
    public GameObject generateRadialMenu(List <string> choices)
    {
        cleanRadialMenu();
        currentRadialMenu = (GameObject)Instantiate(menus[choices.Count], decisionPanel.transform);
        currentRadialMenu.transform.position = decisionPanel.transform.position;

        RMF_RadialMenu RM = currentRadialMenu.GetComponent <RMF_RadialMenu>();

        for (int i = 0; i < RM.elements.Count; i++)
        {
            RM.elements[i].setText(choices[i]);
            UnityEngine.UI.Button button = RM.elements[i].button;
            //next, any of these will work:
            button.onClick.RemoveAllListeners();
            int currentIndex = i;
            button.onClick.AddListener(() => { makeDecision(currentIndex); });
        }

        return(currentRadialMenu);
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();


        RMF_RadialMenu rm = (RMF_RadialMenu)target;

        GUIContent visualize = new GUIContent("Visualize Arrangement", "Press this to preview what the radial menu will look like ingame.");
        GUIContent reset     = new GUIContent("Reset Arrangement", "Press this to reset all elements to a 0 rotation for easy editing.");

        if (!Application.isPlaying)
        {
            if (GUILayout.Button(visualize))
            {
                arrangeElementsInEditor(rm, false);
            }

            if (GUILayout.Button(reset))
            {
                arrangeElementsInEditor(rm, true);
            }
        }
    }
Beispiel #8
0
 private void Awake()
 {
     menu = GameObject.Find("radialMenuSkills").GetComponent <RMF_RadialMenu>();
 }