swipe almost finished

This commit is contained in:
esteb 2023-01-12 11:31:21 +01:00
parent 8cea51f47f
commit e02467b154

View File

@ -24,6 +24,7 @@ public class SwipeScript : MonoBehaviour
Button btnRight = arrowRight.GetComponent<Button>(); Button btnRight = arrowRight.GetComponent<Button>();
btnLeft.onClick.AddListener(PreviousText); btnLeft.onClick.AddListener(PreviousText);
btnRight.onClick.AddListener(NextText); btnRight.onClick.AddListener(NextText);
imageText.sprite = lengths[0];
} }
// Update is called once per frame // Update is called once per frame
@ -44,22 +45,33 @@ public class SwipeScript : MonoBehaviour
} }
private void NextText(){ private void NextText(){
if(numberImage < lengthTexts)
{
numberImage ++; numberImage ++;
if(numberImage == lengthTexts){ if(numberImage == lengthTexts){
arrowRight.gameObject.SetActive(false); arrowRight.gameObject.SetActive(false);
}else{ }else{
arrowRight.gameObject.SetActive(true); arrowRight.gameObject.SetActive(true);
} }
if(numberImage != 0){
arrowLeft.gameObject.SetActive(true);
}
imageText.sprite = lengths[numberImage]; imageText.sprite = lengths[numberImage];
} }
}
private void PreviousText(){ private void PreviousText(){
if(numberImage > 0) {
numberImage --; numberImage --;
if(numberImage == 0){ if(numberImage == 0){
arrowLeft.gameObject.SetActive(false); arrowLeft.gameObject.SetActive(false);
}else{ }else{
arrowLeft.gameObject.SetActive(true); arrowLeft.gameObject.SetActive(true);
} }
if(numberImage != lengthTexts){
arrowRight.gameObject.SetActive(true);
}
imageText.sprite = lengths[numberImage]; imageText.sprite = lengths[numberImage];
} }
} }
}