Example #1
0
    void Start()
    {
        isJoystickTouched = false;
        //if (singleJoystickBackgroundImage.GetComponent<ColorJoystick>() == null)
        //{
        //    Debug.LogError("There is no joystick attached to this script.");
        //}
        //else
        //{
        //    colorJoystick = singleJoystickBackgroundImage.GetComponent<ColorJoystick>(); // gets the single joystick script
        //    singleJoystickBackgroundImage.enabled = singleJoyStickAlwaysVisible; // sets single joystick background image to be always visible or not
        //}
        joystick      = GameObject.FindWithTag("ColorJoystick");
        colorJoystick = joystick.GetComponent <ColorJoystick>();
        paintManager  = GameObject.FindWithTag("PaintManager").GetComponent <PaintManager>();
        scaleVector   = new Vector3(scaleFactor, scaleFactor, scaleFactor);

        if (colorJoystick == null)
        {
            Debug.LogError("There is no joystick attached to this script.");
        }
        else
        {
            colorJoystick.GetComponent <ColorJoystick>();                        // gets the color joystick script
            singleJoystickBackgroundImage.enabled = singleJoyStickAlwaysVisible; // sets single joystick background image to be always visible or not
        }

        if (colorJoystick.transform.GetChild(0).GetComponent <Image>() == null)
        {
            Debug.LogError("There is no joystick handle (knob) attached to this script.");
        }
        else
        {
            singleJoystickHandleImage         = colorJoystick.transform.GetChild(0).GetComponent <Image>(); // gets the handle (knob) image of the single joystick
            singleJoystickHandleImage.enabled = singleJoyStickAlwaysVisible;                                // sets single joystick handle (knob) image to be always visible or not
        }
        initialPosition = joystick.transform.localPosition;
        shift           = (200f * scaleFactor) * 0.5f - 100f; // assuming button width = 200
    }
Example #2
0
        protected override void Start()
        {
            RectButton rectButton = SkiaBehaviourEngine.Instantiate <RectButton>();

            rectButton.RectTransform.AnchorMax = new SKPoint(0, 0);
            rectButton.RectTransform.AnchorMin = new SKPoint(0, 0);
            rectButton.RectTransform.OffsetMax = new SKPoint(1000, 1000);
            rectButton.RectTransform.OffsetMin = new SKPoint(500, 250);

            ColorJoystick colorJoystick = SkiaBehaviourEngine.Instantiate <ColorJoystick>();

            colorJoystick.RectTransform.AnchorMax = new SKPoint(0, 0);
            colorJoystick.RectTransform.AnchorMin = new SKPoint(0, 0);
            colorJoystick.RectTransform.OffsetMax = new SKPoint(2000, 500);
            colorJoystick.RectTransform.OffsetMin = new SKPoint(500, 250);

            /*
             * RectButton rectButton = SkiaBehaviourEngine.Instantiate<RectButton>();
             * rectButton.RectTransform.AnchorMin = new SKPoint(0, 0);
             * rectButton.RectTransform.AnchorMax = new SKPoint(0, 0);
             * rectButton.RectTransform.OffsetMin = new SKPoint(33.49999f, 33);
             * rectButton.RectTransform.OffsetMax = new SKPoint(143.9f, 80);*/

            RectButton rectButton2 = SkiaBehaviourEngine.Instantiate <RectButton>();

            rectButton2.RectTransform.AnchorMin = new SKPoint(1, 0);
            rectButton2.RectTransform.AnchorMax = new SKPoint(1, 0);
            rectButton2.RectTransform.OffsetMin = new SKPoint(-148.9f, 27.79999f);
            rectButton2.RectTransform.OffsetMax = new SKPoint(-38.49998f, 74.79999f);
            RectButton rectButton3 = SkiaBehaviourEngine.Instantiate <RectButton>();

            rectButton3.RectTransform.AnchorMin = new SKPoint(0.5f, 1);
            rectButton3.RectTransform.AnchorMax = new SKPoint(0.5f, 1);
            rectButton3.RectTransform.OffsetMin = new SKPoint(-47.8f, -102.4f);
            rectButton3.RectTransform.OffsetMax = new SKPoint(62.59999f, -55.40002f);
        }