예제 #1
0
 private void OnTriggerExit(Collider other)
 {
     if (grabbedObject)
     {
         SetCursor();
         grabbedObject.Focus(this, false);
         grabbedObject = null;
     }
 }
예제 #2
0
 private void TriggerReleased(object sender, ClickedEventArgs e)
 {
     if (grabbedVodget)
     {
         grabbedVodget.Button(this, ButtonType.Trigger, false);
         grabPoint     = Vector3.zero;
         grabbedVodget = null;
     }
 }
예제 #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (isFocusGrabbed)
        {
            return;
        }
        if (other.transform.gameObject.GetComponent <Vodget>())
        {
            Vodget hitVodget = other.transform.gameObject.GetComponent <Vodget>();
            SetCursor();

            // if there's no obj selected before
            if (grabbedObject == null)
            {
                grabPoint     = transform.position;
                grabbedObject = hitVodget;
                hitVodget.Focus(this, true);
            }

            // if the hit object is not the obj the one that selector previously focused
            else if (grabbedObject != other.transform.gameObject)
            {
                if (grabbedObject)
                {
                    grabbedObject.Focus(this, false);
                }

                grabbedObject = hitVodget;
                hitVodget.Focus(this, true);
                grabPoint = transform.position;
            }

            // if the hit object is the same as the obj
            else
            {
                //hitVodget.Focus(this, true);
            }
        }
    }
예제 #4
0
    // Update is called once per frame
    void Update()
    {
        if (!isFocusGrabbed)
        {
            if (Physics.Raycast(transform.position, transform.forward, out hit, int.MaxValue))
            {
                Vodget hitVodget = hit.transform.gameObject.GetComponent <Vodget>();
                if (hitVodget)
                {
                    // if there's no obj selected before
                    if (!hitVodget.isSelected)
                    {
                        if (grabbedVodget == null)
                        {
                            grabPoint     = hit.point;
                            grabbedVodget = hitVodget;
                            SetCursor();
                            hitVodget.Focus(this, true);
                        }

                        // if the hit object is not the obj the one that selector previously focused
                        else if (grabbedVodget != hitVodget)
                        {
                            if (grabbedVodget)
                            {
                                grabbedVodget.Focus(this, false);
                            }

                            grabbedVodget = hitVodget;
                            SetCursor();
                            hitVodget.Focus(this, true);
                            grabPoint = hit.point;
                        }
                    }
                }

                // ray hit, but not hitting at a vodget
                else
                {
                    if (grabbedVodget != null)
                    {
                        grabbedVodget.Focus(this, false);
                        grabbedVodget = null;
                    }
                }
            }

            //ray hit nothing
            else
            {
                //not shooting at any vodget
                if (grabbedVodget != null)
                {
                    SetCursor();
                    grabbedVodget.Focus(this, false);
                    grabbedVodget = null;
                }
            }
        }

        if (grabbedVodget)
        {
            SetCursor();
            grabbedVodget.FocusUpdate(this);
        }
    }