26
Mark Rondina Unite 12 For Introduction to Unity for AS3 Developers Mark Rondina Unite 12 1 Tuesday, April 30, 13

Intro to unity for as3

Embed Size (px)

DESCRIPTION

Slides from my presentation at Unite 2012 in Amsterdam.

Citation preview

Page 1: Intro to unity for as3

Mark Rondina Unite 12

For

Introduction to Unity for AS3 Developers

Mark Rondina Unite 12 1Tuesday, April 30, 13

Page 2: Intro to unity for as3

Mark Rondina Unite 12 2

Introduction

http://markrondina.com

@mrondina

[email protected]

Tuesday, April 30, 13

Page 3: Intro to unity for as3

Mark Rondina Unite 12 3

Audience Poll

Tuesday, April 30, 13

Page 4: Intro to unity for as3

Mark Rondina Unite 12 4

Audience Poll

Tuesday, April 30, 13

Page 5: Intro to unity for as3

Mark Rondina Unite 12 5

Session Overview

• Window Layout

• Where’s my stuff?

Unity IDE Basics

Unity Objects

The GUI

• GameObjects, Prefabs

and Transforms

• Components

• Text

• GUI elements

• GUI skins

Scripting• Languages

• Adding Scripts

• Accessing Scripts

Tuesday, April 30, 13

Page 6: Intro to unity for as3

Mark Rondina Unite 12 6

Unity IDE Overview - Project Window

Project Window• Linked to the folder on your

computer where project is stored

• ~/Project Folder/Assets/

• Built-in Unity assets are loaded here

• Similar to Flash Professional Library

Tuesday, April 30, 13

Page 7: Intro to unity for as3

Mark Rondina Unite 12 7

Unity IDE Overview - Hierarchy Window

• List of all objects in the Unity scene

• Unity scenes ≈ Flash Pro scenes

• Can rename objects and elements

Hierachy Window

Tuesday, April 30, 13

Page 8: Intro to unity for as3

Mark Rondina Unite 12 8

Unity IDE Overview - Inspector Window

• List of all the properties of selected object

• Unity inspector += Flash Pro properties

panel

• Rename objects and elements

• Add/Delete and Enable/disable

components

• Edit/Modify object components

• Edit/Modify object properties

• Interact with script variables

• Assign materials and shaders

Inspector Window

Tuesday, April 30, 13

Page 9: Intro to unity for as3

Mark Rondina Unite 12 9

Unity IDE Overview - Animation Window

• List of all the properties of selected object

• Edit existing animations imported with

geometry

• Split animations apart for ease of

triggering and looping

• Create new animations

Inspector Window

Tuesday, April 30, 13

Page 10: Intro to unity for as3

Mark Rondina Unite 12 10

Unity Objects - Transform

• Component of GameObject

• Holds Position, Scale and Rotation of

the object

• Accessed using -

GameObject.transform

• 3D objects can be cast as Transforms

i.e. var myCube:Transform;

• Casting as Transform may provide

speed increase when working with Scale

Position and Rotation

• Access the GameObject parent -

myCube.gameObject

Transform

Tuesday, April 30, 13

Page 11: Intro to unity for as3

Mark Rondina Unite 12 11

Unity Objects - GameObject

• Base class for all elements in a scene

• Able to access any component on the

selected object - i.e.

GameObject.GetComponent();

• Must use to add or remove

components, such as colliders, scripts.

etc

• Similar to Flash - Sprite class

GameObject

Tuesday, April 30, 13

Page 12: Intro to unity for as3

Mark Rondina Unite 12 12

Unity Objects - Prefab

• Container of GameObjects

• Can be configured to hold multiple

objects with set components

• Editing of the base Prefab can provide

quick and easy updates to all linked to it

• Similar to Flash - MovieClip class

• Convenience of build once and use

anywhere

• Can be placed on scene or instances

created from code

• Combined with code can be powerful!

Prefab

Tuesday, April 30, 13

Page 13: Intro to unity for as3

Mark Rondina Unite 12 13

Working With the GUI

• Exist in OnGUI ≈ onEnterFrame

• Buttons

• Labels

• Text Input - normal/password

• TextField, TextArea

• Vertical/Horizontal Scrollbars

• Toggle

• Window

• ScrollView ≈ scrolling text component

Unity GUI Objects

Tuesday, April 30, 13

Page 14: Intro to unity for as3

Mark Rondina Unite 12 14

