void Start() { mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); centerCameraX = mainCamera.pixelWidth / 2; centerCameraY = mainCamera.pixelHeight / 2; rectTransform = GetComponent <RectTransform>(); scrollImage = scrollImageobject.GetComponent <ScrollImage>(); }
void shuffleRight(ScrollImage s) { GameObject[] shuffle = new GameObject[3] { s.images[1], s.images[2], s.images[0] }; s.images = shuffle; Vector3 newPos = s.images[1].transform.position; newPos.x += s.imageSize; s.images[2].transform.position = newPos; }
void shuffleImage(ScrollImage s) { Vector3 CameraPos = new Vector3(cameraRig.transform.position.x, 0, 0); Vector3 rightImage = new Vector3(s.images[2].transform.position.x, 0, 0); Vector3 leftImage = new Vector3(s.images[0].transform.position.x, 0, 0); if (Vector3.Distance(CameraPos, rightImage) < 1) { shuffleRight(s); } if (Vector3.Distance(CameraPos, leftImage) < 1) { shuffleLeft(s); } }
void followCamera(ScrollImage s) { s.imageHolder.transform.position = new Vector3(s.imageHolder.transform.position.x + test * s.scrollSpeed, s.imageHolder.transform.position.y, s.imageHolder.transform.position.z); }