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} - {fileID: 21300000, guid: 16a85829eb6fea243b045f6d00d2e5a3, type: 3}
numberImage: 0 numberImage: 0
lengthTexts: 3 lengthTexts: 3
arrowLeft: {fileID: 1856408476} arrowLeft: {fileID: 1856408478}
arrowRight: {fileID: 1728270320} arrowRight: {fileID: 1728270322}
--- !u!1 &1248988450 --- !u!1 &1248988450
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

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