Very good script, only thing I would change is some optimization to reduce the declaration of variables on update and for loops, like maybe a check or a variable with the current level stored so you aren’t looping through so much. Could save processing power (and battery life for mobile)
Hello. Amazing tutorial, but I have a question: How can scroll bar be more flexible? So when I touch to left side scroll bar is moving only for one level, but how it to be more flexible (to scroll more than one level)
Thank you for this video, it saves me a lot! If I change the horizontal scrolling to vertical, everything seems off... Can anyone please give me some guidance or resource to refer? Much appreciated.
Love this -- thanks a ton! BUT... :) ... the update loop is really heavy, constantly updating the UI even when it's not necessary (=nothing is touched/scrolled etc). I'm trying to optimize it (unsuccessful to this point), any idea would be appreciated!
A bit late, but I got it working with OnEndDrag function (the script needs to be attached to the ScrollView) and using DOTween to animate the movement once the user stopped moving the scrollbar. I can maybe post the code somewhere if you want (I also added the possibility to click the buttons directly to move there)
I am getting this error CS1061: 'float[]' does not contain a definition for 'length' and no accessible extension method 'length' accepting a first argument of type 'float[]' could be found (are you missing a using directive or an assembly reference?)
Guys i have an issue when i apply the script my sprites becomes invisible i want to put a sprite in those buttons for levels EDIT: this tutorial works for world space camera canvas but i want to work with screenoverlayspace EDIT2: i FIXED IT BY SETTING ORDER LAYER AS 999
@@akbar.project bro can you tell me how to make the level pop like if i know ive won certain level how to start this menu screen from that position for instance if i won level 1 how to move the Content gameobject through script ?
@@ko.vurado i know its a late reply , try adding a sorting layer in your gameobject or adding a child canvas in your main canvas and tweak the sorting order
Set the selected position child and create a new color for it and apply it. Don't forget to make the main one full color again. In second to last if. transform.GetChild(i).GetComponent().color = new Color(transform.GetChild(i).GetComponent().color.r, transform.GetChild(i).GetComponent().color.g, transform.GetChild(i).GetComponent().color.b, 1f); In last if. transform.GetChild(a).GetComponent().color = new Color(transform.GetChild(a).GetComponent().color.r, transform.GetChild(a).GetComponent().color.g, transform.GetChild(a).GetComponent().color.b, 0.5f);
Hi. this video helped a lot to my project. and Thanks... Can we move next Level little bit faster? when we swipe the screen it goes next level hardly. I needed to swipe almost half of the screen to go next level. so Can you move it earlier like when we swipe just around 1/3 of the screen it can go next one... Is it possible?
any idea how i can use this in VR and program the swipe using the Vive pro controller? I hope to get a few feedback from u guys! as I'm using it for my school project! this will help a lot!!
I found a way to accomplish the desired effect by adjusting the local scale of the children based on the scrollbar's position while maintaining the required "Screen Space - Overlay" render mode. for (int i = 0; i < pos.Length; i++) { if (scroll_pos < pos[i] + (distance / 2) && scroll_pos > pos[i] - (distance / 2)) { // Scale the current child to 1f, 1f, 1f transform.GetChild(i).localScale = Vector3.Lerp(transform.GetChild(i).localScale, new Vector3(1f, 1f, 1f), 0.1f);
// Scale all other children to 0.8f, 0.8f, 1f for (int a = 0; a < pos.Length; a++) { if (a != i) { transform.GetChild(a).localScale = Vector3.Lerp(transform.GetChild(a).localScale, new Vector3(0.8f, 0.8f, 1f), 0.1f); } }
I think this is because you use Vector2 instead of Vector3 so z is set to 0 try Vector3.Lerp(transform.GetChild(i).localScale, new Vector3(1.2f, 1.2f,1.2f), 0.1f); and Vector3.Lerp(transform.GetChild(j).localScale, new Vector3(0.8f, 0.8f,0.8f), 0.1f);
Kalau swipe nya pakai button gimana kak y, contoh nya ada 2 button yang satu untuk swipe ke kiri dan tang satu ke kanan, please buatkan tutorialnya kak,
bro can you tell me how to make the level pop like if i know ive won certain level how to start this menu screen from that position for instance if i won level 1 how to move the Content gameobject through script ?
After doing some more research on this with different screen resolutions. It does not adapt well as far as I am seeing. Is there something I am missing maybe?
Download Master Project (Unity3D 2018.4.36f)
sociabuzz.com/akbar_project/p/swipe-menu-control-master-project
I literally positioned each item manually. Content Size Fitter is miracle
I never feel the need to comment on anything...but damn this is a great tutorial!!!
Very good script, only thing I would change is some optimization to reduce the declaration of variables on update and for loops, like maybe a check or a variable with the current level stored so you aren’t looping through so much. Could save processing power (and battery life for mobile)
SUPER HELPFUL! This is like the only video on this topic! gj mate, ur a hero
bro you done it very well.... but if you explain the scrip instead of music it will be fantastic and more helpful for us
WoW! Thanks!!
from Brazil!
Дай бог тебе здоровья, добрый человек)
У меня почему то камера возвращается не знаешь почему?
А вдруг он по нашему не понимает
My focus does not change on the 2nd button when i scroll .. help plz
the best guide from the best person.
This is 2021 and it's still working :) thanks.
Hello. Amazing tutorial, but I have a question: How can scroll bar be more flexible? So when I touch to left side scroll bar is moving only for one level, but how it to be more flexible (to scroll more than one level)
Anyone know how to start the menu at a specific panel? Like if I want to start on Panel 2 instead of Panel 1??
Up! I have the same question. Any answer will be much appreciated
How do you implement this vertically. It completely broke when I tried to do it.
Exactly what i was looking for mate. TYVVM.
It's work on android ??
this tutorial is gold, thanks.
Excelente tutorial, muchas gracias, saludos desde Colombia
Hey, thank you for the tutorial. May I know how to add sound in between each button, while swiping?
I want selected level to be centered in the screen but I couldn't. How can I do that?
How can I controll this with buttons?
one should move it to the next left the other to the next right pls help
The best, thank you, you helped me a lot.
Thank you for this video, it saves me a lot! If I change the horizontal scrolling to vertical, everything seems off... Can anyone please give me some guidance or resource to refer? Much appreciated.
the tut was amazing, thx dude
Jan e jigar tum tu cha gye🥰
Love this -- thanks a ton! BUT... :) ... the update loop is really heavy, constantly updating the UI even when it's not necessary (=nothing is touched/scrolled etc). I'm trying to optimize it (unsuccessful to this point), any idea would be appreciated!
A bit late, but I got it working with OnEndDrag function (the script needs to be attached to the ScrollView) and using DOTween to animate the movement once the user stopped moving the scrollbar. I can maybe post the code somewhere if you want (I also added the possibility to click the buttons directly to move there)
@@Adriankaroshi Please do post the code
@@Adriankaroshi hi, will appreciate if you do post the code :)
using UnityEngine;
using UnityEngine.EventSystems;
using DG.Tweening;
using UnityEngine.UI;
public class SwipeControl : MonoBehaviour, IEndDragHandler
{
[SerializeField] private Scrollbar scrollbar;
[SerializeField] private Transform content;
private float[] pos;
private float distance;
void Start()
{
pos = new float[content.childCount];
distance = 1f / (pos.Length - 1f);
for (int i = 0; i < pos.Length; i++)
{
pos[i] = distance * i;
}
scrollbar.value = 0.5f;
}
// Implementing IEndDragHandler interface
public void OnEndDrag(PointerEventData eventData)
{
float nearestPos = FindNearestPosition();
Debug.Log(nearestPos);
scrollbar.value = nearestPos;
AnimateToNearest(nearestPos);
}
float FindNearestPosition()
{
float nearest = pos[0];
float distanceToNearest = Mathf.Abs(scrollbar.value - pos[0]);
for (int i = 1; i < pos.Length; i++)
{
float distanceToCurrent = Mathf.Abs(scrollbar.value - pos[i]);
if (distanceToCurrent < distanceToNearest)
{
nearest = pos[i];
distanceToNearest = distanceToCurrent;
}
}
return nearest;
}
void AnimateToNearest(float targetPos)
{
int index = pos.Length - 1 - System.Array.IndexOf(pos, targetPos);
for (int i = 0; i < content.childCount; i++)
{
Transform child = content.GetChild(i);
float scale = i == index ? 1f : 0.8f;
child.DOScale(new Vector2(scale, scale), 0.3f);
}
}
}
Script needs to be at scrollView object.
Good Video, I used to load weapons that are equipped
Still possible to full screen the level 1 level 2?
Image?
Very nice worke my friend. I can say you Thanks for this is working. I'm Real learnin new menu with scroll))))
Thanks for useful video.
I am getting this error CS1061: 'float[]' does not contain a definition for 'length' and no accessible extension method 'length' accepting a first argument of type 'float[]' could be found (are you missing a using directive or an assembly reference?)
excelent post.
this works with AR? Incredible video!
very usefull, percise and effective
Guys i have an issue when i apply the script my sprites becomes invisible i want to put a sprite in those buttons for levels
EDIT: this tutorial works for world space camera canvas but i want to work with screenoverlayspace
EDIT2: i FIXED IT BY SETTING ORDER LAYER AS 999
Use image, not spriterenderer
@@akbar.project bro can you tell me how to make the level pop like if i know ive won certain level how to start this menu screen from that position for instance if i won level 1 how to move the Content gameobject through script ?
Hi, I understand that a lot of time has passed since your comment, but could you tell me where you set this value (order in l. 999)
@@ko.vurado i know its a late reply , try adding a sorting layer in your gameobject or adding a child canvas in your main canvas and tweak the sorting order
How to make it that when clicked zoom in and focus on that button?
I am using this for my shop, is there a way to fill the swipe menu using scriptable objects?
Thanks for tutorial it really help me!!
is it applicable for mobile?
Do you know if it is possible to make it loop (endless) ?
scrolling up and down doesn't work can you help please
Scroll bar Always set active false.
I can swipe menu.But it comes back originial position.
You’ve got a like and a new sub!
Thanks for this tutorial!
Very useful tutorial thanks!
hi bro , can you make a tutorial like this but for vertical layout?
Really clever. Well done 👍
will it work on android? by swiping?
Hi Akbar
I would like to know how I can put buttons on the sides? () to move the items when clicking, thanks
th-cam.com/video/eQPmFnREBL4/w-d-xo.html
@@akbar.project Gracias, gan
can anyone explain the distance variable why is it created what does it represent ?
how we can move the same thing using left / right button .
Thanks for the great tutorial!
best tutorial ever
when i click play button, my button images are dissapear. why?
Mouse wheel scroll not working. How to fix it?
why this isn't working on my menu?? the reason is float does not contain a definition of length?.
what if i want to make it vertical? can you help me?
have you been able to do it for vertical?
sangat membantu. mantap. thankyou
thank you so much, it's super beneficial and it's working 😍👍🏻👍🏻👍🏻👍🏻
Alhamdulilah nemu juga maksih mas
nice!! i have a question, if i want the unselected level will reduce a little bit alpha, how to script that?? thanks
Set the selected position child and create a new color for it and apply it. Don't forget to make the main one full color again.
In second to last if.
transform.GetChild(i).GetComponent().color = new Color(transform.GetChild(i).GetComponent().color.r, transform.GetChild(i).GetComponent().color.g, transform.GetChild(i).GetComponent().color.b, 1f);
In last if.
transform.GetChild(a).GetComponent().color = new Color(transform.GetChild(a).GetComponent().color.r, transform.GetChild(a).GetComponent().color.g, transform.GetChild(a).GetComponent().color.b, 0.5f);
The type or namespace name 'Scrollbar' could not be found (are you missing a using directive or an assembly reference?)
uour script is error, instead of use 'Scrollbar', change it to 'scrollbar'. Variable is case-sensitive.
any tutorial in bolt?
i id like scrool with mouse scrool well as i can doing?
without unnecessary chatter, in detail, and with good Mouzon, thanks for the lesson!
Greetings from Russia ^ _ ^
how would you make this work in 3D?
if i add images instead of buttons, how can i write the code?
Great video! Thank you man! You awesome!
Hi. this video helped a lot to my project. and Thanks...
Can we move next Level little bit faster? when we swipe the screen it goes next level hardly. I needed to swipe almost half of the screen to go next level. so Can you move it earlier like when we swipe just around 1/3 of the screen it can go next one... Is it possible?
Have you found a way of doing this?
@@gabe_marcos8027 Hi, try increasing number 2 to 4 in first for loop, and also at the beginning of "else" copy and paste code from if statement above
@@Jigglychad Thank you so much. I'll try that.
@@Jigglychad Hello, I don't quite understand what you mean, so sending me the code would be very nice Thanks in advance
Wow!!!Thank You!
From Russia
any idea how i can use this in VR and program the swipe using the Vive pro controller? I hope to get a few feedback from u guys! as I'm using it for my school project! this will help a lot!!
Hey, is there a way to increase sensitivity of scroll? Its kinda hard to scroll left and right on phone.
I would appriciate any help!
I'm also trying to do this, have you managed to make it more sensitive?
@@gabe_marcos8027 nah, i tried to make some fixes, but it didnt work. I just left it like it was
@@gabe_marcos8027 Have you managed to make it more easily scroll?
how use this for level up? in every level complete change value scrollbar horizontal ++
Worth Watching!!
So nice really good job man !
the script not suit for vertical version
That's what I wanted.... Thank you so much ... Plus one subscriber for you 😍😎
Makasih tutorialnya bang
Kalo bisa bikin effect sound nya jugak
Kayak main menu GTA hehe🙏🙏🙏
I found a way to accomplish the desired effect by adjusting the local scale of the children based on the scrollbar's position while maintaining the required "Screen Space - Overlay" render mode.
for (int i = 0; i < pos.Length; i++)
{
if (scroll_pos < pos[i] + (distance / 2) && scroll_pos > pos[i] - (distance / 2))
{
// Scale the current child to 1f, 1f, 1f
transform.GetChild(i).localScale = Vector3.Lerp(transform.GetChild(i).localScale, new Vector3(1f, 1f, 1f), 0.1f);
// Scale all other children to 0.8f, 0.8f, 1f
for (int a = 0; a < pos.Length; a++)
{
if (a != i)
{
transform.GetChild(a).localScale = Vector3.Lerp(transform.GetChild(a).localScale, new Vector3(0.8f, 0.8f, 1f), 0.1f);
}
}
break;
}
}
Thanks so much for this tutorial dude! Helped a lot! You are very underrated!
in this video i want to auto scroll to some point in start,how can i do this?
I love The Script make me smart
Лайк этому красавчику!!!!
Im in the last part but when I press play, the text inside the buttons disappear. Can u tell me where i went wrong. I used buttons text mesh pro
I think this is because you use Vector2 instead of Vector3 so z is set to 0
try
Vector3.Lerp(transform.GetChild(i).localScale, new Vector3(1.2f, 1.2f,1.2f), 0.1f);
and
Vector3.Lerp(transform.GetChild(j).localScale, new Vector3(0.8f, 0.8f,0.8f), 0.1f);
대박! 이런기능이 있었군요!
Bisa dibikin looping gak?
Kalau swipe nya pakai button gimana kak y, contoh nya ada 2 button yang satu untuk swipe ke kiri dan tang satu ke kanan, please buatkan tutorialnya kak,
how to get code recourse of this content?
Bang kalau scale nya dirubah jadi fullscreen buat di android bisa ga? 0,1f itu maksudnya apa ya bg
#2021 #COVID so friend thank you
bro can you tell me how to make the level pop like if i know ive won certain level how to start this menu screen from that position for instance if i won level 1 how to move the Content gameobject through script ?
Awesome, thank you
bang gua kok malah balik lg ke slide awal gabisa netap gitu
?
thank you.. It help me
Thanks for the video! Well done!!!
After doing some more research on this with different screen resolutions. It does not adapt well as far as I am seeing. Is there something I am missing maybe?
감사합니다. Good!~
Awesome tutorial!
Can any one give me the work source code? Mine always error because float[ ] cant initialize lenght
Bang tolong tutor swipe control with sounds pada object yang berbeda-beda
Kamal kar gaya larka
mantup soul sensei
halo kak, script yang versi vertical apakah kaka tau?