Exemplo n.º 1
0
        public void RaycastSelectables()
        {
            raycast_list.Clear();

            if (TheUI.Get().IsBlockingPanelOpened())
            {
                return;
            }

            PlayerUI ui = PlayerUI.GetFirst();

            if (ui != null && ui.IsBuildMode())
            {
                return; //Dont hover/select things in build mode
            }
            RaycastHit[] hits = Physics.RaycastAll(GetMouseCameraRay(), 99f, selectable_layer.value);
            foreach (RaycastHit hit in hits)
            {
                if (hit.collider != null)
                {
                    Selectable select = hit.collider.GetComponentInParent <Selectable>();
                    if (select != null)
                    {
                        raycast_list.Add(select);
                    }
                }
            }
        }
        void Update()
        {
            PlayerControlsMouse controls = PlayerControlsMouse.Get();

            float target_alpha = controls.IsJoystickActive() && !PlayerUI.GetFirst().IsBuildMode() ? 1f : 0f;

            canvas.alpha = Mathf.MoveTowards(canvas.alpha, target_alpha, 4f * Time.deltaTime);

            Vector2 screenPos = controls.GetJoystickPos();

            rect.anchoredPosition = TheUI.Get().ScreenPointToCanvasPos(screenPos);
            pin.anchoredPosition  = controls.GetJoystickDir() * 50f;
        }