Beispiel #1
0
 void checkForUserInput()
 {
     if (stylus.GetButton(0))
     {
         if (!point0)
         {
             point0    = stylusTip.transform;
             location0 = stylusTip.transform.position;
         }
         else if (!point1)
         {
             point1    = stylusTip.transform;
             location1 = stylusTip.transform.position;
         }
         else
         {
             endPoints.transform.localScale = new Vector3(.01f, .01f, .01f);
             createLine(location0, location1);
             if (pointSwitch)
             {
                 point0 = null;
             }
             else
             {
                 point1 = null;
             }
             pointSwitch = !pointSwitch;
         }
     }
     else if (stylus.GetButtonUp(0))
     {
         point0 = null;
         point1 = null;
     }
     else if (stylus.GetButtonDown(1))
     {
         if (colorNumber + 1 < colorArray.Length)
         {
             changeColor(++colorNumber);
         }
     }
     else if (stylus.GetButtonDown(2))
     {
         if (colorNumber - 1 >= 0)
         {
             changeColor(--colorNumber);
         }
     }
     else if (Input.GetKeyDown(KeyCode.C))
     {
         Destroy(container.gameObject);
         lineCount   = 0;
         objectCount = 0;
         container   = new GameObject("Drawing").transform;
     }
     else if (Input.GetKeyDown(KeyCode.Z))
     {
         Destroy(container.GetChild(container.childCount - 1).gameObject);
     }
 }
Beispiel #2
0
 // Update is called once per frame
 void Update()
 {
     if (stylus.GetButton(1))
     {
         rotateArm(arm2);
     }
     else if (stylus.GetButtonUp(1))
     {
         setVisibilityOfStylus(true);
     }
 }
    void OnPostRender()
    {
        bool isButtonDown = false;

        for (int i = 0; i < _stylusSelector.numButtons; ++i)
        {
            isButtonDown |= _stylusSelector.GetButton(i);
        }

        if (!isButtonDown)
        {
            Utility.RenderMeshes(_stylusSelector.HoverObject, hoveredMaterial);

            foreach (GameObject selectedObject in _stylusSelector.selectedObjects)
            {
                Utility.RenderMeshes(selectedObject, selectedMaterial);
            }
        }
    }
 void Update()
 {
     if (resetting)
     {
         Reset();
     }
     else if (Input.GetMouseButton(0))
     {
         Checker(Input.GetAxis("Mouse Y") * 5);
     }
     if (GameData.zSpace)
     {
         if (stylus.GetButton(0))
         {
             float newPos = firstTurn ? 0 : stylus.transform.position.y;
             Checker((newPos - oldPos) * 300);
             oldPos    = firstTurn ? stylus.transform.position.y : newPos;
             firstTurn = false;
         }
     }
 }
Beispiel #5
0
    void Update()
    {
        bool isButtonDown = _selectButtons.Aggregate(false, (isPressed, buttonId) => isPressed |= _stylusSelector.GetButtonDown(buttonId));

        if (isButtonDown)
        {
            if (_stylusSelector.HoverObject == null)
            {
                _startPosition = _stylusSelector.activeStylus.hotSpot;
                _startRotation = (_isAxisAligned) ? Quaternion.identity : _stylusSelector.activeStylus.transform.rotation;

                GetComponent <Collider>().enabled = true;
                GetComponent <Renderer>().enabled = true;
                transform.rotation = _startRotation;
            }
        }

        bool isButton = _selectButtons.Aggregate(false, (isPressed, buttonId) => isPressed |= _stylusSelector.GetButton(buttonId));

        if (isButton && GetComponent <Renderer>().enabled)
        {
            _endPosition = _stylusSelector.activeStylus.hotSpot;

            Vector3 diagonal = _endPosition - _startPosition;
            transform.localScale = Quaternion.Inverse(transform.rotation) * diagonal;
            transform.position   = 0.5f * (_endPosition + _startPosition);
        }

        bool isButtonUp = _selectButtons.Aggregate(false, (isPressed, buttonId) => isPressed |= _stylusSelector.GetButtonUp(buttonId));

        if (isButtonUp)
        {
            GetComponent <Collider>().enabled = false;
            GetComponent <Renderer>().enabled = false;
        }
    }