generated from VR-Sexe/Unity3DTemplate
213 lines
6.9 KiB
C#
213 lines
6.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
|
|
public class SwipeManagementScript : MonoBehaviour
|
|
{
|
|
public TMP_Text header;
|
|
public TMP_Text textSteps;
|
|
public TMP_Text textNumber;
|
|
|
|
public TMP_Text header2;
|
|
public TMP_Text textSteps2;
|
|
public TMP_Text textNumber2;
|
|
|
|
public List<Text> lengths;
|
|
public int numberImage;
|
|
public int lengthTexts;
|
|
|
|
public GameObject arrowLeft;
|
|
public GameObject arrowRight;
|
|
|
|
public GameObject arrow;
|
|
public GameObject arrowGravure;
|
|
public GameObject arrowXY;
|
|
public GameObject arrowHB;
|
|
public GameObject arrowPause;
|
|
|
|
public GameObject warning;
|
|
|
|
public Animator m_Animator;
|
|
|
|
public List<int> images;
|
|
|
|
private Vector2 startTouchPosition;
|
|
private Vector2 endTouchPosition;
|
|
|
|
private GameObject image;
|
|
private Image imageUI;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
header.text = "Allumer la Speedy 100";
|
|
header2.text = "Allumer la Speedy 100";
|
|
textSteps.text = lengths[0].text;
|
|
textSteps2.text = lengths[0].text;
|
|
textNumber.text = "Step 1/" + (lengthTexts+1);
|
|
textNumber2.text = "Step 1/" + (lengthTexts+1);
|
|
arrowLeft.gameObject.SetActive(false);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began){
|
|
startTouchPosition = Input.GetTouch(0).position;
|
|
}
|
|
if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended){
|
|
endTouchPosition = Input.GetTouch(0).position;
|
|
if(endTouchPosition.x < startTouchPosition.x){
|
|
NextText();
|
|
}else{
|
|
PreviousText();
|
|
}
|
|
if(endTouchPosition.y + 80 < startTouchPosition.y){
|
|
SwipeDown();
|
|
}
|
|
if(endTouchPosition.y - 80 > startTouchPosition.y){
|
|
SwipeUp();
|
|
}
|
|
}
|
|
if(numberImage == 1){
|
|
header.text = "Pour rappel : ";
|
|
header2.text = "Pour rappel : ";
|
|
arrow.SetActive(true);
|
|
warning.SetActive(false);
|
|
}
|
|
if(numberImage == 2)
|
|
{
|
|
header.text = "Initialisation : Sécurité";
|
|
header2.text = "Initialisation : Sécurité";
|
|
arrow.SetActive(false);
|
|
warning.SetActive(true);
|
|
}
|
|
if(numberImage == 3)
|
|
{
|
|
header.text = "Initialisation : Positionnement automatique";
|
|
header2.text = "Initialisation : Positionnement automatique";
|
|
warning.SetActive(false);
|
|
}
|
|
if(numberImage == 4)
|
|
{
|
|
header.text = "Placer la pièce à graver";
|
|
header2.text = "Placer la pièce à graver";
|
|
arrowGravure.SetActive(true);
|
|
arrowXY.SetActive(false);
|
|
}
|
|
if(numberImage == 5)
|
|
{
|
|
header.text = "Mise au point : Tête de traitement";
|
|
header2.text = "Mise au point : Tête de traitement";
|
|
arrowGravure.SetActive(false);
|
|
arrowXY.SetActive(true);
|
|
}
|
|
if(numberImage == 7)
|
|
{
|
|
header.text = "Mise au point : Outil focal";
|
|
header2.text = "Mise au point : Outil focal";
|
|
arrowXY.SetActive(false);
|
|
arrowHB.SetActive(false);
|
|
}
|
|
if(numberImage == 8){
|
|
header.text = "Mise au point : Table de gravure";
|
|
header2.text = "Mise au point : Table de gravure";
|
|
arrowHB.SetActive(true);
|
|
}
|
|
if(numberImage == 10){
|
|
header.text = "Mise au point : Position du laser";
|
|
header2.text = "Mise au point : Position du laser";
|
|
arrowHB.SetActive(false);
|
|
arrowXY.SetActive(true);
|
|
}
|
|
if(numberImage == 11){
|
|
header.text = "Procédure sur ordinateur";
|
|
header2.text = "Procédure sur ordinateur";
|
|
arrowXY.SetActive(false);
|
|
arrowPause.SetActive(false);
|
|
}
|
|
if(numberImage == 12){
|
|
header.text = "Suivre la découpe";
|
|
header2.text = "Suivre la découpe";
|
|
arrowPause.SetActive(true);
|
|
}
|
|
}
|
|
|
|
private void NextText(){
|
|
if(numberImage < lengthTexts)
|
|
{
|
|
numberImage ++;
|
|
if(numberImage +1 == lengthTexts){
|
|
arrowRight.gameObject.SetActive(false);
|
|
}else{
|
|
arrowRight.gameObject.SetActive(true);
|
|
}
|
|
if(numberImage != 0){
|
|
arrowLeft.gameObject.SetActive(true);
|
|
}
|
|
if(images.Contains(numberImage - 1)){
|
|
DisableImageStep();
|
|
}
|
|
if(images.Contains(numberImage)){
|
|
SetImageStep();
|
|
}else{
|
|
textSteps.text = lengths[numberImage].text;
|
|
textSteps2.text = lengths[numberImage].text;
|
|
textNumber.text = "Step" + (numberImage+1) + "/" + (lengthTexts+1);
|
|
textNumber2.text = "Step" + (numberImage+1) + "/" + (lengthTexts+1);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void PreviousText(){
|
|
if(numberImage > 0) {
|
|
numberImage --;
|
|
if(numberImage == 0){
|
|
arrowLeft.gameObject.SetActive(false);
|
|
}else{
|
|
arrowLeft.gameObject.SetActive(true);
|
|
}
|
|
if(numberImage != lengthTexts){
|
|
arrowRight.gameObject.SetActive(true);
|
|
}
|
|
if(images.Contains(numberImage + 1)){
|
|
DisableImageStep();
|
|
}
|
|
if(images.Contains(numberImage)){
|
|
SetImageStep();
|
|
}else{
|
|
textSteps.text = lengths[numberImage].text;
|
|
textSteps2.text = lengths[numberImage].text;
|
|
textNumber.text = "Step" + (numberImage+1) + "/" + (lengthTexts+1);
|
|
textNumber2.text = "Step" + (numberImage+1) + "/" + (lengthTexts+1);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void SwipeDown(){
|
|
m_Animator.ResetTrigger("SwipeUp");
|
|
m_Animator.SetTrigger("SwipeDown");
|
|
}
|
|
private void SwipeUp(){
|
|
m_Animator.ResetTrigger("SwipeDown");
|
|
m_Animator.SetTrigger("SwipeUp");
|
|
}
|
|
|
|
private void SetImageStep(){
|
|
textSteps.text = "";
|
|
textSteps2.text = "";
|
|
textNumber.text = "Step" + (numberImage+1) + "/" + (lengthTexts+1);
|
|
textNumber2.text = "Step" + (numberImage+1) + "/" + (lengthTexts+1);
|
|
image = GameObject.Find("Image"+ numberImage);
|
|
imageUI = image.GetComponent<Image>();
|
|
imageUI.enabled = true;
|
|
}
|
|
|
|
private void DisableImageStep(){
|
|
imageUI.enabled = false;
|
|
}
|
|
}
|