1. Ivanov Michael
Lead Programmer R&D,Neurotech Solutions LTD
Writer for Packt Publishing.,”Away3D Cookbook”
Expert in Flex/AIR, Open Source Flash 3d engines.
Spare time:Unity,UnrealEngine,OpenGL,Java3D
Visit my tech blog:http://blog.alladvanced.net
2. How many of you have never heard of Unity?
How many of you are designers ?
How many of you come from Flash/ActionScript background?
How many of you programmed in Unity? What language?
How many of you accomplished commercial projects with
Unity ?
3. Unity engine API model
Unity programming paradigm
Scripting Languages
Scripting practices
Unity GameObject structure
Examples walkthrough
4. How to program(You should learn by yourselves)
Level design(designers –sorry)
Advanced programming
Shaders
Much more cool and important stuff because of time limitation.
P.S
For the rest of disclaimer please refer to:GNU General Public License
Stay tuned for Unity3D workshop announcement
5.
6. Audio Engine
Particle System Engine
Terrain Engine
Physics Engine
GUI System
Animation Engine
Network API
Shaders programmingAPI
Unity Engine Core
C#
JavaScript
Boo(Python)
ShaderLab,Cg,GLSL
Sealed
7. WindZone
LightCamera
Rigid Body Collider
Mesh Filter
Particle
Emitter
Audio
Source
Custom GameObject
Camera
FPSControl
ler
AudioListe
ner
GameObject
Shader Prefab Material
Script File AnimationAssets
Customized
Game Object
Components
(Resource Library)
8. UnityScript(JavaScript) MONO(C#)
Pros •20X faster than web JS
•Flexible coding(no need in data types
declaration, no class body explicit typing
required)
•Beginners friendly
•Well documented in Unity docs
•C family(fast adaptation for experienced devs)
•Strong typing
•Robust .NET Framework(Event Model,threads,structs and
more C# specific)
•External IDE software availability
•Piles of docs in theWeb
•Portability to other platforms
•DLL libs support
Cons •No explicit variable types declaration required
•iPhone builds are bigger than C#(additional libs
added)
•language specific restrictions: No multi-
dimensional arrays definition, no pass values by
reference into functions(needs workaround),no
Char data type , no multiple interface
implementation only one class or interface are
allowed to be extended
•Poor Even Model(custom approach is slow)
•Partial implementation of .NET(no virtual classes allowed,
no namespaces, limited multi-threading,Timer..
•Less documented in Unity docs
9. class MyClass extends MonoBehaviour {
var myVar = 1;
function Start() {
Debug.Log("hello world!");
}
}
class MyClass : MonoBehaviour {
public int myVar = 1;
void Start() {
Debug.Log("hello world!");
}
}
Java Script C#
10. Surprisingly you can write with both of them in one
project!(one way communication only)
Script
Script
Script
Script
Standard Assets
((Compiled first
My Scripts Folder(Outside)
(Compiled last)
C#JavaScript
Script
Script
Script
Script
12. using UnityEngine;
using System.Collections;
public class MyNewBehaviour : MonoBehaviour {
public static AudioClip playingClip;//////---accessible from outside to all
void Start () {
}
void Update () {///////// see also FixedUpdate
}
void OnMouseDown(){
}
void OnCollisionEnter(){
}
public void SpawnEnemy(){////////-------------------your custom method
}
}
19. Time.time
Time.deltaTime
C# System.Timers.Timer
Update() and FixedUpdate()
FixedUpdate synchronized with Physics Engine steps while Update() runs on each
frame
Always use FixedUpdate() for physics!
F F F F F
0.1 seconds0.0 seconds
U U U U U U U U U U
20. Time.time
Time.deltaTime
C# System.Timers.Timer
Update() and FixedUpdate()
FixedUpdate synchronized with Physics Engine steps while Update() runs on each
frame
Always use FixedUpdate() for physics!
F F F F F
0.1 seconds0.0 seconds
U U U U U U U U U U
23. What are these matrices and vectors anyways?
Core Classes:
Mathf .(Also C# System.Math )
Matrix4x4
Vector2/3/4
Quaternion –all Rotations are Quaternion based
27. Self attachment
_audioSource=gameObject.AddComponent<AudioSource>();
Indirect attachment
GameObject tile = (GameObject)Instantiate (tilePF,Vector3.zero, Quaternion.identity);
AudioSource audioSource=tile.AddComponent<AudioSource>();
//adding audio source component to the tile and accessing it at the same time//
28. Yield
Ensures that the function will continue from the line after the yield statement next
time it is called
Can’t be used inside “Time” methods like Update(),FixedUpdate()
Coroutine
Suspends its execution until givenYield instruction finishes.
Requires a method to be IEnumerator
34. Unity built-in event system
SendMessage()-Calls the method on every MonoBehaviour in this game object.
BroadcastMessage()- Calls the method on every MonoBehaviour in this game
object or any of its children.
Downside:
Need to target methods by their name (Errors prone)
Work only within the object's transform hierarchy
Controller Class registers all the classes to be notified of changes via reference
Downside :
Flexibility & Scalability
Nightmare for big projects
35. Dispatcher class
public class EventSender : MonoBehaviour {
public delegate void GameObjectPressHandler(GameObject e);
public event GameObjectPressHandler OnGameObjectPress;
private void DispatchPressEvent () {
if (OnGameObjectPress != null){
OnGameObjectPress (this.gameObject);//event has been fired!
}
}
}
public GameObject gm;
EventSender myEventSender=gm.getComponent<EventSender>();
myEventSender.OnGameObjectPress+=new GameObjectPressHandler(onGMPress);
Private void onGMPress(GameObjject gm){
print(gm+”was has been!”);
}
Listener Class