scanner 1 et 2 qui fonctionnent
This commit is contained in:
128
Assets/Scripts/SwipeManagementPCScript.cs
Normal file
128
Assets/Scripts/SwipeManagementPCScript.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
|
||||
public class SwipeManagementPCScript : MonoBehaviour
|
||||
{
|
||||
public TMP_Text textSteps;
|
||||
public TMP_Text textNumber;
|
||||
|
||||
public List<Text> lengths;
|
||||
public int numberImage;
|
||||
public int lengthTexts;
|
||||
|
||||
public GameObject arrowLeft;
|
||||
public GameObject arrowRight;
|
||||
|
||||
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()
|
||||
{
|
||||
textSteps.text = lengths[0].text;
|
||||
textNumber.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void NextText(){
|
||||
if(numberImage < lengthTexts)
|
||||
{
|
||||
numberImage ++;
|
||||
if(numberImage == 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;
|
||||
textNumber.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;
|
||||
textNumber.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 = "";
|
||||
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;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SwipeManagementPCScript.cs.meta
Normal file
11
Assets/Scripts/SwipeManagementPCScript.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73316d2510847254fbdd6e5eebf6e40f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -82,7 +82,7 @@ public class SwipeManagementScript : MonoBehaviour
|
||||
if(numberImage == 2)
|
||||
{
|
||||
header.text = "Initialisation : Sécurité";
|
||||
header2.text = "Initialisation : Sécurité";
|
||||
header2.text = "Initialisationzzzzz : Sécurité";
|
||||
arrow.SetActive(false);
|
||||
warning.SetActive(true);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,10 @@ public class UIRotation : MonoBehaviour
|
||||
{
|
||||
public GameObject canvas1;
|
||||
public GameObject canvas2;
|
||||
public GameObject stepup1;
|
||||
public GameObject card1;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -22,10 +21,8 @@ public class UIRotation : MonoBehaviour
|
||||
canvas1.SetActive(false);
|
||||
canvas2.SetActive(true);
|
||||
} else if(Input.deviceOrientation == DeviceOrientation.Portrait) {
|
||||
canvas2.SetActive(false);
|
||||
canvas1.SetActive(true);
|
||||
card1.SetActive(true);
|
||||
stepup1.SetActive(false);
|
||||
canvas2.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user