vite
This commit is contained in:
@@ -77,6 +77,7 @@ public class SwipeManagementScript : MonoBehaviour
|
||||
}
|
||||
}
|
||||
if(numberImage == 1){
|
||||
header.text = "Pour rappel : ";
|
||||
arrow.SetActive(true);
|
||||
warning.SetActive(false);
|
||||
}
|
||||
|
||||
@@ -4,34 +4,45 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
|
||||
public class SwipeScript : MonoBehaviour
|
||||
{
|
||||
public TMP_Text header;
|
||||
public TMP_Text textSteps;
|
||||
public List<Text> lengths;
|
||||
public int numberImage;
|
||||
public int lengthTexts;
|
||||
|
||||
public Button arrowLeft;
|
||||
public Button arrowRight;
|
||||
public Button quit;
|
||||
public GameObject arrowLeft;
|
||||
public GameObject arrowRight;
|
||||
|
||||
public GameObject canvas1;
|
||||
public GameObject canvas2;
|
||||
public Button buttonleft;
|
||||
public Button buttonright;
|
||||
|
||||
public Animator m_Animator;
|
||||
|
||||
public TMP_Text textNumber;
|
||||
|
||||
public List<int> images;
|
||||
|
||||
private Vector2 startTouchPosition;
|
||||
private Vector2 endTouchPosition;
|
||||
private Vector2 endTouchPosition;
|
||||
|
||||
private GameObject image;
|
||||
|
||||
private Image imageUI;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Button btnLeft = arrowLeft.GetComponent<Button>();
|
||||
Button btnRight = arrowRight.GetComponent<Button>();
|
||||
Button btnQuit = quit.GetComponent<Button>();
|
||||
header.text = "Allumer la Speedy 100";
|
||||
textSteps.text = lengths[0].text;
|
||||
textNumber.text = "Step 1/" + (lengthTexts+1);
|
||||
arrowLeft.gameObject.SetActive(false);
|
||||
Button btnLeft = buttonleft.GetComponent<Button>();
|
||||
Button btnRight = buttonright.GetComponent<Button>();
|
||||
btnLeft.onClick.AddListener(PreviousText);
|
||||
btnRight.onClick.AddListener(NextText);
|
||||
btnQuit.onClick.AddListener(Quit);
|
||||
textSteps.text = lengths[0].text;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -42,14 +53,15 @@ public class SwipeScript : MonoBehaviour
|
||||
}
|
||||
if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended){
|
||||
endTouchPosition = Input.GetTouch(0).position;
|
||||
/* if(endTouchPosition.x < startTouchPosition.x){
|
||||
if(endTouchPosition.x < startTouchPosition.x){
|
||||
NextText();
|
||||
}else{
|
||||
PreviousText();
|
||||
}*/
|
||||
if(endTouchPosition.y < startTouchPosition.y){
|
||||
}
|
||||
if(endTouchPosition.y + 100 < startTouchPosition.y){
|
||||
SwipeDown();
|
||||
} else {
|
||||
}
|
||||
if(endTouchPosition.y - 100 > startTouchPosition.y){
|
||||
SwipeUp();
|
||||
}
|
||||
}
|
||||
@@ -67,7 +79,15 @@ public class SwipeScript : MonoBehaviour
|
||||
if(numberImage != 0){
|
||||
arrowLeft.gameObject.SetActive(true);
|
||||
}
|
||||
textSteps.text = lengths[numberImage].text;
|
||||
if(images.Contains(numberImage - 1)){
|
||||
DisableImageStep();
|
||||
}
|
||||
if(images.Contains(numberImage)){
|
||||
SetImageStep();
|
||||
}else{
|
||||
textSteps.text = lengths[numberImage].text;
|
||||
textNumber.text = "Step" + (numberImage+1) + "/" + (lengthTexts+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,25 +101,37 @@ public class SwipeScript : MonoBehaviour
|
||||
}
|
||||
if(numberImage != lengthTexts){
|
||||
arrowRight.gameObject.SetActive(true);
|
||||
}
|
||||
textSteps.text = lengths[numberImage].text;
|
||||
}
|
||||
if(images.Contains(numberImage + 1)){
|
||||
DisableImageStep();
|
||||
}
|
||||
if(images.Contains(numberImage)){
|
||||
SetImageStep();
|
||||
}else{
|
||||
textSteps.text = lengths[numberImage].text;
|
||||
textNumber.text = "Step" + (numberImage+1) + "/" + (lengthTexts+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Quit(){
|
||||
canvas1.SetActive(false);
|
||||
canvas2.SetActive(false);
|
||||
}
|
||||
public void Enter(){
|
||||
canvas1.SetActive(true);
|
||||
canvas2.SetActive(true);
|
||||
Debug.Log("Hello: ");
|
||||
}
|
||||
|
||||
private void SwipeDown(){
|
||||
PreviousText();
|
||||
m_Animator.ResetTrigger("SwipeUp");
|
||||
m_Animator.SetTrigger("SwipeDown");
|
||||
}
|
||||
private void SwipeUp(){
|
||||
NextText();
|
||||
m_Animator.ResetTrigger("SwipeDown");
|
||||
m_Animator.SetTrigger("SwipeUp");
|
||||
}
|
||||
|
||||
private void SetImageStep(){
|
||||
textSteps.text = "";
|
||||
textNumber.text = "Step" + (numberImage+1) + "/" + (lengthTexts+1);
|
||||
image = GameObject.Find("Image"+ numberImage);
|
||||
imageUI = image.GetComponent<Image>();
|
||||
imageUI.enabled = true;
|
||||
}
|
||||
|
||||
private void DisableImageStep(){
|
||||
imageUI.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user