Esempio n. 1
0
    // Update is called once per frame
    public void CheckElementSelection()
    {
        //Set up the new Pointer Event
        PointerEventData m_PointerEventData = new PointerEventData(eventSystem);

        //Set the Pointer Event Position to that of the mouse position
        m_PointerEventData.position = Input.mousePosition;

        //Create a list of Raycast Results
        List <RaycastResult> results = new List <RaycastResult>();

        //Raycast using the Graphics Raycaster and mouse click position
        graphicRayCaster.Raycast(m_PointerEventData, results);

        //For every result returned, output the name of the GameObject on the Canvas hit by the Ray
        foreach (RaycastResult result in results)
        {
            OnHighlight possibleElementButton = result.gameObject.GetComponent <OnHighlight>();

            if (result.gameObject == gameObject)
            {
                elementManager.PickElement(elementId);
            }
        }
    }
Esempio n. 2
0
 /// <summary>
 /// Assigns all events to the selectable, since there are so many of them.
 /// </summary>
 /// <param name="selectable">The selectable to assign events to.</param>
 /// <param name="i">The index of the methods array.</param>
 /// <param name="j">The number to pass into the method.</param>
 private void AssignSelectable(KMSelectable selectable, ref int i, ref int j)
 {
     if (OnCancel != null && i < OnCancel.Length)
     {
         selectable.OnCancel += OnCancel[i](j);
     }
     if (OnDefocus != null && i < OnDefocus.Length)
     {
         selectable.OnDefocus += OnDefocus[i](j);
     }
     if (OnDeselect != null && i < OnDeselect.Length)
     {
         selectable.OnDeselect += OnDeselect[i](j);
     }
     if (OnFocus != null && i < OnFocus.Length)
     {
         selectable.OnFocus += OnFocus[i](j);
     }
     if (OnHighlight != null && i < OnHighlight.Length)
     {
         selectable.OnHighlight += OnHighlight[i](j);
     }
     if (OnHighlightEnded != null && i < OnHighlightEnded.Length)
     {
         selectable.OnHighlightEnded += OnHighlightEnded[i](j);
     }
     if (OnInteract != null && i < OnInteract.Length)
     {
         selectable.OnInteract += OnInteract[i](j);
     }
     if (OnInteractEnded != null && i < OnInteractEnded.Length)
     {
         selectable.OnInteractEnded += OnInteractEnded[i](j);
     }
     if (OnLeft != null && i < OnLeft.Length)
     {
         selectable.OnLeft += OnLeft[i](j);
     }
     if (OnRight != null && i < OnRight.Length)
     {
         selectable.OnRight += OnRight[i](j);
     }
     if (OnSelect != null && i < OnSelect.Length)
     {
         selectable.OnSelect += OnSelect[i](j);
     }
 }
Esempio n. 3
0
        /// <summary>Rotates the hand towards the object it's aiming to pick up</summary>
        void LookAssist()
        {
            if (holdingObj == null)
            {
                Grabbable  lookingAtGrab;
                RaycastHit hit;
                var        dir = HandClosestHit(out hit, reachDistance, LayerMask.GetMask("Grabbable", "Grabbing", "Releasing"));
                //Zero means it didn't hit
                if (dir != Vector3.zero)
                {
                    //Changes look target
                    if (hit.collider.transform.gameObject != lookingAtObj)
                    {
                        //Unhighlights current target if found
                        if (lookingAtObj != null && GetGrabbable(lookingAtObj, out lookingAtGrab))
                        {
                            OnStopHighlight?.Invoke(this, lookingAtGrab);
                            lookingAtGrab.Unhighlight();
                        }

                        //Highlights new target if found
                        lookingAtObj = hit.collider.transform.gameObject;
                        if (GetGrabbable(lookingAtObj, out lookingAtGrab))
                        {
                            OnHighlight?.Invoke(this, lookingAtGrab);
                            lookingAtGrab.Highlight();
                        }
                    }

                    rotationOffset = Quaternion.RotateTowards(rotationOffset, Quaternion.FromToRotation(palmTransform.forward, hit.point - transform.position), 50f * Time.deltaTime * lookAssistSpeed);
                }
                //If it was looking at something but now it's not
                else if (lookingAtObj != null)
                {
                    //Just in case the object your hand is looking at is destroyed
                    if (GetGrabbable(lookingAtObj, out lookingAtGrab))
                    {
                        OnStopHighlight?.Invoke(this, lookingAtGrab);
                        lookingAtGrab.Unhighlight();
                    }

                    lookingAtObj   = null;
                    rotationOffset = Quaternion.identity;
                }
                //If you're seeing nothing reset offset
                else
                {
                    rotationOffset = Quaternion.identity;
                }
            }
            //If you're holding something reset offset
            else
            {
                rotationOffset = Quaternion.identity;
            }
        }
