- Home /
Carousel or Swipe Menu
I want to do a specific kind of effect, a demo can be found HERE. It has a set of image(menu) that can be carouseled by swiping. It has bullet points to denote the currently selected menu. It also show the currently centered menu to be larger than the others.
I'm not sure what this effect is called, but I wish to know how to do it in Unity 5.
Currently I have something like this:
// menu items
public GameObject Quest;
public GameObject Vortex;
public GameObject RaidBattle;
public GameObject Randall;
public GameObject Arena;
// menu item bullets
public GameObject bulletQuest;
public GameObject bulletVortex;
public GameObject bulletRaidBattle;
public GameObject bulletRandall;
public GameObject bulletArena;
// other public
public GameObject centerPoint;
// private
private GameObject firstItem;
private GameObject lastItem;
private GameObject chosenItem;
private bool isHolding = false;
// quest is always the center menu on load
void Start () {
chosenItem = Quest;
}
void Update () {
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector2 touchPos = new Vector2(mousePos.x, mousePos.y);
// left click (should be touch)
if (Input.GetMouseButtonDown (0) && !isHolding) {
// check if collided with a sprite
if (chosenItem.GetComponent<BoxCollider2D>() == Physics2D.OverlapPoint(touchPos)) {
isHolding = true;
}
}
// release left click
if (Input.GetMouseButtonUp (0) && isHolding) isHolding = false;
// holding on
if (isHolding) {
transform.localPosition = new Vector3(mousePos.x, transform.localPosition.y, 1f);
}
// check collision between center and a menu
Debug.Log (centerPoint.GetComponent<BoxCollider2D>()) ;
}
But I'm already starting to get confused on what to do next. I guess I need to steply grow and shrink the localScale of the gameObjects but:
How do I know if which one is currently in the center?
How do I make it snap to the center?
How do I consider the force of the swipe to make it revolve per menu item?
Answer by Coder1983 · Jan 21, 2017 at 05:18 PM
You can try this asset. https://www.assetstore.unity3d.com/#!/content/79251
Your answer
Follow this Question
Related Questions
[Unity3d 5.1] Multiplayer - Multiple match - dedicated server 1 Answer
Audio doesn't play when "Play on awake" is unticked 0 Answers
Why is it taking Unity so long to process video's? 0 Answers
Trees that I painted on terrain are really dark and also missing parts in it's hirearchy... 0 Answers
What this error means? 1 Answer