SLIDE 1
Introduction to Unity and MiddleVR
David J. Zielinski DiVE Virtual Reality Lab Duke University
SLIDE 2 Overview
- Unity Overview
- Editor Interface
- Scripting
- MiddleVR
SLIDE 3 Unity - Why even use a game engine?
Simplify development of games.
○ physics, AI
○ shadows, lighting
○ input devices ○ output devices
SLIDE 4 Unity - What is it?
- Commercial game engine (Free and Pro)
- Cross platform
- Popular
SLIDE 5 Unity - Commercial Game Engine
Pro Version offers:
- LOD
- Occulsion culling
- Profiler
- Full screen post processing effects (Oculus)
- Quad Buffered Stereo (for zSpace and
DiVE)
SLIDE 6 Unity - Cross Platform
Multiple Build Targets (Input/Output Abstraction)
- Windows
- Linux
- iOS
- Android
- Web
- … and more!
SLIDE 7 Unity - Popular
- 2 million registered users
- Large asset store (models, scripts)
- Utilized in other Duke classes
SLIDE 8
Unity - Competitors
SLIDE 9 Unity - Understanding Projects
A Unity project...
- is actually the directory
- will contain all the assets for your game
- can contain multiple scenes
SLIDE 10
Unity Editor - Windows
Scene Hierarchy Inspector Project Console
SLIDE 11
Unity Editor - Scene Window
Orbit: alt+left mouse right mouse button Pan: middle mouse Zoom: scroll wheel alt+ right mouse
SLIDE 12 Unity Editor - Hierarchy
- Show objects in current scene
- Can drag objects underneath
another object.
- Selecting an object will change
the view in the inspector window (next slide)
- Tip: can use ‘f’ key to center on
- bject in scene view
SLIDE 13 Unity Editor - Inspector
- Shows currently selected game
- bject.
- Lists all components of that
game object.
- Scripts will show up here as
well.
SLIDE 14 Unity Editor - Project
- Lists all assets in your project
SLIDE 15
Unity Editor - Console
If there are errors in your script, they will show up here when you press play.
SLIDE 16 Unity Editor - Game Window
the scene window will switch to the game view window.
adjusted while in play mode will revert when play ends.
SLIDE 17
Example - Adding a Cube
GameObject Create Other Cube
SLIDE 18 Example - Moving a cube
scene view to move
inspector view
use mouse to quickly adjust
SLIDE 19
Example - add material to cube
Assets Create Material
SLIDE 20
Example - add material to cube part2
Drag material from project window onto Cube in Hierarchy window.
SLIDE 21 Example - Material added to cube
used
- We can change the color by
bringing up the color picker
SLIDE 22
Example - Color picker
SLIDE 23
Building
File Build & Run
SLIDE 24 Building - Platform Chooser
generate a standalone exe
is in build.
Build” window.
SLIDE 25 Scripting
- UnityScript (similiar to JavaScript)
- Boo (similiar to python)
- C#
SLIDE 26 Which language to use?
Answer: C#
- interoperability with libraries written in C#
○ MiddleVR is written in C#
○ JS Implicit variable declaration can cause problems
- advanced features available if needed
○ Properties, delegates, lambdas, generics
SLIDE 27
Comments
// for single line comments /* for multi line comments */
SLIDE 28 Variables
○ bool, char, byte, float, double, int, string, …
- Public vs Private keyword
- Pass by reference: use ref instead of &
Example: public int playerHealth=5;
SLIDE 29 Functions (called methods in C#)
- allows us to compartmentalize and reuse
code effeciently
public int SquareANumber(int number) { return number * number; }
SLIDE 30
If Statements
if (m > 10) { //do something } else { //do something }
SLIDE 31
Basic Functions
void Start() { //called once. do any initialization here } void Update() { //called every frame. move objects here }
SLIDE 32
For Loop
for (int i = 1; i <= 5; i++) { Debug.Log(“hello”); }
SLIDE 33
Example - Rotating Cube
void Update() { transform.Rotate(0,speed,0); }
SLIDE 34
Example - Rotate Cube Properly
void Update() { transform.Rotate(0,speed*Time.deltaTime,0); }
SLIDE 35 MiddleVR
- Commercial Plugin
- Support for 3D interaction devices
- Stereoscopy (active, passive)
- Multi-screens / multi-computers
○ (needed for CAVE-type systems)
SLIDE 36 MiddleVR Licensing
Free Version:
- export for oculus
- simulator for desktop development
Academic (licensed) Version:
- Build/Export to zSpace
- Build/Export to DiVE
- Can be node locked or floating license.
SLIDE 37
Add MiddleVR to Unity Project
Assets Import Package Custom Package
SLIDE 38
Find the MiddleVR Package
SLIDE 39
Adding to Scene
Need to drag “VRManager” from project to Hierarchy window
SLIDE 40 Pick Config File
- Select VRManager.
- Many options in
inspector window.
file.
SLIDE 41 Pick Config File - Part 2
(in progress) on some config files.
DiVE fileserver.
SLIDE 42
Now Click Play
We can see that VRRootNode is created dynmically.
SLIDE 43 Virtual Hand Technique
- MiddleVR has easy ways to
enable Virtual Hand technique.
- Add VRActor script to object
we want to pickup
SLIDE 44 Virtual Hand Demo
and click, the
underneath the handnode
SLIDE 45 Learn More
Unity
http://docs.unity3d.com/Documentation/Manual/index.html
Walker Boys Studio - Video tutorial
http://www.walkerboystudio.com/html/unity_training___free__.html
Lynda
http://www.lynda.com/Unity-3D-tutorials/Unity-3D-35-Essential-Training/96677-2.html
Middle VR
http://www.imin-vr.com/doc/current/
SLIDE 46
Thank You! Questions?