void Awake () { if(!swipeCtrl) swipeCtrl = gameObject.GetComponent<SwipeControlXY>(); //Find SwipeControl on same GameObject if none given if(imgRect == new Rect(0,0,0,0)) { //If no rect given, create default rect imgRect = new Rect(-img[0].width * 0.5f, -img[0].height * 0.5f, img[0].width, img[0].height); } //Set up SwipeControl swipeCtrl.pxDistBetweenValues.x = img[0].width; swipeCtrl.pxDistBetweenValues.y = img[0].height; swipeCtrl.maxValue.x = 0; swipeCtrl.maxValue.y = img.GetLength(0) - 1; if(expandInputAreaToFullHeight) { swipeCtrl.SetActiveArea(new Rect(imgRect.x, -Screen.height * 0.5f, imgRect.width, Screen.height)); // Use image-height for the input-Rect, but full screen-width } else { swipeCtrl.SetActiveArea(imgRect); //Use the same Rect as the images for input } swipeCtrl.CalculateEdgeRectsFromActiveArea(imgRect); swipeCtrl.Setup(); //Determine center position of the Dots if(dotRelativeCenterPos == Vector2.zero) dotRelativeCenterPos.x = imgRect.width * 0.5f + 14f; dotRelativeCenterPos = new Vector2((imgRect.x + imgRect.width * 0.5f) + dotRelativeCenterPos.x, (imgRect.y + imgRect.height * 0.5f) + dotRelativeCenterPos.y); if(centerMatrixOnScreen) { matrixPosition.x += Mathf.Round(Screen.width * 0.5f); matrixPosition.y += Mathf.Round(Screen.height * 0.5f); } }
void Awake() { if (!swipeCtrl) { swipeCtrl = gameObject.GetComponent <SwipeControlXY>(); //Find SwipeControl on same GameObject if none given } if (imgRect == new Rect(0, 0, 0, 0)) //If no rect given, create default rect { imgRect = new Rect(-img[0].width * 0.5f, -img[0].height * 0.5f, img[0].width, img[0].height); } //Set up SwipeControl swipeCtrl.pxDistBetweenValues.x = img[0].width; swipeCtrl.pxDistBetweenValues.y = 0; swipeCtrl.maxValue.x = img.Length - 1; swipeCtrl.maxValue.y = 0; if (expandInputAreaToFullWidth) { swipeCtrl.SetActiveArea(new Rect(-Screen.width * 0.5f, imgRect.y, Screen.width, imgRect.height)); // Use image-height for the input-Rect, but full screen-width } else { swipeCtrl.SetActiveArea(imgRect); //Use the same Rect as the images for input } swipeCtrl.CalculateEdgeRectsFromActiveArea(imgRect); swipeCtrl.Setup(); //Determine center position of the Dots if (dotRelativeCenterPos == Vector2.zero) { dotRelativeCenterPos.y = imgRect.height * 0.5f + 14f; } dotRelativeCenterPos = new Vector2((imgRect.x + imgRect.width * 0.5f) + dotRelativeCenterPos.x, (imgRect.y + imgRect.height * 0.5f) + dotRelativeCenterPos.y); if (centerMatrixOnScreen) { matrixPosition.x += Mathf.Round(Screen.width * 0.5f); matrixPosition.y += Mathf.Round(Screen.height * 0.5f); } }