void SetupPlayerJoyStick()
    {
        GameObject canvas = GameObject.FindWithTag("MainCanvas");

        moveJoystick = Instantiate(moveJoystick_Prefab, Vector3.zero, Quaternion.identity) as VirtualJoystick;
        moveJoystick.transform.SetParent(canvas.transform);
        moveJoystick.transform.localScale = new Vector3(1, 1, 1);
        moveJoystick.GetComponent <RectTransform>().anchoredPosition = new Vector2(100, 100);
    }
Ejemplo n.º 2
0
        private IEnumerator getTopOfJoystickInPixels()
        {
            yield return(new WaitForSeconds(1f));

            if (joystick != null)
            {
                RectTransform component = joystick.GetComponent <RectTransform>();
                Vector3[]     array     = new Vector3[4];
                component.GetWorldCorners(array);
                topOfJoystickInPixels = (int)array[1].y;
            }
        }