Swiping Pages in Unity

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ธ.ค. 2024

ความคิดเห็น • 135

  • @Legendary33284
    @Legendary33284 4 ปีที่แล้ว +35

    To restrict the swipe on left and right, add an "int currentChild" and change the if (percentage > 0) statements to
    if (percentage > 0 && currentChild < transform.childCount - 1)
    {
    newLocation += new Vector3(-Screen.width, 0, 0);
    currentChild++;
    }
    else if(percentage 0)
    {
    newLocation += new Vector3(Screen.width, 0, 0);
    currentChild--;
    }

    • @hanif8537
      @hanif8537 4 ปีที่แล้ว

      hye im a newbie in coding can you help me how to add this code?

    • @hieu-dev
      @hieu-dev 2 ปีที่แล้ว

      thank you verry much

    • @lilbocheap139
      @lilbocheap139 2 ปีที่แล้ว

      Thank you so much!!

    • @krouzekunity
      @krouzekunity ปีที่แล้ว

      thanks for help, profesional unity team from Czech Republic

    • @ОлександрЩіпайло
      @ОлександрЩіпайло 10 หลายเดือนก่อน

      "int currentChild" is private!

  • @NiclasGleesborg0
    @NiclasGleesborg0 5 ปีที่แล้ว +4

    Nice solution for a common problem :)

  • @xxx.xxx.xxx.xx1joker706
    @xxx.xxx.xxx.xx1joker706 4 ปีที่แล้ว +2

    Perfect Tuto. Many thanks. The cherry on the cake would be to implement this in a List View filled with items, and swipe a selected item either to delete it or archive it, as this is done in email apps.

  • @brandonhohn245
    @brandonhohn245 5 ปีที่แล้ว +6

    Heading to class, but I'm so super excited for this one, thank you!

  • @sarangborude8260
    @sarangborude8260 3 ปีที่แล้ว

    You are such a life saver, this is really good info. lIke really really good info. I spent some much time implementing my own drag handling without realizing that this is built in.

  • @Misanthropowitsch
    @Misanthropowitsch 5 ปีที่แล้ว +7

    Straigt forward. That video is a gem. Pls don´t forget that video and show us how to limit the swipe if there´s no additional pages to go. It´d also be great to see how you do the same in y direction. I tried it, but for some reason other than weird behaviour nothing worked. Keep it up man. Your channel is very promising!

    • @pressstart6864
      @pressstart6864  5 ปีที่แล้ว +2

      Hey Dom, I cover it in this video: th-cam.com/video/tCr_i5CVv_w/w-d-xo.html

  • @kerandonovan7255
    @kerandonovan7255 4 ปีที่แล้ว +15

    Great vid! How would you amend the code so this workds on Scale With Screen Size?

  • @desarrollovirtual4998
    @desarrollovirtual4998 3 ปีที่แล้ว

    Nice Video bro i do Mistakes but i saw this , fix it and learn lot, thanks Amigo

  • @SpiderDilly
    @SpiderDilly 11 หลายเดือนก่อน

    If you're having weird issues with snapping back to the first panel, simply move some code (that sets the panel location variable to the new transform.position) into the while loop of the Coroutine worked for me!

  • @niekknijnenburg2466
    @niekknijnenburg2466 3 ปีที่แล้ว

    Great video, great script!
    Works like a charm.
    Added a BackToPage1 method to reset
    public void BackToPage1()
    {
    currentPage = 1;
    transform.position += new Vector3(-transform.position.x, 0, 0);
    panelLocation = transform.position;
    }
    which I call when the content of the panels is swapped for new content

  • @stute_01
    @stute_01 2 ปีที่แล้ว

    Great video dude !

  • @oscarsanchez2739
    @oscarsanchez2739 4 ปีที่แล้ว

    GRACIAS !! me has ayudado mucho, sin duda alguna este es uno de los mejores turoriales que he visto :) . many cold beers for you good man

    • @maestradebobobo767
      @maestradebobobo767 4 ปีที่แล้ว

      A mí no me detecta el "OnDrag", he usado el Debug.Log para ver si me calcula las coordenadas pero no funciona... No estoy usando Panels, puede ser por eso?

    • @oscarsanchez2739
      @oscarsanchez2739 4 ปีที่แล้ว +1

      @@maestradebobobo767 intenta hacerlo tal cual como el tutoríal , mismos nombres de los prefabs todo tal cual igual, ya cuando te funcione puedes modificar lo que gustes y así veras cual es el error

    • @maestradebobobo767
      @maestradebobobo767 4 ปีที่แล้ว

      Oscar Sanchez Vale, por alguna razón me faltaba el EventSystem y sin EventSystem no funciona.

    • @oscarsanchez2739
      @oscarsanchez2739 4 ปีที่แล้ว +1

      @@maestradebobobo767 haz una prueba, construyelo y pásalo a tu teléfono e intenta hacer swipe después de rotar el teléfono en modo horizontal y me comenta si te funciono perfecto

    • @maestradebobobo767
      @maestradebobobo767 4 ปีที่แล้ว

      Oscar Sanchez Me funcionó perfectamente! Gracias

  • @MrBudowniczy
    @MrBudowniczy 4 ปีที่แล้ว

    You are a genius, thank you for this video!

  • @jeroenvanderheijden8101
    @jeroenvanderheijden8101 4 ปีที่แล้ว +5

    Thanks for your tutorial, I added below lines to stop at the last panel.
    int EndPos = (NoOfPanels - 2) * Screen.width + Screen.width / 2;
    if (newLocation.x < -EndPos) newLocation.x = -EndPos;

  • @RajOnTheStreet
    @RajOnTheStreet 3 ปีที่แล้ว +5

    Did anyone figure how to make the resolutions all the same? I keep getting them different screen sizes when I build for mobile

  • @joesai9611
    @joesai9611 ปีที่แล้ว

    so helpful, thank you!

  • @QuânHoàngVăn-y1n
    @QuânHoàngVăn-y1n ปีที่แล้ว

    awesome bro!

  • @willwainwright7166
    @willwainwright7166 ปีที่แล้ว

    Still valid today

  • @pedromartins9049
    @pedromartins9049 2 ปีที่แล้ว +2

    For those who want to make it force stop at the far left/right panels:
    public void OnDrag(PointerEventData data)
    {
    float difference = data.pressPosition.x - data.position.x;
    if (Math.Abs(farLeftPanel.position.x - Screen.width / 2f) < .001f && difference < 0)
    {
    print("Far Left");
    return;
    }

    if (Math.Abs(farRightPanel.position.x - Screen.width / 2f) < .001f && difference > 0)
    {
    print("Far Right");
    return;
    }
    _tf.position = _panelLocation - new Vector3(difference, 0, 0);
    }
    You're welcome.

  • @brennankabalkin4840
    @brennankabalkin4840 2 ปีที่แล้ว +4

    If any of you are having a problem with the scrolling being way too fast:
    Change your camera to overlay

  • @lcd11001
    @lcd11001 4 ปีที่แล้ว

    thank you. Your code is clear & smart

  • @kerandonovan7255
    @kerandonovan7255 4 ปีที่แล้ว

    A perfect tutorial

  • @dariuszcegieka3494
    @dariuszcegieka3494 5 ปีที่แล้ว +2

    helpful as always :D

  • @Baal3033
    @Baal3033 3 ปีที่แล้ว

    Awesome, thanks for the tutorial :)

  • @gme2968
    @gme2968 2 ปีที่แล้ว

    Overall.. Thank you dear for sharing those images as well as codes with me...🥰...

  • @denysuhendraproject5251
    @denysuhendraproject5251 4 ปีที่แล้ว

    Thanks for the knowledge!

  • @andrewmanigault6550
    @andrewmanigault6550 3 ปีที่แล้ว +6

    For anyone still wondering how to apply this to code when using "Screen Space - Camera"; just convert the data.pressPosition and data.position to world points. For example:
    float difference = Camera.main.ScreenToWorldPoint(data.pressPosition).x - Camera.main.ScreenToWorldPoint(data.position).x;

  • @diegosuarez5473
    @diegosuarez5473 5 ปีที่แล้ว +4

    You are a crack broh!! Keep going and congratulations

  • @zotinfo9110
    @zotinfo9110 3 ปีที่แล้ว +7

    Hi, first of all thanks for the wonderful tutorial, however I'm having trouble dragging sideways, my panel is moving too fast a single tap makes it move by -9858 at position X.
    Has anyone had this problem and managed to solve?
    My code is identical to the video.

    • @BilliJhown
      @BilliJhown 3 ปีที่แล้ว +1

      I have the same problema, you found solution?

    • @Lundasamor
      @Lundasamor 2 ปีที่แล้ว

      maybe a little late , but i was able to solve the problem.
      you probably dont use Screen Space - Overlay in the Canvas but Screen Space- Camera. You can either switch, or use transform.localposition insted

  • @TheKr0ckeR
    @TheKr0ckeR 2 ปีที่แล้ว +1

    Is this gonna be responsive? For example with different screen sizes like 1600x2000 & 1080x1920

  • @mateenamir3194
    @mateenamir3194 5 ปีที่แล้ว

    Love it man

  • @alaydonga
    @alaydonga ปีที่แล้ว

    it's very usefull video

  • @rickole7404
    @rickole7404 4 ปีที่แล้ว

    thx! just wut i needed

  • @Allfortea1234
    @Allfortea1234 4 ปีที่แล้ว

    Very thanks for this lesson :)

  • @aboutvenice
    @aboutvenice 5 ปีที่แล้ว

    Hey, nice and clean and neat. Thank you!

  • @MaazKhan-vf2zu
    @MaazKhan-vf2zu 5 ปีที่แล้ว +1

    Wow Amazing

  • @Tvtig
    @Tvtig 5 ปีที่แล้ว

    Thanks bro, this is great.

  • @dwexecutioner
    @dwexecutioner 4 ปีที่แล้ว

    Thank you so much.

  • @thaiduong9136
    @thaiduong9136 3 ปีที่แล้ว

    so helpful

  • @zukaichi
    @zukaichi 5 ปีที่แล้ว +1

    Thanks man :D

  • @SolocovGE
    @SolocovGE 5 ปีที่แล้ว +2

    This does not work if you are using Scroll Rect in the Panel. How do I fix this?

  • @TsaoLiam
    @TsaoLiam ปีที่แล้ว +1

    hey guys, I wanna add teleport function on each button. Every buttons have specific position. Can you guys give me some advice. thanks

  • @Carlos-ll1ky
    @Carlos-ll1ky 2 ปีที่แล้ว

    Gracias me ayudo mucho:D

  • @ibrahimmohamedmahmoudali3668
    @ibrahimmohamedmahmoudali3668 4 ปีที่แล้ว +2

    Very useful tutorial
    but can i make the slide vertically instead of horizontal?

    • @ibrahimmohamedmahmoudali3668
      @ibrahimmohamedmahmoudali3668 4 ปีที่แล้ว

      I tried Changing the OnDrag to
      Vector3 pos = transform.position
      pos.y = Input.mousePosition.y;
      transform.position = pos;
      But when i swipe up or down it returns to the main panel always Any help plz😥

    • @rollox2121
      @rollox2121 3 ปีที่แล้ว

      @@ibrahimmohamedmahmoudali3668 I have the same problem did you find out how to fix it?

  • @koku900
    @koku900 4 ปีที่แล้ว +3

    I found error.
    I used transform.position. but it was not working
    and i finaly changed "position -> localPosition"
    so it's very good working

  • @yoohup1218
    @yoohup1218 4 ปีที่แล้ว +1

    Hello guys ! Thanks for tutorial. How can you force stop the swipe when you come at the last panel ?

  • @deraminator945
    @deraminator945 3 ปีที่แล้ว +1

    In my case it's not jumping to the next panel, it skipps all panels when i'm halfway through my 10 panels

  • @mohamadikmal8328
    @mohamadikmal8328 5 ปีที่แล้ว +2

    Hello , i just followed your tutorial in this video but i faced problems when i swipe right then it goes to back to 1st panel. i got 3 panel in the scene but you have 7 panel. Does the amount of panel related to the script?

    • @PumaGnom
      @PumaGnom 5 ปีที่แล้ว

      Hi, i got the same problem as you, but after comparing my and his code i realised that in the first line of the OnEndDrag function i wrote: float percentage = (data.position.x - data.position.x) / Screen.width;
      instead of
      float percentage = (data.pressPosition.x - data.position.x) / Screen.width;
      So maybe u got the same careless mistake as me.

    • @mohamadikmal8328
      @mohamadikmal8328 5 ปีที่แล้ว

      @@PumaGnom Maybe i face problems on vector 3 script. thanks for the help

    • @cathardgamer
      @cathardgamer 4 ปีที่แล้ว

      same problem, any solution?

    • @hansha9404
      @hansha9404 2 ปีที่แล้ว

      @@PumaGnom i wrote the same thing " (data.pressPosition.x) " but it still doesn't work

  • @ManParmar-n1q
    @ManParmar-n1q ปีที่แล้ว

    hello brother,
    is it work with buttons also??
    if yes then how we can use it.........

  • @zbyszekkiebasa906
    @zbyszekkiebasa906 4 ปีที่แล้ว +1

    Where is the continuation mate. I want to know how not moving off the panels is done

    • @miltonponte180
      @miltonponte180 4 ปีที่แล้ว

      Go to the video next to this one, in the end there is the solution. Pretty simple, btw

    • @lcd11001
      @lcd11001 4 ปีที่แล้ว +1

      The fixed is here: th-cam.com/video/tCr_i5CVv_w/w-d-xo.html

    • @zbyszekkiebasa906
      @zbyszekkiebasa906 4 ปีที่แล้ว

      @@lcd11001 God Bless my dude

  • @GrafitiGames
    @GrafitiGames 4 ปีที่แล้ว +1

    Hey, Great video, i have one question tho, it works on almost all resolutions but if i change it to a really low resolution it has way more distance between each swipe, somebody knows whats up? Great video tho!

    • @lappenjr.2506
      @lappenjr.2506 4 ปีที่แล้ว

      Same Problem here

    • @RajOnTheStreet
      @RajOnTheStreet 3 ปีที่แล้ว +1

      @@lappenjr.2506 Anyone found a solution to this?

  • @glitchgrid5088
    @glitchgrid5088 4 ปีที่แล้ว

    can we get the panels you used for commercial use if yes can you make a google drive or something like that for them?

  • @gamingtotdemaxi
    @gamingtotdemaxi 3 ปีที่แล้ว +1

    I only have 3 panels, and for some reason the swipe is insanely fast. It also does not stay on the next panel when swiping
    Edit: it is because I am using screen space camera instead of overlay, Is there any way of fixing this apart from setting my canvas to overlay?

    • @thegreeen929
      @thegreeen929 2 ปีที่แล้ว

      I have the same Problem, maybe you can use some ScreenTo-whatever function?

  • @alessandrocinque4542
    @alessandrocinque4542 4 ปีที่แล้ว +2

    He explains how to not overstep panels at the 14:15 of the following video : th-cam.com/video/tCr_i5CVv_w/w-d-xo.html

  • @overgastoru
    @overgastoru ปีที่แล้ว

    I might be coming too late into this, but any ideas on how would I go about implementing BUT if at the start I swipe to the left, the last page appears through the left and so on? Like an infinite cycle, not a scroll back to the position of the desired, but that you can scroll infinitely? ie: you get to the last page, you scroll again and you get the first page, then the second and so on

  • @GrafitiGames
    @GrafitiGames 4 ปีที่แล้ว

    How do you swipe on a y position? Nice tutorial btw!!

  • @vishalanime
    @vishalanime 4 ปีที่แล้ว

    Hi. Thanks for the tutorial. How to stop scrolling to an empty page?

    • @vishalanime
      @vishalanime 4 ปีที่แล้ว

      Found what i was looking for in your next video :) Thank you
      th-cam.com/video/tCr_i5CVv_w/w-d-xo.html

    • @valentinopizzo486
      @valentinopizzo486 3 ปีที่แล้ว

      Just paste this
      public void OnDrag(PointerEventData data)
      {
      float difference = data.pressPosition.x - data.position.x;
      if(currentPage == 1 && difference > 0 || currentPage != 1 && currentPage != totalPages|| currentPage == totalPages && difference < 0)
      transform.position = panelLocation - new Vector3(difference, 0, 0);
      }

  • @maestradebobobo767
    @maestradebobobo767 4 ปีที่แล้ว

    Should I limit the scrolls with code or with collisions?

    • @lcd11001
      @lcd11001 4 ปีที่แล้ว

      do you mean this fix? th-cam.com/video/tCr_i5CVv_w/w-d-xo.html

  • @digigo6323
    @digigo6323 4 ปีที่แล้ว

    awsome thnx for this Tuto
    but when at the first panel we swipe to right it doesent work
    i saw this problem in your video too
    what should we do?

    • @drav4132
      @drav4132 4 ปีที่แล้ว

      Hi, I solved this problem. I can give some hint for you.
      Good Luck :)
      if(this.GetComponent().offsetMin.x > 0)
      {
      StartCoroutine(SmoothMove(transform.position, panelLocation, easing));
      }

  • @portwo
    @portwo 4 ปีที่แล้ว +1

    is there any way to implement it with "Screen-Space Camera"?

    • @alexjhones_gamedev
      @alexjhones_gamedev 4 ปีที่แล้ว

      In the "CANVAS" object, change the "CANVAS" component "Render Mode" to "Screen Space - Overlay".
      Soon I will start recording tutorials too! :)

  • @ComputerOyyy
    @ComputerOyyy 4 ปีที่แล้ว

    very impressive...
    but how do you set this up for different screen-sizes? Because the panels you set up in unity editor are not always the same size of the Screen.width :'(

    • @lcd11001
      @lcd11001 4 ปีที่แล้ว

      You can recalculate the panels size in Awake function, then layout child components inside these panels using Group component or something like that
      private void Awake()
      {
      for (int i = 0; i < transform.childCount; i++)
      {
      Transform child = transform.GetChild(i);
      RectTransform childRect = child.GetComponent();
      childRect.sizeDelta = new Vector2(Screen.width, Screen.height);
      }
      }

    • @ComputerOyyy
      @ComputerOyyy 4 ปีที่แล้ว

      @@lcd11001 yep thanks, I actually already did what I need with just a bit of thinking. Some tutorials make us spoiled programmers sometimes 😅

    • @RajOnTheStreet
      @RajOnTheStreet 3 ปีที่แล้ว

      @@ComputerOyyy Can you please share how you did this?

  • @ZawyedZion
    @ZawyedZion 4 ปีที่แล้ว

    how did you set up this with code ? 00:37

  • @random_precision_software
    @random_precision_software 3 ปีที่แล้ว

    How do I get a spectrum and c64 loading type screen on unity?

  • @advikmalwa379
    @advikmalwa379 4 ปีที่แล้ว +2

    1:12 how to make this can anyone help me out pleaseeee

    • @alexjhones_gamedev
      @alexjhones_gamedev 4 ปีที่แล้ว +1

      In the "CANVAS" object, change the "CANVAS" component "Render Mode" to "Screen Space - Overlay".
      Soon I will start recording tutorials too! :)

    • @advikmalwa379
      @advikmalwa379 4 ปีที่แล้ว +1

      @Tavint please start the tutorials I will watch them😃😄

  • @sachaallen2412
    @sachaallen2412 5 ปีที่แล้ว

    Is it possible to make it deactive some objects when you swipe as in my menu there are pop ups on the side that show for certain things?

  • @bene5776
    @bene5776 5 ปีที่แล้ว +1

    Do you know how to make this Level Manager resolution responsive? So that it works e.g. for smartphones and tablets?
    And thanks for your tutorials! Keep going on like this ✌🏻👍🏻

    • @pressstart6864
      @pressstart6864  5 ปีที่แล้ว +1

      Should work fine with smartphones and tablets (touch devices). Since it uses a canvas element, you can modify the settings on the canvas to make it responsive for different resolutions. Cheers

    • @lappenjr.2506
      @lappenjr.2506 4 ปีที่แล้ว

      @@pressstart6864 It doesnt work for diffrent resolutions, because the "PanelHolder" is a gameObject, not a canvas. You cant make it a canvas because you wont be able swipe then.
      I dont se any way to fix this issue, i think a diffrent Method is required.

    • @RajOnTheStreet
      @RajOnTheStreet 3 ปีที่แล้ว

      @@lappenjr.2506 Did you find a fix for this?

    • @lappenjr.2506
      @lappenjr.2506 3 ปีที่แล้ว +1

      Kind of. I remember that I made a workaround, to scale according to the Screen Aspect Ration from inside the script.
      But its like stretching a Photo, it doesnt look good on Tablets...

  • @bengreat6889
    @bengreat6889 4 ปีที่แล้ว

    I swipe left and its fine but when I swipe right, the panel falls down. I've tried a bunch of solutions but just can't seem to get it right. Help!!

  • @craftingpixel9053
    @craftingpixel9053 2 ปีที่แล้ว

    Great Video, but i have a problem with swiping it doesnt swipe to the next pannel, could anyone help me with that problem?

    • @martinorocco8049
      @martinorocco8049 ปีที่แล้ว

      I have the same problem with only 3 pannel
      Edit: YOU HAVE TO CHANGE ON MIDDLE RIGHT ON UNITY THE NUMER OF PAGES YOU HAVE!!

  • @onatkorucu842
    @onatkorucu842 4 ปีที่แล้ว

    Why not just use a Scroll View?

  • @avin555
    @avin555 4 ปีที่แล้ว

    float percentage=(data.pressPosition.x - data.position.x)/Screen.width; //I did not get the point of dividing the equation by Screen.width???

  • @lookeyyensen6071
    @lookeyyensen6071 4 ปีที่แล้ว

    I copy paste the code from your website and when i swipe it swipes hyper fast and allways jumps pack to first pannel ?

    • @bakerosoftcom2775
      @bakerosoftcom2775 4 ปีที่แล้ว

      dont use Screen-Space Camera

    • @ropemox5550
      @ropemox5550 ปีที่แล้ว

      @Can SOLEN public void OnEndDrag(PointerEventData data)
      {
      float percentage = (data.pressPosition.x - data.position.x) / Screen.width;
      if (Mathf.Abs(percentage) >= percentThreshold)
      {
      Vector3 newLocation = panelLocation;
      if (percentage > 0)
      {
      if (pageNum < maxPage)
      {
      pageNum++;
      var test = Camera.main.ScreenToWorldPoint(new Vector3(-Screen.width / 2, 0, 0));
      test = new Vector3(test.x, 0, 0);
      newLocation += test;
      }
      }
      else if (percentage < 0)
      {
      if (pageNum > 1)
      {
      pageNum--;
      var test = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, 0, 0));
      test = new Vector3(test.x * 2, 0, 0);
      newLocation += test;
      }
      }
      StartCoroutine(SmoothMove(transform.position, newLocation, easing));
      panelLocation = newLocation;
      }
      else
      {
      transform.position = panelLocation;
      }
      }

  • @dominik9351
    @dominik9351 4 ปีที่แล้ว

    Awsome tutorial. During playtesting i ran into a problem with the script. After reloading the scene I cant swipe between the panels anymore. Do you guys have any idea what might cause this problem?
    Edit: I found out that Time.deltaTime does not increse anymore after the scene is reloaded but i cant think of any reason why it would not count up anylonger.

    • @ludosphere
      @ludosphere 4 ปีที่แล้ว +1

      for me it stopped working because my timescale (Time.timescale) was set to 0 when i loaded the scene.

  • @dmsassassin
    @dmsassassin 4 ปีที่แล้ว +2

    have a scroll view .... it is not working?

  • @thatomogale9803
    @thatomogale9803 4 ปีที่แล้ว

    Why can't you just use the slider component?

  • @uusoft
    @uusoft 4 ปีที่แล้ว

    You are a great teacher but please do not say Classes for Interfaces 1:55
    Thank you

  • @xGreenhero
    @xGreenhero 4 ปีที่แล้ว

    here is the code for not letting the user swipe past the bounds
    // I'm doing a vertical style swipe from up to down.
    private int _page = 0;
    private int _upperPageBound= 1;
    private int _lowerPageBound = 0;
    // other code . . .
    // inside OnEndDrag
    if (percentage > 0 && page == _upperPageBound) { // swipe down, go to page above

    newLocation += new Vector3(0,-Screen.height,0);
    page--;
    }
    else if(percentage < 0 && page == _lowerPageBound ) { // swipe up, go to page below
    newLocation += new Vector3(0, Screen.height, 0);
    page ++;
    }

  • @arium7899
    @arium7899 4 ปีที่แล้ว

    I had screen size struggles so I made this.. parent every gameObject to each other and set the parents to 0. swipe menu is now responsive for me.
    public GameObject[] items;
    void Start()
    {
    items[0].transform.position += new Vector3(Screen.width ,0,0);
    items[1].transform.position += new Vector3(Screen.width, 0, 0);
    items[2].transform.position += new Vector3(Screen.width, 0, 0);

    }

    • @RajOnTheStreet
      @RajOnTheStreet 3 ปีที่แล้ว

      Can you please explain how you did this, it would be a big help!

    • @gamingtotdemaxi
      @gamingtotdemaxi 3 ปีที่แล้ว

      I dont understand

    • @henrig8708
      @henrig8708 3 ปีที่แล้ว +2

      @@gamingtotdemaxi mine might be a little different to his, but generally the same. ANSWER TO DIFFERENT SCREENS/ DYNAMIC SCREEN SIZES:
      3 Main steps:>
      1. Create a reference panel on unity, ie this is the panel that will always adapt to the size of the canvas automatically. Normally the very next panel canvas sees naturally does this
      2. Create a script (attach it to your canvas), with the number of panels you are using as game objects ie : public GameObject referencePanel, panelOne, panelTwo, panelThree; etc
      3. In Void start; Write the code: PanelOne.transform.position = referencePanel.position //this makes your panel go to the same position as the reference panel which is the precise size of the canvas and location
      4. then write: PanelTwo.transform.position = new Vector3 (screen.width, screen.height/2); //This makes panel two move its X axis to the right by the exact size of the reference panel.
      5. lastly, do the same things for each panel that you have. However, on the second code for your third panel, do - screen.width*2 and for your fourth panel, do screen.width*3 etc etc.
      Here are a few things to keep an eye on:
      1. Make sure that your pivot is set to the middle left side on each panel
      2. Your first panel does not need to be moved, so it only needs to be set to the same position as the reference panel, so the second code is only applied to the panels outside the field of view
      3. I know this could be simplified, i am still yet to simplify it, but this is what worked for me and i felt i had o share it asap

    • @jonaz77
      @jonaz77 2 ปีที่แล้ว +1

      @@henrig8708 even if this is a simplified version, it worked for me, thanks!

  • @deadheadstd
    @deadheadstd ปีที่แล้ว

    damn, its fucking impossible to read code

  • @vc.2023
    @vc.2023 ปีที่แล้ว +1

    No explanation how to start setting camera, create level buttons etc, impossible to follow up. Waste of my time.

  • @cyrus3430
    @cyrus3430 3 ปีที่แล้ว +1

    Good at coding ,horrible at explaining

    • @cyrus3430
      @cyrus3430 3 ปีที่แล้ว

      Great video though

  • @martinorocco8049
    @martinorocco8049 ปีที่แล้ว

    Can someone teach me how to remove this Error "NullReferenceException: Object reference not set to an instance of an object" when I open a new Unity Progect every time?