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

@ -655,8 +655,8 @@ MonoBehaviour:
- {fileID: 21300000, guid: 16a85829eb6fea243b045f6d00d2e5a3, type: 3}
numberImage: 0
lengthTexts: 3
arrowLeft: {fileID: 1856408476}
arrowRight: {fileID: 1728270320}
arrowLeft: {fileID: 1856408478}
arrowRight: {fileID: 1728270322}
--- !u!1 &1248988450
GameObject:
m_ObjectHideFlags: 0

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];
}