SOLID Principles in Unity

Поділитися
Вставка
  • Опубліковано 21 лип 2024
  • Sign up for the Level 2 Game Dev Newsletter: eepurl.com/gGb8eP
    You don't have to be an amazing programmer to finish a game! This Unity tutorial will show you how to use the SOLID principles to write code that'll stand the test of time.
    #UnitySOLID #UnityTutorial #GameDevelopment
    📦 Download the project: / 26159833
    This tutorial was created with the help of ‪@JasonStorey‬
    💬 Join Our Community
    Discord: / discord
    Patreon: / infalliblecode
    Newsletter: eepurl.com/gGb8eP
    ❤️ My Favorite Unity Assets *
    Odin Inspector and Serializer: assetstore.unity.com/packages...
    Editor Console Pro: assetstore.unity.com/packages...
    Rainbow Folders 2: assetstore.unity.com/packages...
    Peek: assetstore.unity.com/packages...
    Project Search & Replace: assetstore.unity.com/packages...
    ⚡ Unity 3D Plus: prf.hn/click/camref:1100l3e8M/...
    ⚡ Unity 3D Pro: prf.hn/click/camref:1100l3e8M/...
    👋 Contact me directly at charles@infalliblecode.com
    * Disclosure: These are affiliate links, which means I'll receive a commission if you use them to make a purchase.

