Search Unity

Where is the best place to learn C# for unity with good practices and in detail

Discussion in 'Scripting' started by SprayNpraY, Sep 14, 2018.

  1. SprayNpraY

    SprayNpraY

    Joined:
    Oct 2, 2014
    Posts:
    79
    Hi I know this question may trigger some people and mention a 1000 different places I can learn both C# and unity and I've already used a large variety of platforms. But my problem is finding a course or a channel that goes into using C# for unity that goes into detail, for example, the syntactic sugar and best practices for applying concepts rather than just saying the bare minimum basics of what it is for.

    For C# specific tutorials, it's easy to find very high-quality tutorials but I'm unfortunately struggling to find the same quality when combined with using unity.

    Its much harder to unlearn and replace bad habits and practices replace with good practices then it is to do so with less or no prior knowledge. Which is why it's so important to me I learn good practices from the start.

    I'm even considering hiring a personal tutor but I'm currently having no luck where to find C# tutorials for unity like I say that covers both whats going off under the hood and best practices in detail.

    If anyone is an advanced unity developer I'd very much appreciate a pointer in the right direction.

    Thanks
     
  2. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    969
    Best practices are unfortunately very subjective, and like you suspected, opinions will vary. Sometimes quite strongly so.

    My own opinions actually also vary depending on the team size and complexity of what we're trying to do. If the team is large and there's a lot of potential for code overlaps and people stepping on each others toes, then I'd focus a lot more on defensive coding.

    However, if it's a small team of people I know and trust, then I'd probably relax and focus more on getting S*** done, and less on making my code safe from others.

    What I'm saying is: If my own opinions vary depending on team size and the situation, I'm not sure there's any one article or tutorial people can point at and say, "That's the definitive way of doing things with Unity." If there had to be a site I'd point to, I'd probably use this one: https://unity3d.com/learn/tutorials/s/best-practices. Or maybe this: https://unity3d.com/learn/tutorials/s/scripting

    A few big generalizations I can make at this stage are:

    - Keep your UI and data separate. Your UI is supposed to reflect your data, not control your data. See "Model-View-Controller" or "Model-View-Viewmodel" patterns as examples of this.

    - Unity encourages more component-driven systems than inheritance systems. Of course, this comes with exceptions. There are always exceptions.

    - Only use Awake for self-initialization. Use Start for initializing with other stuff.

    Honestly, I'd say just create stuff, and don't worry about making mistakes. Learning from mistakes is honestly the best way to learn, IMO. If you let yourself get caught up in over-engineering things to the point where things become so abstract that reading your code is like looking at air currents, you're not getting anything done. Your coworkers also won't want to touch your code so it'll end up being on you to fix bugs related to your code, which defeats the point of all that abstraction.
     
    SprayNpraY, Munchy2007 and kastor7000 like this.
  3. SprayNpraY

    SprayNpraY

    Joined:
    Oct 2, 2014
    Posts:
    79
    Thanks for the detailed response, I can see where you're coming from and like most fields and industries there are many ways to "skin a cat" so to speak. I used to be a personal trainer and its the same within the fitness industry and I'm experiencing the same going into programming and game development as I did originally entering the fitness industry there are so many different views its difficult to know which path to follow.

    I'm not looking for the perfect path to learn from just somewhere/someone that even if it isn't the very best approach it is still general good practice and knowledge as even with my lack of knowledge and experience I've been coming across alot of awful tutorials which makes me think they must be even worse than I realize if I can tell it isn't exactly great.

    I guess I may have to take the approach you have suggested and just keep trying to create stuff myself and learn that way. Hopefully I can find places to learn from that will speed up the process.
     
  4. StickyHoneybuns

    StickyHoneybuns

    Joined:
    Jan 16, 2018
    Posts:
    207
    I have years of schooling and professional development using different languages. However, when I started Unity I had no idea what the best practices are for game design. To be honest, the best place to start is right here on Unity's own website. Start with the Unity tutorials. I think all of them have Java and C# scripting and they are easy to follow.

    https://unity3d.com/learn/tutorials

    Secondly, I found a lot of best practices in Unity's documentation. For instance:
    https://docs.unity3d.com/ScriptReference/GameObject.Find.html

    It clearly states in the above doc to use sparingly due to performance issues and instead to cache the result first.

    So if you haven't done the tutorials I woul do them and then go onto to external tutorials.

    Also, HumbleBundle is having an amazing deal on a Unity package. For 15 dollars you can get about $1600 worth of assets and games. One asset is a $600 tutorial for game development. I have the package but havn't done the tutorail so I can't comment on that. Note that this package is only available for about 21 more hours so hurry up and get it. I would provide a link but I can't go to HumbleBundle on this PC(work).
     
    SprayNpraY likes this.
  5. SprayNpraY

    SprayNpraY

    Joined:
    Oct 2, 2014
    Posts:
    79
    Thanks for the reply stickeyhoneybun lol feel like I'm flirting saying your name

    I have only just seen your message but thankfully I received an ad for the bundle and purchased it for $15 and got the whole bundle including the tutorials you have mentioned. I will definitely check them out soon. I already have a few unity tutorials on udemy but the main thing that had irritated me to start this post was the ones supposedly made in partnership or something with unity where ironically its the worst ones out of all of them and doesn't seem to be anywhere near the standard of the tutorials on unitys official website.

    I guess I will follow the tutorials on here that you have both suggested it would have been easier I'm guessing to have a series of tutorials to follow that progress from each other that shows you how to apply them into making a game rather than aspects that can be applied as part of making a game if that makes sense?

    Anyway I will work through all of these tutorials and read their best practices guides and guess I will give the tutorials I got in that bundle a go. Thanks again for your inputs.
     
  6. SprayNpraY

    SprayNpraY

    Joined:
    Oct 2, 2014
    Posts:
    79
    Just read your message again I wasn't aware of this, It seems like a similar concept I've seen in some C# specific tutorials for creating more loosely coupled applications I found a good youtube tutorial for those of you interested in this concept: