void FocusInput()
        {
            // TODO: Make utility to find parent menu
            Gui3DMenu menu = gameObject.transform.parent.transform.gameObject.GetComponent <Gui3DMenu>();

            Focused     = !Focused;
            menu.Locked = Focused;
        }
Exemple #2
0
        void Focus()
        {
            parent = transform.parent.GetComponent <Gui3DMenu>();
            if (LockParentMenu)
            {
                if (parent == null)
                {
                    return;
                }
                parent.Focused = false;
            }

            Focused       = true;
            SelectedIndex = 0;
        }
Exemple #3
0
        public static Gui3DMenu GetParentMenu(Transform trans)
        {
            Transform parent = trans.parent;

            if (parent != null)
            {
                Gui3DMenu menu = parent.gameObject.GetComponent <Gui3DMenu>();
                if (menu != null)
                {
                    return(menu);
                }
                GetParentMenu(parent);
            }
            return(null);
        }
Exemple #4
0
        // Update is called once per frame
        void Update()
        {
            parent = Gui3DMenuUtils.GetParentMenu(transform);
            if (LockedByParent)
            {
                if (parent != null)
                {
                    if (!parent.Locked)
                    {
                        Locked         = false;
                        LockedByParent = false;
                    }
                }
            }
            if (Locked)
            {
                return;
            }
            if (parent != null)
            {
                if (parent.Locked)
                {
                    Locked         = true;
                    LockedByParent = true;
                }
            }
            if (Selected && !Focused)
            {
                Focus();
            }
            if ((MenuObjects.Count <= 0))
            {
                return;
            }

            MenuObjects[SelectedIndex].GetComponent <Gui3DObject>().Deselect();

            if (Focused)
            {
                if (Input.GetButtonDown(DownButton))
                {
                    UpdateIndex(GridColumns);
                }
                else if (Input.GetButtonDown(UpButton))
                {
                    UpdateIndex(-GridColumns);
                }

                if (Input.GetButtonDown(RightButton))
                {
                    UpdateIndex(1);
                }
                else if (Input.GetButtonDown(LeftButton))
                {
                    UpdateIndex(-1);
                }
            }

            if (UseMouse)
            {
                if (GetGui3D().HoverObject != null)
                {
                    Gui3DObject hoverobj = MenuObjects.Find(obj => obj.gameObject == GetGui3D().HoverObject.gameObject);
                    if (hoverobj != null)
                    {
                        if (!Focused)
                        {
                            Focus();
                        }
                        SelectedIndex = MenuObjects.IndexOf(hoverobj);
                    }
                    else
                    {
                        UnFocus();
                    }
                }
            }

            if (Focused)
            {
                MenuObjects[SelectedIndex].Select();
            }
        }
Exemple #5
0
 // Use this for initialization
 void Start()
 {
     RefillMenu();
     parent = transform.parent.GetComponent <Gui3DMenu>();
 }