unity-clinic2-unityscript-basics

289
-1

Published on

Slides from the 2nd Unity clinic at UOW.

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
289
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
24
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

unity-clinic2-unityscript-basics

  1. 1. UnityScript The Basics WOODIWISS.ME Freelance Web Developer & Lecturer in the Winchester, Hampshire area.
  2. 2. ECMA What/Who is ECMA? • European Computer Manufacturers Association. • Non-profit Standards Organisation. • Introducing ECMAScript! WOODIWISS.ME
  3. 3. ECMAScript Language ECMAScript.es Dialects JavaScript.js WOODIWISS.ME ActionScript.as
  4. 4. ECMAScript ToolKit Dialects JavaScript.js WOODIWISS.ME
  5. 5. ECMAScript ToolKit Dialects JavaScript.js WOODIWISS.ME
  6. 6. ECMAScript JavaScript.js UnityScript.js WOODIWISS.ME
  7. 7. Onward! • NewBehaviourScript.js • Basic starting point. • #pragma strict? • Start • Update WOODIWISS.ME
  8. 8. WOODIWISS.ME
  9. 9. WOODIWISS.ME
  10. 10. WOODIWISS.ME
  11. 11. NewBehaviourScript.js WOODIWISS.ME
  12. 12. NewBehaviourScript.js WOODIWISS.ME
  13. 13. NewBehaviourScript.js WOODIWISS.ME
  14. 14. Start() • gameObject = Cube • Start = run before first frame. • e.g set color, set size, set position… WOODIWISS.ME
  15. 15. Start() • gameObject = Cube • Start = run before first frame. • e.g set color, set size, set position… WOODIWISS.ME
  16. 16. Start() • gameObject = Cube • Start = run before first frame. • e.g set color, set size, set position… WOODIWISS.ME
  17. 17. Update • gameObject = Cube still. • Continually polling the code. Each frame. WOODIWISS.ME
  18. 18. Mono Madness • All scripts extend MonoBehaviour. • Awake() • OnCollisionEnter() • FixedUpdate() • LOTS more base functions. WOODIWISS.ME
  19. 19. User Created Functions Keeps your code DRY ! D - on’t R - epeat Y - ourself WOODIWISS.ME
  20. 20. User Created Functions Keeps your code DRY ! D - on’t R - epeat Y - ourself WOODIWISS.ME
  21. 21. User Created Functions Keeps your code DRY ! D - on’t R - epeat Y - ourself WOODIWISS.ME Defined
  22. 22. User Created Functions Keeps your code DRY ! D - on’t R - epeat Y - ourself WOODIWISS.ME Defined
  23. 23. User Created Functions Invoked Keeps your code DRY ! D - on’t R - epeat Y - ourself WOODIWISS.ME Defined
  24. 24. In more detail WOODIWISS.ME
  25. 25. In more detail WOODIWISS.ME
  26. 26. Define In more detail WOODIWISS.ME
  27. 27. Define In more detail WOODIWISS.ME
  28. 28. Call / Invoke Define In more detail WOODIWISS.ME
  29. 29. Variables What is a variable? ! var playerHealth : int = 100; ! var playerHealth : int; playerHealth = 100; WOODIWISS.ME
  30. 30. Basic Data Types int - Number without decimal place. float - Number with decimal place. boolean - Truth value. String - Text or words, numbers, some symbols. Vector3 - X Y Z co-ordinates. GameObject - Object that is present in the Unity Scene. WOODIWISS.ME
  31. 31. Basic Data Types int = 17; float = 5.994; boolean = true; String = “Darren”; Vector3(100,124,55); // x, y, z GameObject = GameObject.Find("Zombie"); WOODIWISS.ME
  32. 32. Casting var fingersOnHand : int; var playerHeight : float; var powerupActive : boolean; var playerName : String; var playerStartLocation : Vector3; var enemy : GameObject; WOODIWISS.ME
  33. 33. Casting and Assigning var playerAge : int = 17; var playerHeight : float = 5.994; var powerupActive : boolean = true; var playerName : String = “Darren”; var playerStartLocation = Vector3(0,0,0); var enemy : GameObject; enemy = GameObject.Find("Zombie"); WOODIWISS.ME
  34. 34. Arguments • First define required parameters. • Specify arguments parsed to function. WOODIWISS.ME
  35. 35. Arguments • First define required parameters. • Specify arguments parsed to function. WOODIWISS.ME
  36. 36. Arguments • First define required parameters. • Specify arguments parsed to function. WOODIWISS.ME
  37. 37. More arguments It’s like bloody Eastenders in here. WOODIWISS.ME
  38. 38. More arguments It’s like bloody Eastenders in here. WOODIWISS.ME
  39. 39. More arguments It’s like bloody Eastenders in here. WOODIWISS.ME
  40. 40. More arguments It’s like bloody Eastenders in here. WOODIWISS.ME
  41. 41. Cube More arguments It’s like bloody Eastenders in here. WOODIWISS.ME
  42. 42. Cube More arguments It’s like bloody Eastenders in here. WOODIWISS.ME
  43. 43. Cube 1 More arguments It’s like bloody Eastenders in here. WOODIWISS.ME
  44. 44. Cube 1 More arguments It’s like bloody Eastenders in here. WOODIWISS.ME
  45. 45. Cube 1 More arguments It’s like bloody Eastenders in here. WOODIWISS.ME
  46. 46. Cube 1 cube More arguments It’s like bloody Eastenders in here. WOODIWISS.ME
  47. 47. Cube 1 cube cube More arguments It’s like bloody Eastenders in here. WOODIWISS.ME
  48. 48. Links / Research • http://en.wikipedia.org/wiki/Ecma_International • http://en.wikipedia.org/wiki/ECMAScript • http://www.mono-project.com/What_is_Mono • docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.html • http://unity3d.com/learn/tutorials/modules/beginner/scripting • https://www.inkling.com/read/javascript-definitive-guide-david-flanagan-6th/chapter-8/function-arguments-and • http://www.sublimetext.com/ WOODIWISS.ME
  49. 49. Next Time Scope / Operators / Statements … WOODIWISS.ME Freelance Web Developer & Lecturer in the Winchester, Hampshire area.
  50. 50. Questions? WOODIWISS.ME Freelance Web Developer & Lecturer in the Winchester, Hampshire area.

×