Hello world. Your first program

Слайд 2

Topics

Hello World?
Creating a Unity Project
The Unity Project Folder
MonoDevelop: Unity's Code Editor
Attaching Scripts

Topics Hello World? Creating a Unity Project The Unity Project Folder MonoDevelop:
to GameObjects
Start() and Update()
GameObject Prefabs and Instantiation
The HelloWorld Project

Слайд 3

Hello World?

Hello World is often the first program written by anyone learning

Hello World? Hello World is often the first program written by anyone
a new programming language.
Outputs "Hello World!" to the Console

Слайд 4

Hello World?

The code of HelloWorld.cs is very simple:

Hello World? The code of HelloWorld.cs is very simple:

Слайд 5

Creating a Unity Project

From the menu bar, choose File > New Project…
Choose

Creating a Unity Project From the menu bar, choose File > New
the location for your project folder
Mac OS X
Click the Set… button
Navigate to the right location
Type the project name into the Save As field
Click the Save button
Windows
Click the Browse… button
Navigate to the right location
Click the New Folder button and give the new folder the name of your project.
Click the Select Folder button

Слайд 6

Creating a Unity Project

Set up defaults for 3D
Click the Create Project or

Creating a Unity Project Set up defaults for 3D Click the Create
Create button
Appendix A contains detailed instructions

Слайд 7

Creating a Unity Project

The Project pane shows the contents of the Assets

Creating a Unity Project The Project pane shows the contents of the
folder inside your Unity project folder
Right-click in the Project pane and choose Reveal in Finder (or Show in Explorer) from the pop-up menu

Слайд 8

MonoDevelop: Unity's Code Editor

Unity uses MonoDevelop for code editing
MonoDevelop is a separate

MonoDevelop: Unity's Code Editor Unity uses MonoDevelop for code editing MonoDevelop is
program developed by a different team
To open MonoDevelop, double-click any C# script in your Project pane
This will launch MonoDevelop
Though the launch process takes some time
You must save a document in MonoDevelop for it to recompile and update in Unity
On Windows, Microsoft Visual Studio may be used
Instructions for this can be found online

Слайд 9

MonoDevelop: Unity's Code Editor

The MonoDevelop Window

Code Pane

Classes Pane

Document Outline Pane

MonoDevelop: Unity's Code Editor The MonoDevelop Window Code Pane Classes Pane Document Outline Pane

Слайд 10

Attaching Scripts to GameObjects

To work in Unity, a C# script must be

Attaching Scripts to GameObjects To work in Unity, a C# script must
attached to a GameObject

Слайд 11

Attaching Scripts to GameObjects

This makes the script a component of the GameObject

Attaching Scripts to GameObjects This makes the script a component of the GameObject

Слайд 12

Start() and Update()

You make use of Start() and Update() in the HelloWorld

Start() and Update() You make use of Start() and Update() in the
project
void Start() {…}
Called once
Called immediately before the first Update() is called
void Update() {…}
Called every frame
This can happen over 200 times per second!
void Awake() {…} (not used in HelloWorld, but important)
Called once
Called at the moment the GameObject is created
Guaranteed to be called before Start()

Слайд 13

GameObject Prefabs and Instantiation

A prefab is a mold from which GameObject instances

GameObject Prefabs and Instantiation A prefab is a mold from which GameObject
can be made
Created by dragging a GameObject from the Hierarchy pane into the Project pane
Can be assigned to a script variable in the Inspector pane
public GameObject gameObjectPrefab;
Then, an instance of the prefab can be created in code
Instantiate( gameObjectPrefab );
This is used in HelloWorld to create thousands of instances of a Cube GameObject prefab

Слайд 14

The HelloWorld Project

Output "Hello World!" to the Console pane
Once using Start()
Many times

The HelloWorld Project Output "Hello World!" to the Console pane Once using
using Update()
Create a Cube prefab that reacts to gravity & physics
Instantiate an instance of the Cube prefab
Once using Start()
Many times using Update()
This will create a cascade of thousands of Cube instances
Over other physically-modeled objects

Слайд 15

The HelloWorld Project

The final HelloWorld scene

The HelloWorld Project The final HelloWorld scene
Имя файла: Hello-world.-Your-first-program.pptx
Количество просмотров: 40
Количество скачиваний: 0