Esempio n. 4
0
        public GQuickHues(GHuePicker Picker, GBrightnessBar Brightness, GFlatButton Okay) : base(3, 0x57, 0x76, 20)
        {
            this.m_CompactHeight  = 20;
            this.m_ExpandedHeight = Engine.GameHeight / 2;
            this.m_Picker         = Picker;
            this.m_Brightness     = Brightness;
            this.m_Okay           = Okay;
            base.m_CanDrag        = false;
            this.m_Timer          = new Timer(new OnTick(this.Roll_OnTick), 0);
            GLabel toAdd = new GLabel("Quick Hues", Engine.GetUniFont(0), Hues.Default, 2, 2);

            this.Height          = 20;
            this.m_CompactHeight = base.m_Height;
            base.m_Children.Add(toAdd);
            toAdd.Center();
            QuickHues.Load();
            int         count   = QuickHues.Entries.Count;
            int         num2    = 0x16;
            Clipper     clipper = new Clipper(base.m_X + 1, base.m_Y + 1, base.m_Width - 2, base.m_Height - 2);
            GTextButton button  = new GTextButton("Create new..", Engine.GetUniFont(0), Hues.Default, Hues.Load(0x35), 2, 2, new OnClick(this.Add_OnClick));

            base.m_Children.Add(button);
            button.Center();
            button.Y = num2;
            button.Scissor(clipper);
            num2 += button.Height;
            OnClick     onClick   = new OnClick(this.Entry_OnClick);
            OnHighlight highlight = new OnHighlight(this.Entry_OnHighlight);

            for (int i = 0; i < count; i++)
            {
                QuickHueEntry entry   = (QuickHueEntry)QuickHues.Entries[i];
                GTextButton   button2 = new GTextButton(entry.Name, Engine.GetUniFont(0), Hues.Load(0x58), Hues.Load(0x35), 2, 2, onClick);
                base.m_Children.Add(button2);
                button2.Center();
                button2.Y = num2;
                button2.Scissor(clipper);
                button2.SetTag("HueID", entry.Hue);
                button2.SetTag("Index", i);
                num2 += button2.Height;
                button2.OnHighlight = highlight;
                button2.Tooltip     = new Tooltip(string.Format("0x{0:X}", entry.Hue));
            }
            num2 += 2;
            this.m_ExpandedHeight = num2;
        }
Esempio n. 5
0
 public GQuickHues(GHuePicker Picker, GBrightnessBar Brightness, GFlatButton Okay)
     : base(3, 0x57, 0x76, 20)
 {
     this.m_CompactHeight = 20;
     this.m_ExpandedHeight = Engine.GameHeight / 2;
     this.m_Picker = Picker;
     this.m_Brightness = Brightness;
     this.m_Okay = Okay;
     base.m_CanDrag = false;
     this.m_Timer = new Timer(new OnTick(this.Roll_OnTick), 0);
     GLabel toAdd = new GLabel("Quick Hues", Engine.GetUniFont(0), Hues.Default, 2, 2);
     this.Height = 20;
     this.m_CompactHeight = base.m_Height;
     base.m_Children.Add(toAdd);
     toAdd.Center();
     QuickHues.Load();
     int count = QuickHues.Entries.Count;
     int num2 = 0x16;
     Clipper clipper = new Clipper(base.m_X + 1, base.m_Y + 1, base.m_Width - 2, base.m_Height - 2);
     GTextButton button = new GTextButton("Create new..", Engine.GetUniFont(0), Hues.Default, Hues.Load(0x35), 2, 2, new OnClick(this.Add_OnClick));
     base.m_Children.Add(button);
     button.Center();
     button.Y = num2;
     button.Scissor(clipper);
     num2 += button.Height;
     OnClick onClick = new OnClick(this.Entry_OnClick);
     OnHighlight highlight = new OnHighlight(this.Entry_OnHighlight);
     for (int i = 0; i < count; i++)
     {
         QuickHueEntry entry = (QuickHueEntry) QuickHues.Entries[i];
         GTextButton button2 = new GTextButton(entry.Name, Engine.GetUniFont(0), Hues.Load(0x58), Hues.Load(0x35), 2, 2, onClick);
         base.m_Children.Add(button2);
         button2.Center();
         button2.Y = num2;
         button2.Scissor(clipper);
         button2.SetTag("HueID", entry.Hue);
         button2.SetTag("Index", i);
         num2 += button2.Height;
         button2.OnHighlight = highlight;
         button2.Tooltip = new Tooltip(string.Format("0x{0:X}", entry.Hue));
     }
     num2 += 2;
     this.m_ExpandedHeight = num2;
 }