C# Generics Explained - Unity Tutorial

Поділитися
Вставка
  • Опубліковано 29 вер 2024

КОМЕНТАРІ • 66

  • @Roundbeargames
    @Roundbeargames  4 роки тому +7

    A lot of people were having trouble understanding the Singleton script,
    mainly "T" and "where T: MonoBehaviour"
    (maybe not so much with the singleton pattern itself, so this is NOT a video on singletons)
    If you're looking for a singleton script, check out my files here (Singleton included):
    drive.google.com/drive/folders/17Lfpa5r-3zeR1jaT0eJ4nqIR3pkU9ABE?usp=sharing
    T refers to generics where you don't have to specify a single class or a method. I use T for the Singleton class because I don't know which classes are going to inherit from it (CharacterManager, VirtualInputManager, CameraManager, etc). Generics allow different managers to inherit from the same Singleton class. It's like saying "a class can inherit from Singleton, where that class has to be a MonoBehaviour".
    After watching this video, if you're still having trouble understanding the code, I'll create another video for singletons.
    For now check out this video:
    ua-cam.com/video/hUE_j6q0LTQ/v-deo.html
    EDIT: here's my video on singletons
    ua-cam.com/video/92NQVeFiDeY/v-deo.html
    Download my project:
    github.com/RoundBearChoi/2.5D_Platformer_Unity
    Tutorial playlist:
    ua-cam.com/play/PLWYGofN_jX5BupV2xLjU1HUvujl_yDIN6.html

  • @fearlesskalsi
    @fearlesskalsi 4 роки тому +1

    Thanks a lot. This is the first time I am able to understand this concept.

    • @Roundbeargames
      @Roundbeargames  4 роки тому

      that's good to hear. i hope you have fun in your journey :)

  • @rungeon83
    @rungeon83 4 роки тому +11

    THIS! This is what I'm talking about, too many times people doing tutorials just waffle on and on, without enough demostration, however this good gentleman knows how to do a great tutorial. I'm in Godot C# but I can apply this over. Thank you :)

    • @Roundbeargames
      @Roundbeargames  4 роки тому

      i dont have experience with godot but that sounds great :) i also go on and on with my tutorials series but oh well i hope you enjoy!

    • @klarnorbert
      @klarnorbert 4 роки тому +1

      It's one of the reason, that there are tons of unfinished, buggy or asset flipper games with made Unity out there. Respect to this guy to making these types of videos.

    • @Roundbeargames
      @Roundbeargames  4 роки тому

      @@klarnorbert thank you. Yea people try things and give up too quickly i guess 😂

  • @i.k4854
    @i.k4854 4 роки тому +1

    this the best video i have found about this topic, very nice!

  • @elric7371
    @elric7371 4 роки тому

    Good afternoon my bro, Would it be possible to get both the mesh rendered and mesh filter using this method? sorry if i dont make much sense.

    • @Roundbeargames
      @Roundbeargames  4 роки тому

      this video has nothing to do with meshes. i have no idea what you're asking.

    • @elric7371
      @elric7371 4 роки тому

      @@Roundbeargames Hi,
      This line copyObj.AddComponent(); would it be possible to get all the components on an object and not only the script attached(rigidbody,mesh etc). Just curious if it can be done in this case. excluding instantiate a prefab. Hope this makes more sense. Thank you.

    • @Roundbeargames
      @Roundbeargames  4 роки тому +1

      you can attach MeshFilter and MeshRenderer to an empty gameobject. then you'll need to assign mesh and material in order to render it. yes you can add components through AddComponent

    • @elric7371
      @elric7371 4 роки тому

      @@Roundbeargames Thank you.

  • @bluengel
    @bluengel 4 роки тому +3

    한 주 동안 수고 많으셨어요~^^ 💙
    힘찬 월욜 맞이하셔요~!

    • @Roundbeargames
      @Roundbeargames  4 роки тому +2

      캄사합니다 ^ㅅ^
      오늘은 쬐끔 피곤하지만 월욜도 화이팅!

  • @hernanperez6435
    @hernanperez6435 2 роки тому +1

    Absolutly the best tutorials. Thank you for uploading, you are doing a lot for the community :)

    • @Roundbeargames
      @Roundbeargames  2 роки тому +1

      thank you :) atm i'm focused on my own projects but i hope you enjoy the videos!

  • @aaronfieldman3957
    @aaronfieldman3957 3 роки тому +1

    Thanks!! I'm trying to make a generic function for custom classes that all inherit from one custom class - hoping what you teach here helps

    • @Roundbeargames
      @Roundbeargames  3 роки тому

      thanks for comin! i hope you have fun learning!

  • @goffredo81
    @goffredo81 4 роки тому +1

    if you are learning unity and you are new to C#, C# must be learned first. Very nice explanation!!!

    • @Roundbeargames
      @Roundbeargames  4 роки тому +1

      yes and if you have time i also recommend c/c++/2d libaries/directx/etc and more! :)

  • @lee1davis1
    @lee1davis1 4 роки тому +4

    Best usage example of generics I've seen...and I've seen a lot. Added to my unity playlist of must watch

    • @Roundbeargames
      @Roundbeargames  4 роки тому

      that's awesome. i hope you enjoy the playlist!
      and a lot of what i have is from googling stuff that came before me.

    • @kurotatsu11
      @kurotatsu11 4 роки тому +1

      Added to my Unity Favorites Playlist too.lol

  • @dennisindrawan4005
    @dennisindrawan4005 4 роки тому +1

    this is really easy to Understand. Thank's...

  • @legendqwqw4882
    @legendqwqw4882 4 роки тому +1

    Your Tutorials are awesome.Thank you.

  • @CaverHTC
    @CaverHTC 4 роки тому +3

    You are the best man

    • @Roundbeargames
      @Roundbeargames  4 роки тому

      i wouldn't say best but thanks! :)

    • @CaverHTC
      @CaverHTC 4 роки тому +2

      ​@@Roundbeargames The fact that you're always trying to become a better programmer, and shares your skills / work with us, makes you the best in my eyes :)

    • @Roundbeargames
      @Roundbeargames  4 роки тому +2

      @@CaverHTC wow thank you. but i do feel like there's so much music and short clips from indie game developers but not enough opensource projects.

  • @HadiLePanda
    @HadiLePanda 4 роки тому +3

    The examples given are perfect for me, I was looking for something like this and your explaination helped me find a solution for what I was looking for, thanks a lot! :)

    • @Roundbeargames
      @Roundbeargames  4 роки тому

      thanks i'm glad to hear that. these are extremely simple examples so i dunno if they're gonna have any use cases other than explaining the basics. but i hope you have fun!

  • @aogamedev
    @aogamedev 4 роки тому +1

    thanks bro, great content and easy to understand

  • @belljo
    @belljo 4 роки тому +1

    excellent! keep up the small concise topics.. its really good for users of unity to look up on YT!

    • @Roundbeargames
      @Roundbeargames  4 роки тому +1

      thank you! i do try to keep every video to a single topic, tho that leads to lots of volume.. :)

  • @kurotatsu11
    @kurotatsu11 4 роки тому +1

    These are the tutorials that people really need to be trying to research.
    You just helped me take a system I'm trying to make more modular, and make it more efficient.
    One more tool in the toolbox.
    Well done, as always.

    • @Roundbeargames
      @Roundbeargames  4 роки тому +1

      thanks. i might have more later :)
      and topics depend on what people ask/suggest

    • @kurotatsu11
      @kurotatsu11 4 роки тому +1

      @@Roundbeargames I've been making things as generic as possible where compatability issues may arise with other systems from other authors, like damage messeges(ApplyDamage, GotHit, Damage.ect...), so I add string list for them to make those changes in the inspector.
      This will help immensely with trying to anticipate those scenarios, Thank You.

    • @Roundbeargames
      @Roundbeargames  4 роки тому +1

      that's awesome. this video only shows extremely simple examples. but good luck!

  • @realmaximun
    @realmaximun 4 роки тому +1

    buen video ,excelente

  • @rajasmahadule2697
    @rajasmahadule2697 3 роки тому +1

    Loving this series so far, all the advance stuff and clear explainations.

    • @Roundbeargames
      @Roundbeargames  3 роки тому +1

      i'm happy to hear that. have fun in gamedev!

  • @rafaelskiarteportfolio1098
    @rafaelskiarteportfolio1098 3 роки тому

    You are my hero!!! s2
    Question: at 7m50s, Why all the classes were called? Where it´s been called? You just have to inherit it? I couldn´t make sense out of this yet

    • @Roundbeargames
      @Roundbeargames  3 роки тому +1

      docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html
      start() awake() etc
      Its one of those magic functions.
      Id recommend learn programming first before trying to make sense out of unity :)

  • @robertofantasy123
    @robertofantasy123 4 роки тому

    in the second example, in the line that this code written : copy.Addcomponent(T), its create a loop, i cant see any loop, could you explain the loop

    • @Roundbeargames
      @Roundbeargames  4 роки тому

      Start triggers Declare.
      Declare triggers AddComponent, adding the script to its own game object.
      Start triggers Declare.
      Declare triggers AddComponent, adding the script to its own game object.
      Start triggers Declare.
      Declare triggers AddComponent, adding the script to its own game object.

  • @t33a25
    @t33a25 4 роки тому +1

    ty :)

  • @jbwb1953
    @jbwb1953 4 роки тому +1

    Came here a bit confused after watching the Unity Learn video on generics. These examples were super helpful. Thanks so much!

    • @Roundbeargames
      @Roundbeargames  4 роки тому

      that's good to know! i hope you have fun in gamedev!

  • @funkyjedi
    @funkyjedi 3 роки тому +1

    amazingly clear, thank you, best generics example I've found after years of lookin

  • @OutrageGames
    @OutrageGames 4 роки тому +2

    I love that there are sooo many things that I still don't know about. It adds so much more will to learn. Very cool!

    • @Roundbeargames
      @Roundbeargames  4 роки тому +1

      well we just gotta keep learning!

    • @kurotatsu11
      @kurotatsu11 4 роки тому +1

      I agree 100%, it's exciting the first time you come across something you can actually use.

  • @molkshake5884
    @molkshake5884 3 роки тому +1

    Man, I'm just starting to work on a project with my brother and all of your videos have been super helpful. Can't say thanks enough.

    • @Roundbeargames
      @Roundbeargames  3 роки тому

      that's very good to hear. if you're spending time on my channel that's already a big thanks. i wish you luck with your project.

  • @MadeThisStuff
    @MadeThisStuff 4 роки тому

    Great video with excellent examples!

  • @PascalAchermann
    @PascalAchermann 4 роки тому +1

    Thank you so much, for sharing this, i learn so much here :D