This commit is contained in:
esteb
2023-01-12 10:01:44 +01:00
parent b27fecb9d1
commit 8cea51f47f
2 changed files with 12 additions and 9 deletions

View File

@@ -10,8 +10,8 @@ public class SwipeScript : MonoBehaviour
public int numberImage;
public int lengthTexts;
public GameObject arrowLeft;
public GameObject arrowRight;
public Button arrowLeft;
public Button arrowRight;
private Vector2 startTouchPosition;
@@ -20,7 +20,10 @@ public class SwipeScript : MonoBehaviour
// Start is called before the first frame update
void Start()
{
Button btnLeft = arrowLeft.GetComponent<Button>();
Button btnRight = arrowRight.GetComponent<Button>();
btnLeft.onClick.AddListener(PreviousText);
btnRight.onClick.AddListener(NextText);
}
// Update is called once per frame
@@ -43,9 +46,9 @@ public class SwipeScript : MonoBehaviour
private void NextText(){
numberImage ++;
if(numberImage == lengthTexts){
arrowRight.SetActive(false);
arrowRight.gameObject.SetActive(false);
}else{
arrowRight.SetActive(true);
arrowRight.gameObject.SetActive(true);
}
imageText.sprite = lengths[numberImage];
}
@@ -53,9 +56,9 @@ public class SwipeScript : MonoBehaviour
private void PreviousText(){
numberImage --;
if(numberImage == 0){
arrowLeft.SetActive(false);
arrowLeft.gameObject.SetActive(false);
}else{
arrowLeft.SetActive(true);
arrowLeft.gameObject.SetActive(true);
}
imageText.sprite = lengths[numberImage];
}