Exemplo n.º 1
0
    void CheckKeyCode(KeyCode code, int stringIndex)
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            for (int i = 0; i < 8; i++)
            {
                ControlInput.OnStringChange(i, true);
            }
        }

        if (Input.GetKeyUp(KeyCode.Space))
        {
            for (int i = 0; i < 8; i++)
            {
                ControlInput.OnStringChange(i, false);
            }
        }

        if (Input.GetKeyDown(code))
        {
            ControlInput.OnStringChange(stringIndex, true);
        }
        if (Input.GetKeyUp(code))
        {
            ControlInput.OnStringChange(stringIndex, false);
        }
        if (Input.GetKey(code) && ControlInput.IsButtonPressed(stringIndex) == false)
        {
            ControlInput.OnStringChange(stringIndex, true);
        }
    }
Exemplo n.º 2
0
    void Update()
    {
        for (int i = 0; i < ControlInput.NumStrings; ++i)
        {
            StringChanges[i] = false;
        }

        for (int i = 0; i < Input.touchCount; ++i)
        {
            Touch touch = Input.GetTouch(i);

            if (touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary)
            {
                Ray        ray = Camera.main.ScreenPointToRay(touch.position);
                RaycastHit hit;

                for (int j = 0; j < ControlInput.NumStrings; ++j)
                {
                    if (ControlInput.GetStringButton(j).GetComponent <Collider>().Raycast(ray, out hit, Mathf.Infinity))
                    {
                        StringChanges[j] = true;
                    }
                }
            }
        }

        for (int i = 0; i < ControlInput.NumStrings; ++i)
        {
            ControlInput.OnStringChange(i, StringChanges[i]);
        }
    }