Example #1
0
        private void BeginSelection()
        {
            if (!Input.GetMouseButtonDown(0))
            {
                return;
            }
            boxRect.gameObject.SetActive(value: true);
            origin = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            if (!PointIsValidAgainstSelectionMask(origin))
            {
                ResetBoxRect();
                return;
            }
            boxRect.anchoredPosition = origin;
            MonoBehaviour[]       array = ((selectableGroup != null) ? selectableGroup : Object.FindObjectsOfType <MonoBehaviour>());
            List <IBoxSelectable> list  = new List <IBoxSelectable>();

            MonoBehaviour[] array2 = array;
            foreach (MonoBehaviour monoBehaviour in array2)
            {
                IBoxSelectable boxSelectable = monoBehaviour as IBoxSelectable;
                if (boxSelectable != null)
                {
                    list.Add(boxSelectable);
                    if (!Input.GetKey(KeyCode.LeftShift))
                    {
                        boxSelectable.selected = false;
                    }
                }
            }
            selectables       = list.ToArray();
            clickedBeforeDrag = GetSelectableAtMousePosition();
        }
Example #2
0
 // Token: 0x0600A120 RID: 41248 RVA: 0x003C46B0 File Offset: 0x003C28B0
 private IBoxSelectable MPGFEAKDKBE()
 {
     if (!this.CHBKIHMJHOG(Input.mousePosition))
     {
         return(null);
     }
     IBoxSelectable[] oiiebofiggh = this.OIIEBOFIGGH;
     for (int i = 1; i < oiiebofiggh.Length; i++)
     {
         IBoxSelectable boxSelectable = oiiebofiggh[i];
         RectTransform  rectTransform = boxSelectable.transform as RectTransform;
         if (rectTransform)
         {
             Camera cam = this.PEBAOKFLLPD(rectTransform);
             if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, cam))
             {
                 return(boxSelectable);
             }
         }
         else
         {
             float   magnitude = boxSelectable.transform.GetComponent <Renderer>().bounds.extents.magnitude;
             Vector2 a         = this.PBDLNOHIHII(boxSelectable);
             if (Vector2.Distance(a, Input.mousePosition) <= magnitude)
             {
                 return(boxSelectable);
             }
         }
     }
     return(null);
 }
Example #3
0
        void BeginSelection()
        {
            // Click somewhere in the Game View.
            if (!Input.GetMouseButtonDown(0))
            {
                return;
            }

            //The boxRect will be inactive up until the point we start selecting
            boxRect.gameObject.SetActive(true);

            // Get the initial click position of the mouse.
            origin = new Vector2(Input.mousePosition.x, Input.mousePosition.y);

            //If the initial click point is not inside the selection mask, we abort the selection
            if (!PointIsValidAgainstSelectionMask(origin))
            {
                ResetBoxRect();
                return;
            }

            // The anchor is set to the same place.
            boxRect.anchoredPosition = origin;

            MonoBehaviour[] behavioursToGetSelectionsFrom;

            // If we do not have a group of selectables already set, we'll just loop through every object that's a monobehaviour, and look for selectable interfaces in them
            if (selectableGroup == null)
            {
                behavioursToGetSelectionsFrom = GameObject.FindObjectsOfType <MonoBehaviour>();
            }
            else
            {
                behavioursToGetSelectionsFrom = selectableGroup;
            }

            //Temporary list to store the found selectables before converting to the main selectables array
            List <IBoxSelectable> selectableList = new List <IBoxSelectable>();

            foreach (MonoBehaviour behaviour in behavioursToGetSelectionsFrom)
            {
                //If the behaviour implements the selectable interface, we add it to the selectable list
                IBoxSelectable selectable = behaviour as IBoxSelectable;
                if (selectable != null)
                {
                    selectableList.Add(selectable);

                    //We're using left shift to act as the "Add To Selection" command. So if left shift isn't pressed, we want everything to begin deselected
                    if (!Input.GetKey(KeyCode.LeftShift))
                    {
                        selectable.selected = false;
                    }
                }
            }
            selectables = selectableList.ToArray();

            //For single-click actions, we need to get the selectable that was clicked when selection began (if any)
            clickedBeforeDrag = GetSelectableAtMousePosition();
        }
Example #4
0
 private void EndSelection()
 {
     if (Input.GetMouseButtonUp(0) && boxRect.gameObject.activeSelf)
     {
         clickedAfterDrag = GetSelectableAtMousePosition();
         ApplySingleClickDeselection();
         ApplyPreSelections();
         ResetBoxRect();
         onSelectionChange.Invoke(GetAllSelected());
     }
 }
Example #5
0
        private Vector2 GetScreenPointOfSelectable(IBoxSelectable selectable)
        {
            RectTransform rectTransform = selectable.transform as RectTransform;

            if ((bool)rectTransform)
            {
                Camera screenPointCamera = GetScreenPointCamera(rectTransform);
                return(RectTransformUtility.WorldToScreenPoint(screenPointCamera, selectable.transform.position));
            }
            return(Camera.main.WorldToScreenPoint(selectable.transform.position));
        }
