Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Catlike Coding's C# and Shader Text Tutorials

Discussion in 'Community Learning & Teaching' started by Jasper-Flick, Jul 31, 2011.

  1. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    Want to learn C# and shader scripting in Unity? Prefer text tutorials? You are in the right place!

    Catlike Coding's Unity C# and Shader Tutorials

    The creation of these tutorials is funded via Patreon. It's like Kickstarter or Indiegogo campaign, but ongoing. If you enjoy what's available now and want more, please become my patron!

    Basics
    These tutorials provide an introduction to working with Unity.



    Pseudorandom Noise
    A series about generating and using pseudorandom noise.



    Procedural Meshes
    A series about generating procedural meshes.



    Pseudorandom Surfaces
    A series about generating pseudorandom surfaces.



    Prototypes
    A series about creating small game prototypes.



    Movement

    A series about controlling the movement of a character.



    Object Management
    A series of tutorials that deals with creating, keeping track of, saving, and loading game objects.



    Tower Defense
    A series about creating a simple grid-based tower defense game.



    Flow
    A collection of tutorials that cover the creation of flow effects, like water surfaces.



    Mesh Basics
    An introduction to procedural meshes. From a simple grid to deformable balls.



    Custom SRP
    A collection of tutorials about creating a custom scriptable render pipeline in Unity.



    Rendering
    A series about understanding Unity's rendering pipeline. How a mesh turns into pixels that look like real objects.



    Advanced Rendering
    These are tutorials covering more complex or specialized rendering techniques, going beyond Unity's standard shaders. They build on the work done in the Rendering series.



    Hex Map
    A series about hexagon maps. Lots of strategy games use them.



    Marching Squares
    A series about drawing and reconstructing shapes using a 2D grid. Why not Marching Cubes? Because the concepts are the same for both 2D and 3D, and dealing with two dimensions is already complex enough.




    Found these tutorials useful? Want more? Become my patron via Patreon or Ko-fi!


    (What follows is the original first post from more than a decade ago.)
    Hi! I made a very basic C# text tutorial: Clock, a Unity C# tutorial. It's aimed at people who want to learn to program in Unity. It's a first draft. Feedback is appreciated! I'm wondering if there's interest in this kind of tutorial, as opposed to video tutorials. If there is, I'll make more.
     
    Last edited: Oct 13, 2023
  2. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
    Hi,
    I had a very quick look at the tutorial, just a summary look and it looks good. I am sure there will be interest if you were to make more, no doubt!
     
  3. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    I sure hope so! By now - less than a day online - it got a couple dozen views and people are already finding it on Google. I'll make a second one using the same format.
     
  4. sp00ks222

    sp00ks222

    Joined:
    May 12, 2011
    Posts:
    37
    excellent, I like the format a lot and the questions and answers at the end. I can't wait to see another one! (my vote is 2d sidescroller or top down view)
     
  5. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    Thanks, good to know! The next one is in the works, it's about drawing graphs. After that, maybe a sidescroller.
     
  6. pothb

    pothb

    Joined:
    Oct 19, 2010
    Posts:
    81
    Took a quick look, very cool. I'd love to see more, especially after I get through this other tutorial.
     
  7. shineget

    shineget

    Joined:
    Aug 7, 2011
    Posts:
    1
    Yes! It'd be helpful for newbies like me!
     
  8. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    All right then! I got the second tutorial done: Graphs!

    I decided that the third one will be a simple side-scroller. However, these things are a lot of work, so I'm asking for donations. If I get a little money I'll go ahead and create it.
     
  9. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
    I did not look at the graph tutorial yet... but maybe to stimulate people to donate you may want to do some preview of the side-scroller or description of what it will cover... or if the tutorial is really good and in depth you could even stick a pice to it, maybe.
     
  10. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    Yes, I'll put up some preview material, but I'm super busy right now so it'll take a while. The donation thing is an experiment. If it doesn't work, I'll switch to simply selling it.
     
  11. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
    Had a better look at your 2 existing tutorials, they are good.
    You may also consider what others do, e.g. Burzergarcade.com and his YouTube channel. Ads revenue. With good traffic it may work.
     
  12. ar0nax

    ar0nax

    Joined:
    May 26, 2011
    Posts:
    485
    it's perfect for beginners :D
     
  13. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    :) Nice to know you two like them!

    I'm not fond of ads but it's certainly an option to investigate, if the traffic gets good.
     
    Last edited: Aug 11, 2011
  14. Adeno

    Adeno

    Joined:
    Aug 7, 2011
    Posts:
    184
    Hey this is good, I'm actually learning C# right now, so the combo of Unity and C# is something that I really find great, I hope you make more, thanks for this :)
     
  15. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    Yes, there'll be more! I'm still figuring out the best way to fit it in my schedule though.
     
  16. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    :) Well, here it is, my third tutorial: Runner!

    This is the side-scroller I mentioned before. Subjects it deals with include physics, object reuse, events, layered backgrounds, player input, and GUI. Have fun!
     
  17. ar0nax

    ar0nax

    Joined:
    May 26, 2011
    Posts:
    485
    nice tutorial, very well explained.
     
  18. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    I've released my fourth tutorial, Star!

    $star-editing.png

    This tutorial shows you how to create your own custom editor. You will make a star component that uses a dynamically generated mesh. Then you will build a nice inspector for it, add WYSIWYG editing, and allow editing right in the scene view, while supporting undo, redo, reset, prefabs, and multi-object editing.

    Go check it out!
     
  19. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    I've finally updated the Graphs tutorial so it uses the new Shuriken particle system! Not much changed, but it got a little easier to use and performs better.
     
  20. Tharkis

    Tharkis

    Joined:
    Mar 7, 2012
    Posts:
    16
    Personally, I much prefer text-based tutorials. I hate having to stop-rewind-pause-rewind-pause-pause all the time. I don't always type or move as fast as the guy who has been using unity or scripting forever. Text tutorials give you the ability to work at a slower pace. I would love to see many many more of them.
     
  21. calabi

    calabi

    Joined:
    Oct 29, 2009
    Posts:
    232
    Great tutorials, they work for me.
     
  22. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    :) Great! Thanks for telling.
     
  23. red2blue

    red2blue

    Joined:
    Feb 26, 2013
    Posts:
    200
    Hi Jasper,

    i did the first and the second Tutorial. They were very, very good! I learned a lot!! Right now i am doing the sidescoller tutorial and it works perfect for me. You explain very good and I got never lost! Would love to see other tutorials as well ;-)

    Keep going!!!

    Cheers
     
  24. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    I've updated the Clock tutorial to Unity 4. Mostly some small visual changes, some Q&A tweaks, and the download is now a unitypackage.

    I'm also working on new tutorials. Started out as just one, but got way too big so instead I'm working on a series.
     
  25. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    The Graphs tutorial has been updated as well. It has some new tidbits, like the Range attribute and programming while staying in play mode.
     
  26. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,865
    Thanks. I really liked your tutorials. Couldn't complete the last one though, it was really hard.
     
  27. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    You mean the Star one? I also need to update that one to Unity 4. Was there something specific you got stuck with?
     
  28. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    Finally, Runner is now fully up-to-date with Unity 4!
     
  29. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    I added a new tutorial. It's part of an upcoming set that will replace the Star tutorial.

    Custom Data, an introduction to serialized classes and property drawers
    This tutorial shows how to create a custom data type and how to write a property drawer for it.
     
  30. 0x12

    0x12

    Joined:
    Sep 13, 2013
    Posts:
    1
    Thanks a lot Jasper! I started to work through two of your tutorials and they are great. I've learned so much in a short period of time!
     
  31. Overx

    Overx

    Joined:
    Oct 22, 2012
    Posts:
    11
    Finally some text tutorials! Thanks for making these.
     
  32. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @0x12 Overx: Great to hear they're useful!

    I just released the second editor tutorial of the set.

    Custom List, displaying data your way
    This tutorial shows how to use an attribute and a property drawer to customize how lists are shown in the editor.
     
  33. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    And the third editor tutorial is out! I also kept the old Star tutorial available, for those who still use Unity 3.

    Star, an introduction to custom editors
    This tutorial shows how to use an attribute and a property drawer to customize how lists are shown in the editor.
     
  34. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    Dude, your graph tutorial is such a badass! I'm totally impressed! I've been wanting to do this years ago! (didn't know Unity at that time) - I used to draw stuff with nucala (simple grapher) - But your stuff is crazy! - Please tell me you're not a super genius and you didn't come up with all the equations/functions by yourself! o.o - Where did you get the functions equations from? - Thanks a lot!
     
  35. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    I hope you can answer me soon about those formulas, I'd really appreciate. I'm currently trying to graph a heart shape, no luck :/
     
  36. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @vexe: The functions are simple combinations of basic mathematics, nothing special. Especially sines can be pretty all by themselves.

    A heart shape is more complex, as it consists of multiple parts. Below is an example I made from a formula I grabbed from the web. First I scale it to fit inside the graph's 0-1 domain and add a time-based pulse to it. Then I precompute some squares and a cube of the coordinates, which makes it easier to see what's going on. Then I describe a sphere flattened on the Z-axis. Then I mold it into a heart-shape, whose boundary is where the formula hits zero.

    Code (csharp):
    1.     private static float Heart (Vector3 p, float t){
    2.         t = Mathf.Sin(t);
    3.         t = 3f - 0.5f * t * t;
    4.         p *= t;
    5.         t *= 0.5f;
    6.         p.x -= t;
    7.         p.y -= t;
    8.         p.z -= t;
    9.        
    10.         float
    11.             x2 = p.x * p.x,
    12.             y2 = p.y * p.y,
    13.             y3 = p.y * y2,
    14.             z2 = p.z * p.z;
    15.        
    16.         float s = x2 + y2 + z2 + z2 - 1f;
    17.         s = s * s * s;
    18.        
    19.         return s - z2 * y3 * 0.1f - x2 * y3 <= 0f ? 1f : 0f;
    20.     }
    $heart.png
     
  37. Stevepunk

    Stevepunk

    Joined:
    Oct 20, 2013
    Posts:
    205
    Hi I just tried this but it does not work.
    I have sent you an email.

    Cheers,
    Steve
     
  38. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @Cereal_Killa: It works just fine for me, with Unity 4.2.2f1. What version are you using? Are you getting any errors? Does the script compile?
     
  39. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    I have updated the Clock, Graphs, and Runner tutorials to Unity 4.3. The screenshots now show the new editor UI and I fixed some typos and inconsistencies.

    The editor tutorials still need to be updated. They require extra work because of some changes to Unity's editor API.
     
  40. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    @Jasper thanks for everything really appreciated. I'm currently trying to learn writing custom inspectors and editor scripting. I found your tutorials to be nice. But at the top of each tutorial it says "needs to be updated to work with 4.3" or something. Can't I take the stuff from the tutorial as is and learn from them? or do I have to wait for you to update them? if so... please consider taking the time doing so. There is very little material on that subject in the internet. Thanks. And keep us updated.
     
  41. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @vexe: The biggest thing 4.3 changed is the way attributes are applied to lists, so the custom list tutorial doesn't work any more. It still works fine in Unity 4.2.2, but that's now of limited usability. I'd love to update them but time is the problem. Maybe I'll find some during the holidays.
     
  42. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    I have updated the Custom Data tutorial so it works with Unity 4.3. It's now quite a bit different. The other editor tutorials will follow later.
     
  43. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    644
    Thank you!! :) - Can't wait for the rest!
     
  44. create3dgames

    create3dgames

    Joined:
    Aug 20, 2012
    Posts:
    275
    Really nice tutorials, very professional!
     
  45. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    The Custom List tutorial now also works with Unity 4.3! This one changed quite a bit as well, so it's worth checking out even if you've already done the old version.
     
  46. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    And finally the Star tutorial has been updated to Unity 4.3! It got a bit simpler, thanks to the changes to the other editor tutorials.
     
  47. DalerHakimov

    DalerHakimov

    Joined:
    Mar 14, 2014
    Posts:
    302
    Very good and professional. Bookmarked your web site. One advice, you could add at the beginning of your articles a Unity web player with the end result. It's always good to see what we are going to do. Keep it up
     
  48. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @DalerHakimov: Thanks! The Runner tutorial has a web player at the beginning. But the others so far don't have anything interactive to show.
     
  49. S3dition

    S3dition

    Joined:
    Jan 6, 2013
    Posts:
    252
    Excellent tutorial!

    One suggestion - It doesn't cover the usage of "this". You just use it in the second tutorial without explaining it, which may throw newbies. I'd recommend adding an explanation for it.
     
  50. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @S3dition: Thank you! There was a Q&A for it somewhere but it got lost during the 4.3 update. I added a new one.