Пример #1
0
        private int rightSideFingerID = 0;       // unique finger id for touches on the right-side half of the screen

        void Start()
        {
            if (DPadTouchLeftJoystick.LeftJoystick.GetComponent <DPadTouchLeft>() == null)
            {
                Debug.LogError("There is no DPadTouchLeft script attached to the Left Joystick game object.");
            }
            else
            {
                DPadTouchLeft = DPadTouchLeftJoystick.LeftJoystick.GetComponent <DPadTouchLeft>();                         // gets the left joystick script
                DPadTouchLeft.joystickStaysInFixedPosition = DPadTouchLeftJoystick.isFixedPosition;
                DPadTouchLeftJoystick.LeftJoystick.GetComponent <Image>().enabled = DPadTouchLeftJoystick.isAlwaysVisible; // sets left joystick background image to be always visible or not
            }

            if (DPadTouchLeft.transform.GetChild(0).GetComponent <Image>() == null)
            {
                Debug.LogError("There is no left joystick handle image attached to this script.");
            }
            else
            {
                DPadTouchLeftHandleImage         = DPadTouchLeft.transform.GetChild(0).GetComponent <Image>(); // gets the handle (knob) image of the left joystick
                DPadTouchLeftHandleImage.enabled = DPadTouchLeftJoystick.isAlwaysVisible;                      // sets left joystick handle (knob) image to be always visible or not
            }


            if (DPadTouchRightJoystick.RightJoystick.GetComponent <DPadTouchRight>() == null)
            {
                Debug.LogError("There is no DPadTouchRight script attached to Right Joystick game object.");
            }
            else
            {
                DPadTouchRight = DPadTouchRightJoystick.RightJoystick.GetComponent <DPadTouchRight>();                        // gets the right joystick script
                DPadTouchRight.joystickStaysInFixedPosition = DPadTouchRightJoystick.isFixedPosition;
                DPadTouchRightJoystick.RightJoystick.GetComponent <Image>().enabled = DPadTouchRightJoystick.isAlwaysVisible; // sets right joystick background image to be always visible or not
            }

            if (DPadTouchRight.transform.GetChild(0).GetComponent <Image>() == null)
            {
                Debug.LogError("There is no right joystick handle attached to this script.");
            }
            else
            {
                DPadTouchRightHandleImage         = DPadTouchRight.transform.GetChild(0).GetComponent <Image>(); // gets the handle (knob) image of the right joystick
                DPadTouchRightHandleImage.enabled = DPadTouchRightJoystick.isAlwaysVisible;                      // sets right joystick handle (knob) image to be always visible or not
            }

            if (!DPadTouchLeftJoystick.isEnabled)
            {
                DPadTouchLeftJoystick.LeftJoystick.SetActive(false);
            }
            if (!DPadTouchRightJoystick.isEnabled)
            {
                DPadTouchRightJoystick.RightJoystick.SetActive(false);
            }
        }