Example #6
0
        // Token: 0x0600A0FE RID: 41214 RVA: 0x003C37BC File Offset: 0x003C19BC
        private Vector2 JAADADFEJJH(IBoxSelectable NHFCLJILACH)
        {
            RectTransform rectTransform = NHFCLJILACH.transform as RectTransform;

            if (rectTransform)
            {
                Camera cam = this.PEBAOKFLLPD(rectTransform);
                return(RectTransformUtility.WorldToScreenPoint(cam, NHFCLJILACH.transform.position));
            }
            return(Camera.main.WorldToScreenPoint(NHFCLJILACH.transform.position));
        }
Example #7
0
        void EndSelection()
        {
            //Get out if we haven't finished selecting, or if the selection has been aborted (boxRect disabled)
            if (!Input.GetMouseButtonUp(0) || !boxRect.gameObject.activeSelf)
            {
                return;
            }

            clickedAfterDrag = GetSelectableAtMousePosition();

            ApplySingleClickDeselection();
            ApplyPreSelections();
            ResetBoxRect();
            onSelectionChange.Invoke(GetAllSelected());
        }
Example #8
0
        Vector2 GetScreenPointOfSelectable(IBoxSelectable selectable)
        {
            //Getting the screen point requires it's own function, because we have to take into consideration the selectables heirarchy.

            //Cast the transform as a rectTransform
            var rectTransform = selectable.transform as RectTransform;

            //If it has a rectTransform component, it must be in the heirarchy of a canvas, somewhere.
            if (rectTransform)
            {
                //And the camera used to calculate it's screen point will vary.
                Camera renderingCamera = GetScreenPointCamera(rectTransform);

                return(RectTransformUtility.WorldToScreenPoint(renderingCamera, selectable.transform.position));
            }

            //If it's no in the heirarchy of a canvas, the regular MainCamera.main.WorldToScreenPoint will do.
            return(Camera.main.WorldToScreenPoint(selectable.transform.position));
        }
Example #9
0
        // Token: 0x0600A11B RID: 41243 RVA: 0x003C44D4 File Offset: 0x003C26D4
        public IBoxSelectable[] KADOEEOLGFN()
        {
            if (this.OIIEBOFIGGH == null)
            {
                return(new IBoxSelectable[0]);
            }
            List <IBoxSelectable> list = new List <IBoxSelectable>();

            IBoxSelectable[] oiiebofiggh = this.OIIEBOFIGGH;
            for (int i = 0; i < oiiebofiggh.Length; i += 0)
            {
                IBoxSelectable boxSelectable = oiiebofiggh[i];
                if (boxSelectable.selected)
                {
                    list.Add(boxSelectable);
                }
            }
            return(list.ToArray());
        }
Example #10
0
        // Token: 0x0600A105 RID: 41221 RVA: 0x003C3BE4 File Offset: 0x003C1DE4
        private void KOODEADIDOP()
        {
            if (!Input.GetMouseButtonDown(0))
            {
                return;
            }
            this.IJPPFHCFIHJ.gameObject.SetActive(true);
            this.GEMDHBEGEFH = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            if (!this.CPGJEGEJKAN(this.GEMDHBEGEFH))
            {
                this.HPPNDMHDMAG();
                return;
            }
            this.IJPPFHCFIHJ.anchoredPosition = this.GEMDHBEGEFH;
            MonoBehaviour[] array;
            if (this.KHDFNFGNPEK == null)
            {
                array = Object.FindObjectsOfType <MonoBehaviour>();
            }
            else
            {
                array = this.KHDFNFGNPEK;
            }
            List <IBoxSelectable> list = new List <IBoxSelectable>();

            foreach (MonoBehaviour monoBehaviour in array)
            {
                IBoxSelectable boxSelectable = monoBehaviour as IBoxSelectable;
                if (boxSelectable != null)
                {
                    list.Add(boxSelectable);
                    if (!Input.GetKey((KeyCode)(-182)))
                    {
                        boxSelectable.selected = true;
                    }
                }
            }
            this.OIIEBOFIGGH = list.ToArray();
            this.IECCCKDHMNL = this.MPGFEAKDKBE();
        }
Example #11
0
        // Token: 0x0600A0FD RID: 41213 RVA: 0x003C36B4 File Offset: 0x003C18B4
        private void BHNOEHEJIFH()
        {
            if (!Input.GetMouseButtonDown(0))
            {
                return;
            }
            this.IJPPFHCFIHJ.gameObject.SetActive(true);
            this.GEMDHBEGEFH = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
            if (!this.CHBKIHMJHOG(this.GEMDHBEGEFH))
            {
                this.EKOMMKBCKEC();
                return;
            }
            this.IJPPFHCFIHJ.anchoredPosition = this.GEMDHBEGEFH;
            MonoBehaviour[] array;
            if (this.KHDFNFGNPEK == null)
            {
                array = Object.FindObjectsOfType <MonoBehaviour>();
            }
            else
            {
                array = this.KHDFNFGNPEK;
            }
            List <IBoxSelectable> list = new List <IBoxSelectable>();

            foreach (MonoBehaviour monoBehaviour in array)
            {
                IBoxSelectable boxSelectable = monoBehaviour as IBoxSelectable;
                if (boxSelectable != null)
                {
                    list.Add(boxSelectable);
                    if (!Input.GetKey(KeyCode.LeftShift))
                    {
                        boxSelectable.selected = false;
                    }
                }
            }
            this.OIIEBOFIGGH = list.ToArray();
            this.IECCCKDHMNL = this.OABAKMNNFHA();
        }