Day 18
Today, I studied more C#. I am learning about Classes. Before I demonstrate coding for Classes, I would like to backtrack a bit to reiterate what “Scripting” is and how to perform it. According to Technopedia.com, “Scripts are lists of commands executed by certain programs or scripting engines. They are usually text documents with instructions written using a scripting language. They are used to generate Web pages and to automate computer processes.”
Three steps forward, one step back- Create a new Script in Unity begins with a right click on “Assets”, then go to Create and click “C++Script”. Name the script. Drag and drop the new script onto the selected Object in the Hierachy. Now, you can open the script in Visual Studio. That is a Ready, Set, Go way of creating new script and then opening it up.
Forward to Classes: Herein is the example from the C++ tutorial:
CustomerDatabase
public string firstName; public string lastName, public int age, public string gender; public string occupation
publicCustomer(string first, string last, int age, string gender, string occupation);
Customer Details:
Jonathan=newCustomer(“Jonathan”, Weinberger”, 26, “M”, “
Software Engineer”);
Janet=newCustomer(“Janet”, “ “, 55, “F”, “Instructor”);
Jessica=newCustomer(“Jessica”, “Lang”, 23, “F”, “Scientist”);
Allow the customer details to pass through to the Inspector in Unity and, there is, your Customer Database. For all the details on this code, go to the topic “Classes” in C++ in the Gamedevhq.com website.