Clean Up Your Update Loop - Unity C# Development Tips

Veröffentlicht am: 12 Juni 2023
auf dem Kanal: Hunter Dyar
340
8

Multiple return statements instead of if statements can end up causing more headaches than they fix; as can the opposite. It's a tool to be aware of, but it's also developer preference. Just do what you find easy to read and are comfortable with.

In JetBrains Rider, you can right click on an if statement to pull up "Context Actions", and have it "invert if" for you - and you can do it again if you change your mind. You can also select a block of code in your Update loop and right click, then go "Refactor, Extract Method" to automatically pull a function out. Neat!

Also, I know you can write the return code in one line: "if(!a) return;" without the curly braces. I don't teach one-liners to my students as it's a common cause of bugs specifically when transitioning from python to C#, as they look similar but behave differently, so I keep curly braces explicit to avoid confusion there.


Auf dieser Seite können Sie das Online-Video Clean Up Your Update Loop - Unity C# Development Tips mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Hunter Dyar 12 Juni 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 340 Mal angesehen und es wurde von 8 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!