- Home /
How to show and hide an image by swiping
Hi.
I am very new to unity, building a sliding project. A powerpoint like game on android, basically, I have 2D scenes with animations set up. I have images that are acting as different pages of the comic. Currently, I used canvas and buttons and scripts to switch scenes as I tap on the main page, which takes me to detailed view of each 2D scene.
I am trying to make a method of navigation by swiping which shows and hides the image. I have no clue what I am coding, I spent 7 hours so far trying to understand other people's code that does something similar. If anyone can give me some hints or codes that would be great.
Goal: Swipe left = hides current image and shows previous image swipe right = hides current image shows next image
I also seem to have no idea of where to attach the script, do I attach it to the canvas?
here is my code for the button which shows and hide images :
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems;
public class SwitchScene : MonoBehaviour { public GameObject[] ToShowScene; public GameObject[] ToHideScene;
public void Instatiate(){ for(int i = 0 ; i < ToShowScene.Length;i++){ ToShowScene.SetActive(true); }
for(int i = 0 ; i < ToHideScene.Length;i++){ ToHideScene.SetActive(false); Debug.Log("yahoo"); }
} }
Many thanks.
Your answer
Follow this Question
Related Questions
Unity Touch Help! 0 Answers
Reset touch Vector after movement 2 Answers
check touch position 2 Answers
A touch'es state is always Began and the position doesn't change 1 Answer