КОМЕНТАРІ • 204

  • @InfallibleCode
    @InfallibleCode  5 років тому +17

    Sign up for the Level 2 Game Dev Newsletter: eepurl.com/gGb8eP

    • @notared5948
      @notared5948 5 років тому

      Hey, great tutorial, any chance you could also link some reading materials for the SOLID principles you mentioned about?

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

      @@notared5948 connect.unity.com/p/solid-principles-in-unity-part-1-solid-overview

    • @longuemire748
      @longuemire748 2 роки тому

      Thank you for this tutorial.
      In a way, we can replace interfaces with scriptableObjects. What is the best method in your opinion?

  • @ThomasBCharlie
    @ThomasBCharlie 2 роки тому +124

    As a self-taught programmer and game dev enthusiast I find that nearly all Unity tutorials completely gloss over any semblance of proper design patterns. They cock up quick scripts that do what their title says in sub-optimal ways and are impossible to expand and build upon. For years, such tutorials have been teaching me to haphazardly connect various Unity components and just hope for the best, and as a result I continue to rewrite my code over and over while struggling to make anything more complicated than the simplest Space Invaders knock off.
    Nowadays, I find these kinds of tutorials that actually talk about how code is written in in general much more useful than anything else. Being set in Unity helps a lot too, cause I'm not familiar with many frameworks outside of that. Thank you.

    • @HATL201
      @HATL201 2 роки тому +6

      That's comparing apples to oranges. Most of the Unity tutorials on youtube are teaching you how to implement a certain game logic. And yes, they should be quick and concise, telling you exactly how to implement that logic and be done with it. On the other hand, code design patterns, principles and practices is a separate domain, and it's the responsibility of the user to learn them as well as the game logic on their own.

    • @buriedomasta3375
      @buriedomasta3375 Рік тому +1

      @@HATL201 where do I start from? I am a beginner

    • @nuin9937
      @nuin9937 Рік тому

      @@buriedomasta3375 how did it go

  • @beardordie5308
    @beardordie5308 5 років тому +132

    For those struggling to use the selection manager outside of this or any project with it already working, here's a hard-earned tip: make sure your camera has a Physics Raycaster component on it.

    • @InfallibleCode
      @InfallibleCode  5 років тому +18

      Thanks for sharing this! I definitely glossed over this very important detail lol

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

      Go up and save the day you foo! LIKES LIKES LIEKS!!!

    • @potatomilk7400
      @potatomilk7400 4 роки тому +6

      and tag said camera as Main Camera. I almost had an aneurysm trying to figure out why it wouldn't work for me.

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

      I don't have that on my camera and it still works fine

  • @kidsteveee
    @kidsteveee 5 років тому +121

    Oh man, we need more tutorials like this.

    • @InfallibleCode
      @InfallibleCode  5 років тому +6

      More content is in the works! Stay tuned! :D

  • @KHam56
    @KHam56 4 роки тому +15

    I much preferred this teaching style of your videos over the mock conversations of the current videos. its faster to the content without the bloat of expression, "story building" filler moments like showing off gameplay, and the greeting conversation. time is precious and videos like this feel much more efficient and attention holding.

  • @TheGuyWithTheLemon
    @TheGuyWithTheLemon 4 роки тому +34

    Dude this is a great tutorial! Finally, a channel that goes in-depth into core coding principles that every game programmer should be following! Coming from a coding background this level of detail is perfect!

  • @JackEatock
    @JackEatock 3 роки тому +8

    As a student, I can't explain how useful your videos are at improving my code. Love your channel!

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

    I have not even watched the video in full and I'm fucking mindblown.

  • @snook5555
    @snook5555 5 років тому +18

    Love code quality tutorials, it's an area I'm always looking to improve in

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

    I didn't really get it, until I saw you swap out one script for the other at the end. Then it clicked...mostly.
    such a great video, and the production value is off the charts and very much appreciated

  • @NeoDragonEWW
    @NeoDragonEWW 5 років тому +21

    I love your tutorials. I like that you take on slightly advanced programming topics, show them in a real-world scenarios/use cases, and explain why the topic makes sense - eg. this video on the SOLID ideas that a lot of teams use.

    • @InfallibleCode
      @InfallibleCode  5 років тому +2

      So glad you found it helpful! I really like tackling these advanced topics because their so important and aren't covered very often.

  • @dotaportalvideo
    @dotaportalvideo 4 роки тому +6

    Was not expecting to become a better coder while looking at Unity tutorials today. Nice work.

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

    Came across your channel a couple of days ago and it’s one of my favourite gamedev channels. Your tutorial easy to understand and you explain everything properly like the real problem, options, solutions.
    Great work man. Keep helping people like me.. thanks

  • @bgildersleeve
    @bgildersleeve 5 років тому +5

    Excellent tutorial. It's great to see videos like this that emphasize clean code principles!

  • @CCV334
    @CCV334 5 років тому +1

    This is exactly what I've been looking for. Thank you so much for the clear and concise example!

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

    this explanation of how scripts should interact with each has been just what I needed, thank you

  • @georgew.8282
    @georgew.8282 2 роки тому

    That was one of the most enlightening tutorials I have ever seen. Thank you very much for this!

  • @krisitak
    @krisitak 5 років тому +7

    In this case, instead of interfaces, I'd use abstract classes that inherit from MonoBehaviour. That way you won't have to assume something IS A MonoBehaviour that IMPLEMENTS an interface. Also, some assertions to lock these invariants. Great video, nice editing.

  • @themerpheus
    @themerpheus 5 років тому +3

    Wonderful. Simply wonderful. Good explanation for those of who don't know SOLID principles.

  • @n8dev
    @n8dev 3 роки тому +5

    honestly this is the most helpful tutorial I have ever watched

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

      Wow I really appreciate that!

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

      @@InfallibleCode wow that was quick, I appreciate you making these tutorials so much! I am going to link your video on namespaces in my next devlog, it helped me organize my project really well. With Brackeys gone, I can see you blowing up as much as he did :)

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

      @@n8dev I'm just glad that my videos are helpful, that's the most important thing :D

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

    amazing tutorial, i like how this is just at the level that i am at programming so i can understand everything , thanks!

  • @018FLP
    @018FLP 2 роки тому

    What a relief! I'm an absolute code beginner, so it's easier for me to separate everything for debugging so i naturally code using something very close to this principle. Though i was dumb for making extra steps, but it's very cool to see this is a good practice. Nice!

  • @Walter5850
    @Walter5850 Рік тому

    Brilliant!
    I have been getting back to this video for quite some time, but I just wasn't ready to comprehend the ideas due to lack of knowledge.
    After reading about SOLID principles on my own and looking through some examples, I was able to familiarize myself with the core ideas.
    Afterwards, it was far easier to follow the video and I was able to learn much more from watching it.

  • @Ohlawdie
    @Ohlawdie 5 років тому +3

    Quick, cool, informative - as always Charles! Cheers, much obliged.

  • @funkyjedi
    @funkyjedi 5 років тому +1

    Brilliant and clear, thank you, looking forward to more in the series.

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

    great tutorial. the community needs more videos like this.

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

    All the SOLID principles explained and used in 15 minutes :) Good job.

  • @Osybear
    @Osybear 5 років тому +4

    Thanks for concise tutorial. Keep it up man!

  • @andrewshandle
    @andrewshandle 5 років тому +1

    Fantastic tutorial. When working in the corporate world, I always try and teach the SOLID principles to developers from day one. There's nothing more demoralizing then coming across legacy code with a 12,000 line method in a class that does 37 things and nobody knows how it works. ;)

  • @lightiichen
    @lightiichen 3 роки тому +2

    This REALLY helps a lot as I'm just getting in designing my own game structure but not able to find a tutorial like this. KEEP IT UP BRO!!!!!!

  • @mana20
    @mana20 5 років тому +2

    Great video, looking forward to more architecture related videos. You should do a series on Event architecture(delgates, events, actions, func) to decouple code.

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

    Awesome video! I would love to see this turned into Pure ECS!!

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

    Pretty cool and useful tutorial. Keep it up!❤️

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

    this might bring a little bit more organization in my coding. thank you very much!

  • @android272
    @android272 5 років тому +1

    Thanks for this. I will be using this in my game. I have a class that is equivalent to your selection manager that does way more than what your class did at the beginning of the video. I have a lot of refactoring to do :)

  • @donnyjoe7653
    @donnyjoe7653 Рік тому

    I like how you genuinely want to inform us about green being your favorite color, in a subtle side note 14:04 :D. Thanks for the great content!

  • @tapoutluke
    @tapoutluke 3 роки тому +2

    Thanks for the video! This helped me make a WeaponManager class allowing for different weapon behaviors :D

  • @sparrowhawk81
    @sparrowhawk81 5 років тому +2

    Interfaces are nice. A dev partner and I have been working on a simple 2D shmup for about 1.5 years now (we are taking our time). It came in handy for a lot of stuff. We have interfaces like IProjectile that make it so that all our different types of projectiles HAVE to have a damage value, speed, lifetime, etc etc etc. It also comes in handy when using Zenject, which we do ;-)

    • @InfallibleCode
      @InfallibleCode  5 років тому +1

      Good stuff! I always love to hear about practical examples of OOP concepts being applied in game development.

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

    amazing tutorial!

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

    Thanks for your content, you are my go-to unity related programming Feed!!

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

    Im a beginner and I have no idea what is going on. Maybe I will in a few years. Saving this vid :D

  • @orc_spearman
    @orc_spearman 5 років тому +3

    Very good and easy to understand example, good job and thanks

  • @RenatVasetskyi
    @RenatVasetskyi Рік тому

    good video, I often have crowded classes that are difficult to expand, fater this video i will try to do everything clearly

  • @atakankuloglu4877
    @atakankuloglu4877 2 роки тому

    Perfect explanation. Thank you for sharing your knowledge with the community!

  • @BrokenPuzzle03
    @BrokenPuzzle03 3 роки тому +2

    You have taught me more than my 4 years in University

  • @shoco2
    @shoco2 3 роки тому +5

    Honestly don't know another channel that explains everything so clearly and understandable, great video man

  • @abwuds7208
    @abwuds7208 5 років тому +1

    Great job! Quick question though, why don't you have a Rider warning for the serialized + private fields that don't begin with an underscore?

  • @daniilparokonnyy7980
    @daniilparokonnyy7980 5 років тому +2

    So useful! Thanks a lot!

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

    Hey new subscriber here. Thank you so much. Please keep doing these videos.

  • @BigDaddyGameDev
    @BigDaddyGameDev Рік тому

    Great video! So many tutorials ignore good programming principles. I have a few bad habits to break.

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

    Great tutorial! I have a question though, what would you do if you'd want to combine the two behaviors of the selection responses together, so everytime you hover over a GameObject you'd want to highlight /and/ outline it? Thanks!

  • @wearwolf4202
    @wearwolf4202 Рік тому

    Your pop up literly was in the way of me seeing what you were doing.... thanks

  • @Brian-vs9sd
    @Brian-vs9sd 5 років тому +4

    Wow. This is an excellent tutorial on the SOLID principles. The example you used was so relevant not just to game programming but programming in general. Well OOP anyway.

    • @InfallibleCode
      @InfallibleCode  5 років тому

      I draw on years of experience building enterprise applications when I work on these tutorials. Some people think that those two worlds wouldn't mix but there's plenty of overlap between business and game development. Software is software at the end of the day.

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

    Hello, could you post the link of the outline assets you are using? I got 2 errors related to outline script.

  • @chrisgreenwell3404
    @chrisgreenwell3404 5 років тому +1

    Really great , thank you :)

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

    This feels a lot like a Ryder ad :P
    Really good tutorial though. Certainly got me thinking

  • @myscipper
    @myscipper 2 роки тому +2

    It's so beautyful :)

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

    Excelent, thanks!

  • @alpho94
    @alpho94 2 роки тому +3

    Great video, but I have a question: it appears how in the update method of the SelectionManager you are first deselecting the object and then, if the raycast hit the object, put the selection back in the same frame. Wouldn't be better to put the select and deleselct methods in a if else statement, checking before the value of the raycast, so that you don't run both and save performance? also since those methods do the same thing, they could be unified by creating a single method which change the material or a value in the case of the outline, as taking it as input paramenter.

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

    Quality content!

  • @Robbin_Bob
    @Robbin_Bob 2 роки тому

    probably a bit late to this but that syntax highlighting theme you have is amazing, what setup do you have?

  • @ZoidbergForPresident
    @ZoidbergForPresident 5 років тому +3

    Quickie: we could use a List, right? To get outline AND highlight?

  • @AethernaLuxen
    @AethernaLuxen 3 роки тому +2

    Great tutorial! Btw, captions are broken

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

    You got my subscription, man!

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

      Awesome, thank you!

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

      @@InfallibleCode Got to complete test assignment for Unity programmer job. your channel really helps.

  • @yuriilunha
    @yuriilunha 2 роки тому

    awesome!

  • @Sindrijo
    @Sindrijo 5 років тому +2

    Not that it is important to the lessons shown in this video but you could derive from Unitys IPointerEnterHandler and IPointerExitHandler interfaces (in the UnityEngine.EventSystems) instead of implementing your own raycaster. (Note that you do need to add a Physics Raycaster component to your Camera object for it to work, which I saw another comment mentioning but is actually not needed since the code in the video is doing its own raycast.)

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

    I wrote my own "selection manager" raycast code a long time ago, I didn't knew there was an already made one. So I never had those limitations...

  • @orinom4128
    @orinom4128 2 роки тому

    Your cats tail at the start made me think I had a spider on my screen and i proceeded to spend the next 3 minutes trying to find the spider in my phone

  • @nelsonthekinger
    @nelsonthekinger 7 місяців тому

    quality content!

  • @JJordanov945
    @JJordanov945 3 роки тому +2

    Is there any way we can use both Highlight and Outline Selection Responses simultaneously? I've been playing around with it but as you've mentioned in the vid you have to remove one to place the other. I want to know if I could make a third Response class, say InteractiveSelectionResponse, which is responsible for handling mouse input when you press on a selected object, while still making use of the HighlightSelectionResponse component for visual feedback.

  • @lunkums
    @lunkums 3 роки тому +2

    Hi! awesome tutorial you've created, but i have one question. What is the difference between the deselect and select code bodies? They look identical

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

      nevermind, i didn't see that deselect was default mat and select was highlight mat. Thank you

  •  5 років тому +2

    Tip for clean code : event handlers should call a function, but not contain implementation. You want to have a quick look at it and understand what is going on, not read throguh the whole event.

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

    how is the tag being referenced in the new classes you created from the selectionManager ?

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

    why do you name some variables with an _ at the beginning?

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

    Very helpful video. I've been trying to internalize the SOLID principles for learning how to write enterprise web applications too and have been struggling with how exactly to apply the open-close principle. I understand writing the functionality in a separate class but still haven't really figured out how to get the manager to automatically pick up the new functionality without adding code directly to it to instantiate the new functionality. It's interesting to see how you can automatically pull from the components with the matching interface here in Unity with how things are plugged together in the editor but I'm guessing I'm not going to be able to pull the same thing in my Node app xD.
    I am very curious though, what would happen if you had both components extending the ISelectionResponse interface still attached to the same game object? Would it just return an error? How would it know which one to assign to _selectionResponse?

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

      To answer your first concern, it's rarely about automation and more about maintenance. You have to give the program a class, it isn't magic, somewhere in the chain a dependency must be injected. In this case it's injected through GetComponent, and then assigned by the designer in the editor. If the ISelectionResponse wasn't a mono, you might assign the specific class in Start instead. Using a DI framework, you would specify which ISelectionResponse you want in the inector, and it would go through your code and swap all references for you. If this was an IWeapon, you might get the specific item from a random loot spawn...but of course you'd have to manually add it to the list of things that can spawn, so you still have to type it in or drag and drop it somewhere.
      Imagine tomorrow Unity said "We arent using Nvidia PhysX, we are using some other thing" and you realize that the new thing doesn't have "AddForce" and instead uses something else that takes completely different parameters? Well now you have to go through every new error in the log and replace AddForce with something new, redoing all of your math. If this was a corporate app, you wouldn't have used Nvidias RigidBody, you would have used an IRigidbody with an AddForce function that interfaces with Nvidias Rigidbody. When your boss tells you they made a deal with some new physics company and you are using their backend now, all you'd have to do is write a different IRigidbody that interfaces with the new system with an AddForce function that does the conversion for you behind the scenes. Swap your dependencies in the relevant scripts and it all just works!
      In Unity, a more realistic example would be a gun. What if you have multiple gun classes? Every time the player clicks do you "If Gun1 then Gun1.Shoot(), if Gun2 then Gun2.Shoot()...etc etc etc? Maybe we could use inheritance. All guns can inherit the abstract "Gun" class, and that class can have a "Shoot" method. Then the player class can just Gun.Shoot()...but what if we wanted to add a Final Fantasy Gun blade? Now we need a Stab...maybe we should have a Weapon base class with melee and shoot...but what if my gun is made of chocolate and my character can eat it? I can't derive from Powerup And Weapon...but you can have more than one interface. My can can be IItem, IRanged, IMelee, and IEdible, and my player script doesn't need 1,000 nested if statements.

  • @happyfarang
    @happyfarang 5 років тому +2

    Great video. Very solid info. I just wonder, what if you want to make the response conditional, f.ex say, if you looking north make them yellow, if not then use the green outline. Something like that. You would have to make a new class with both interfaces? or am i missing something obvious here? :) I will have to watch this a few times

    • @InfallibleCode
      @InfallibleCode  5 років тому

      If you wanted to response to be conditional then you could apply the Null Object pattern. But if you wanted to implement more sophisticated behavior then you'd need to implement a new class to handle it. Does that make sense?

    • @happyfarang
      @happyfarang 5 років тому +1

      @@InfallibleCode Makes total sense :) I think i understand it! I will try to make my own test. I like this pattern. The "kind of generic" approach hehe.

  • @Yulaw2k
    @Yulaw2k 5 років тому +1

    What about putting any ISelectionResponse as a scriptable Object. Since its only being used by the SelectionManager. You know how an scene object can have alot of components attached to it. Instead of adding another one script to the object, you can drag the selection behavior onto the script using it. Is this a good, or bad idea?

  • @marcinsurmiak4092
    @marcinsurmiak4092 5 років тому +1

    Very good :) as always. but what about DRY principle? I always wonder is this piece of my code, is small enough that can be repeated.

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

      I always match DRY with the Rule Of 3. When I find myself writing it for the third time, I should really consider an interface or inheritance. The exception to this is third party plugins and frameworks. In this case, hes interfacing with an asset. What if he needs a new Unity version that isn't compatible with that asset? What if the asset has a bug, is closed source, and the creator ghosted the project? What if your boss tells you networking package A is out, and networking package B is in? Interfaces are like condoms for third party assets.

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

    I have a few questions:
    1. How does the concrete SelectionResponse seep into the code as it just initialises ISelectionResponse the interface?
    2. What if I want both effect to manifest? Highlight and outline together?

  • @monkeyrobotsinc.9875
    @monkeyrobotsinc.9875 3 роки тому +1

    yep. green is a great color.

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

    This is a bit out of my scope of c#, i have an idea though it would be nice if you made a c# basics and intermediate series but to stand out from all the other youtube videos that do this you could make the video like you did in your "Unity Events in Action" and "C# Events in Unity" videos. I like how you incorporated problem solving while also teaching code in a in game project. Many many youtube c# series just teach you the basic syntax and read the definition from the documentation and don't show in game examples.

  • @Yulaw2k
    @Yulaw2k 5 років тому +3

    Please make more videos like THIS. Do it again with example 2, then example 3. You got alot of views on this. If you check out your spatialOS videos....not many views.... We appreciate your skills as a coder more then you dabbling into the "new".

    • @InfallibleCode
      @InfallibleCode  5 років тому +1

      Haha don’t worry more videos like THIS are definitely on the way. Only one more video left in the SpatialOS series so stay tuned to the channel.

    • @Yulaw2k
      @Yulaw2k 5 років тому

      ​@@InfallibleCode "Celebrates"

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

    I am confused, is the downloadable project one before or after the refactoring is done?

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

    The problem I have is I try to make my own physics, sort of.
    I try to make everything come down to one vector3 mainMovement.
    Then other methods such as SlopeDifference use transform.forward and input.
    It becomes a cluster**** of variables they use that is shared and changed through the entire script.

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

    thanks for the tutorial, it would have been great if you only used 2/4 of your objects to use the new green highlight methods while having the others still swap to yellow, if that is instead of it would have worked.

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

    Hi Charles! Great video! Is making monobehaviour uicontroller an interface a good idea? I wanted to make an interface out of it so maybe pc has different UI than mobile game but if they use the same interface I could just find the interface in Game Manager class and use whatever UI type I get. But can't find a good way to find my UI interface beside var ui = FindObjectsOfType().OfType(). Do you think it's a good way to do it? Thanks!

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

      Hi Charles! Sorry to bother you but after asking the question I came up with a solution. I get a public GameObject to the uicontroller monobehaviour and use on it GetComponent instead of looping through all the monobehaviour. Do you think it's a good workaround? Thanks!

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

    Ding ding, subbed XD

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

    thanks for the video, i have followed the instructions based on the video. but i have problem with this error 'The type or namespace "Outline" could not be found (are you missing a using directive or an assembly reference?)'. how to fix it? thanks

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

      Did you make sure to actually download the Outline pack he said he got off the store? Outline isn’t a native component to Unity so unless you got the same asset off the store Unity has no idea what that is.

  • @starbuck3980
    @starbuck3980 2 роки тому

    But actually how would be using the Liskov substitution principle? as you use other class with the same method names but actually the functionality changes, and the principle says functionality must not change

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

    What's the "set by unity" thing?

  • @omeryilmaz1021
    @omeryilmaz1021 Рік тому

    you do run OnSelect() and OnDeselect() method at the sametime when mouse enters on "Selectable" object, what s the point of that?

  • @InfernalA1D
    @InfernalA1D 5 років тому +1

    What means liskov substitution principle in terms of Unity? Not so clear for me as a novice

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

    i started unity 1 year ago and i tried this tutorial last year. I didnt understand anything :D maaan now i see how messy my code actually is. As a software engineering student in 2. semester i just learned how to code object oriented and with an mvc principle but i feel i cant use these methods in unity/c#

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

    How to change _selectionResponse value at runtime?

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

    Does raycast work in augmentation reality

  • @NorthernlionLP
    @NorthernlionLP 2 роки тому +3

    Decent video, using so many IDE options instead of just copy-pasting was slightly infuriating tho :p

    • @endorphingames2957
      @endorphingames2957 Рік тому

      Yes make it more complicated looking at specific IDE functionality rather than copy paste

  • @-Engineering01-
    @-Engineering01- Рік тому +1

    I think this is a double edged knife.
    We use these patterns to make the code look more readable but at the same time we're over engineering the code with lot of classes especially for a small hyper casual game where at these patterns maybe never needed.

  • @r1pfake521
    @r1pfake521 5 років тому +3

    The only annoying thing here is that Unity can't serialize interfaces so you can't drag&drop them in the editor. That's why I usually create a abstract base class which also inherits from MonoBehaviour instead (obviously this only works if the class only implements a single "interface", because otherwise it couldn't inherit from multiple abstract classes).
    It's kinda ugly, but I don't want to lose the drag&drop workflow in the editor.

  • @darkman237
    @darkman237 2 роки тому +3

    What about using c# events to decouple the code?

    • @endorphingames2957
      @endorphingames2957 Рік тому

      Yes, I would have a script on each object with the functionality of changing its own material. Selection manager would only sent events on raycast.

  • @demarcorr
    @demarcorr Рік тому

    its prob just a preference thing and im prob in the wrong, but seeing 2 if blocks just to call OnSelect vs OnDeselect really just jimmies my rustles. I would slap a ternary conditional on one line and be done