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)
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?)
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)
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?
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);
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);
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!!
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 ?
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,
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?
Download Master Project (Unity3D 2018.4.36f)
sociabuzz.com/akbar_project/p/swipe-menu-control-master-project
I never feel the need to comment on anything...but damn this is a great tutorial!!!
SUPER HELPFUL! This is like the only video on this topic! gj mate, ur a hero
WoW! Thanks!!
from Brazil!
I literally positioned each item manually. Content Size Fitter is miracle
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)
the best guide from the best person.
Дай бог тебе здоровья, добрый человек)
У меня почему то камера возвращается не знаешь почему?
А вдруг он по нашему не понимает
bro you done it very well.... but if you explain the scrip instead of music it will be fantastic and more helpful for us
Exactly what i was looking for mate. TYVVM.
This is 2021 and it's still working :) thanks.
without unnecessary chatter, in detail, and with good Mouzon, thanks for the lesson!
Greetings from Russia ^ _ ^
Jan e jigar tum tu cha gye🥰
excelent post.
The best, thank you, you helped me a lot.
My focus does not change on the 2nd button when i scroll .. help plz
Very nice worke my friend. I can say you Thanks for this is working. I'm Real learnin new menu with scroll))))
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)
this tutorial is gold, thanks.
the tut was amazing, thx dude
How do you implement this vertically. It completely broke when I tried to do it.
Excelente tutorial, muchas gracias, saludos desde Colombia
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
It's work on android ??
Really clever. Well done 👍
Alhamdulilah nemu juga maksih mas
Thanks for tutorial it really help me!!
I want selected level to be centered in the screen but I couldn't. How can I do that?
You’ve got a like and a new sub!
Thanks for this tutorial!
Very useful tutorial thanks!
thank you so much, it's super beneficial and it's working 😍👍🏻👍🏻👍🏻👍🏻
best tutorial ever
Great video! Thank you man! You awesome!
How can I controll this with buttons?
one should move it to the next left the other to the next right pls help
So nice really good job man !
Thanks so much for this tutorial dude! Helped a lot! You are very underrated!
Thanks for useful video.
Thanks for the great tutorial!
Good Video, I used to load weapons that are equipped
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?)
this works with AR? Incredible video!
That's what I wanted.... Thank you so much ... Plus one subscriber for you 😍😎
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.
Hey, thank you for the tutorial. May I know how to add sound in between each button, while swiping?
very usefull, percise and effective
Wow!!!Thank You!
From Russia
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.
Still possible to full screen the level 1 level 2?
Image?
hi bro , can you make a tutorial like this but for vertical layout?
Makasih tutorialnya bang
Kalo bisa bikin effect sound nya jugak
Kayak main menu GTA hehe🙏🙏🙏
Worth Watching!!
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.
sangat membantu. mantap. thankyou
when i click play button, my button images are dissapear. why?
How to make it that when clicked zoom in and focus on that button?
Awesome tutorial!
Kamal kar gaya larka
mantup soul sensei
Do you know if it is possible to make it loop (endless) ?
I am using this for my shop, is there a way to fill the swipe menu using scriptable objects?
any tutorial in bolt?
Mouse wheel scroll not working. How to fix it?
Awesome, thank you
why this isn't working on my menu?? the reason is float does not contain a definition of length?.
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?
The BEST!!!
is it applicable for mobile?
Indo hadir
will it work on android? by swiping?
how we can move the same thing using left / right button .
Лайк этому красавчику!!!!
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
i id like scrool with mouse scrool well as i can doing?
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
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.
if i add images instead of buttons, how can i write the code?
how to get code recourse of this content?
bang gua kok malah balik lg ke slide awal gabisa netap gitu
?
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);
can anyone explain the distance variable why is it created what does it represent ?
the script not suit for vertical version
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;
}
}
what if i want to make it vertical? can you help me?
have you been able to do it for vertical?
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);
how would you make this work in 3D?
thank you.. It help me
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!!
in this video i want to auto scroll to some point in start,how can i do this?
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 ?
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,
halo kak, script yang versi vertical apakah kaka tau?
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
Excellent
Thank you!!!!
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?
감사합니다. Good!~
Bang kalau scale nya dirubah jadi fullscreen buat di android bisa ga? 0,1f itu maksudnya apa ya bg
Thank you so much;)
Bisa dibikin looping gak?
thanks you helped me