- Home /
How to create image slider using unity
I have created one unity app with vuforia plugin. App contains image target to view an object and play video. I need one more feature to create gallery view from image target. I want to create something like this https://www.youtube.com/watch?v=LhwhELJgdX4&feature=youtu.be&t=85 Please give me some instruction how to make gallery view using vuforia. Please share any tutorial link or sample app with me. Thanks in advance.
Answer by junedmmn · Sep 25, 2018 at 04:24 PM
You can use IEnumerator or use Update(). This is the simple code that I am using. You can modify the code as per you requirement. This is a sample code just to get the idea. This is the simplest method that I used
public class SlideImage
{
public Transform currentPlayer;
IEnumerator SlideImagesLeft()
{
while (currentPlayer.position.x > targetPosition.x)
{
currentPlayer.position = Vector3.MoveTowards(currentPlayer.position, targetPosition, 1000f * Time.deltaTime);
yield return null;
}
}
}
If you are using Update while loop must be removed just currentPlayer.position = Vector3.MoveTowards(currentPlayer.position, targetPosition, 1000f * Time.deltaTime); is important in Update(). Don't forget to attach Image or any Rect Transform to the currentPlayer in the Unity Inspector