Working With the GUI

• Exist in OnGUI ≈ onEnterFrame

• Buttons

• Labels

• Text Input - normal/password

• TextField, TextArea

• Vertical/Horizontal Scrollbars

• Toggle

• Window

• ScrollView ≈ scrolling text component

Unity GUI Objects

DEMO THIS

Tuesday, April 30, 13

Page 15: Intro to unity for as3

Mark Rondina Unite 12 15

Positioning GUI Elements

GUIvs

GUILayout

• Positing your GUI elements yourself

• May have speed improvements

• For when you know what you’re

dealing with

• Unity’s Layout Manager positions your

GUI elements

• Layout is similar to HTML tables

• Rapidly getting elements on screen to

test

Tuesday, April 30, 13

Page 16: Intro to unity for as3

Mark Rondina Unite 12 16

Positioning GUI Elements

GUIvs

GUILayout

• Positing your GUI elements yourself

• May have speed improvements

• For when you know what you’re

dealing with

• Unity’s Layout Manager positions your

GUI elements

• Layout is similar to HTML tables

• Rapidly getting elements on screen to

test

DEMO THIS

Tuesday, April 30, 13

Page 17: Intro to unity for as3

Mark Rondina Unite 12 17

GUI Skinning - IDE

• Customize the built-in GUI components

• Make your own custom skins

• Can set global GUI fonts and add

additional fonts to use in scripts

• If not specified, Unity uses default skins

Skinning in the IDE

Tuesday, April 30, 13

Page 18: Intro to unity for as3

Mark Rondina Unite 12 18

GUI Skinning - Code

• Use “private” keyword for your GUISkin

variables

• Can be overridden by IDE GUI Skin

• States need to have same background

image or won’t show

Skinning in code

Tuesday, April 30, 13

Page 19: Intro to unity for as3

Mark Rondina Unite 12 19

GUI Skinning - IDE

• Very easy to use

• Global access for any GUI elements

• Override using scripts if needed

Skinning in the IDE

Tuesday, April 30, 13

Page 20: Intro to unity for as3

Mark Rondina Unite 12 20

GUI Skinning - IDE

• Very easy to use

• Global access for any GUI elements

• Override using scripts if needed

Skinning in the IDE

DEMO THIS

Tuesday, April 30, 13

Page 21: Intro to unity for as3

Mark Rondina Unite 12 21

Scripting Options

Boo Script• Based on Python

• Less Verbose

• Debugging in MonoDevelop

UnityScript• Based on Javascript

• Allows for strict typing

• Familiarity

• Pascal case (OnGUI)

• Run time and Compile time

error checking

C#• Established code language

• Lots of available libraries

• Ability to use Visual Studio

• Possible speed

improvements

Tuesday, April 30, 13

Page 22: Intro to unity for as3

Mark Rondina Unite 12 22

Script Popularity Survey

Tuesday, April 30, 13

Page 23: Intro to unity for as3

Mark Rondina Unite 12 23

Variable Scope

UnityScript• public by default

• Vars public && undeclared are

accessible via IDE

• static == global i.e. myScript.staticVar;

• private are kept within the script scope

• local variables - those within functions

exist during the function and then are

marked for GC

** in C# variables are private by default

Tuesday, April 30, 13

Page 24: Intro to unity for as3

Mark Rondina Unite 12 24

Adding Scripts

Scripts• Unity treats scripts as components

• IDE - drag and drop onto objects (similar

to Macromedia Director behaviours)

• Code - use

GameObject.AddComponent(ScriptName)

Tuesday, April 30, 13

Page 25: Intro to unity for as3

Mark Rondina Unite 12 25

Learning Resources

Online• Unity Answers - http://answers.unity3d.com

• Unity Forum - http://forum.unity3d.com/

• Unify Wiki - http://wiki.unity3d.com

• Unity Documentation - http://bit.ly/3wgqcp

• Unity Script Reference - http://bit.ly/NX42Db

• Reference Manual - http://docs.unity3d.com

• BIG LIST of TUTS! - http://bit.ly/oXSGNy

• Virtual Game Lab - http://bit.ly/QVohzg

Offline

http://bit.ly/Nh6bXy

Tuesday, April 30, 13

Page 26: Intro to unity for as3

Mark Rondina Unite 12 26

THANK YOU!!

http://markrondina.com

@mrondina

[email protected]

Tuesday, April 30, 13