Let’s Take A Look At Some C# Code

by Tara Nakano

in

Hello everyone! Welcome back! I’ve been thinking about how I should make this post and the best idea I came up with is just to take you along and show you the problems I’m working on. Curl up with something warm to drink and let’s dive in.

For starters, I should point out that, in regards to programing, I’m completely self taught. I may have some weird, quirky, ideas that may not be entirely accurate. If you notice anything, just let me know. I’m always eager to update my understanding of things.

Let’s start off with one of those quirky ideas. How I organize scripts. I like to think of a script as a complete idea. There are times where, like a run on sentence, you can just go on and on. However, I like to compartmentalize things a bit more. One idea equals one script. That helps keep it clean. Some scripts are short some are long, but I like to keep it to one idea.

Let’s take a look at the ‘idea’ that I’m working on right now. I’m updating my canvas controller.

Ha ha ha… any questions? I need to work on lines 50 and 51. The game I’ve set up just spawns two objects: a reward object and an obstacle (a bomb). Currently, I’m working on expanding the reward objects by switching them out for various multiplication facts. Let me walk you through the rest of the code so you can see what I have going on here.

Lines 1 -6 tell Unity which libraries it needs to access. Some of them are in active right now but they were active at one point. After I have everything working the way that I want, I’ll go through and delete all the inactive libraries. Because this is the canvas, this is where all the button/ font stuff will be displayed. You’ll need text mesh pro and the user interface libraries to do this. I also have the scene management library plugged in because I’m going to have various transitions to menus and different levels.

Next up, lines 9 through 20.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *