Web Games Programming Unity Scripting Fundamentals.

Slides:



Advertisements
Similar presentations
1What is the Stage. 2How do you open a panel in Flash
Advertisements

UFCFSU-30-13D Technologies for the Web Creating and Updating a Graphical Heads-Up Display (HUD)
The Web Warrior Guide to Web Design Technologies
UFCEKU-20-3Web Games Programming Shockwave 3D Environment and Lingo Scripting Basics.
1 Flash Actionscript Adding Interactive Actions Variables.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Functions Part I.
HELLO WORLD: YOUR FIRST PROGRAM CHAPTER Topics  Hello World?  Creating a Unity Project –The Unity Project Folder  MonoDevelop: Unity's Code Editor.
Code ‘n Play Interactive Games with Unity & JavaScript.
Unity 3D game IDE 1.  Unity is a multi-platform, integrated IDE for scripting games, and working with 3D virtual worlds  Including:  Game engine ▪
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
UFCEKU-20-3Web Games Programming Unity 3D Physics Colliders and Object Collisions.
Sage CRM Developers Course
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
XP Tutorial 5 Buttons, Behaviors, and Sounds. XP New Perspectives on Macromedia Flash MX Buttons Interactive means that the user has some level.
Exercise : Animated Navigation Structure in Flash 1.Develop Answers to “What did you learn in ITI program?” “What do you have to offer?” “What are your.
UFCEKU-20-3Web Games Programming Unity 3D Basic Concepts Using and Creating Prefabs.
EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 13 Wenbing Zhao
Using the Netbeans GUI Builder. The Netbeans IDE provides a utility called the GUI Builder that assists you with creating Windows applications. The Netbeans.
Tutorial 2 Variables and Objects. Working with Variables and Objects Variables (or identifiers) –Values stored in computer memory locations –Value can.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
SE 350 – Programming Games Lecture 7: Programming with Unity Lecturer: Gazihan Alankuş Please look at the last slide for assignments (marked with TODO)
Getting a handle on ActionScript A basic primer for non-programmers.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Web Games Programming An Introduction to Unity 3D.
UFCFS D Technologies for the Web Unity 3D: Review of Topics and Related Concepts.
USING UNITY JAVASCRIPT. CONVENTIONS AND SYNTAX IN JAVASCRIPT Case Sensitivity All keywords like var or function must be in lowercase. All variable names,
Learning Unity. Getting Unity
USING UNITY JAVASCRIPT. CONVENTIONS AND SYNTAX IN JAVASCRIPT Case Sensitivity All keywords like var or function must be in lowercase. All variable names,
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
SE 320 – Introduction to Game Development Lecture 3: Unity’s Interface and Concepts Lecturer: Gazihan Alankuş Please look at the last two slides for assignments.
SE 320 – Introduction to Game Development Lecture 7: Programming Lecturer: Gazihan Alankuş Please look at the last two slides for assignments (marked with.
JavaScript Syntax, how to use it in a HTML document
Exploring the Macromedia Flash Workspace – Lesson 2 1 Exploring the Macromedia Flash Workspace Lesson 2.
UFCEK-20-3Web Games Programming Unity 3D: Review of Topics Publishing for the Web.
Building the Events Components– Lesson 111 Building the Events Components Lesson 11.
JavaScript, Fourth Edition
Problem Solving Methodology Rachel Gauci. Problem Solving Methodology Development Design Analysis Evaluation Solution requirements and constraints. Scope.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
GameDevClub CODE CHEAT SHEET NOTE: ALL OF THE CODE IS CASE-SENSITIVE AND THE SYNTAX IS STRICT SO A LOT OF YOUR ERRORS WILL PROBABLY COME FROM TYPOS If.
Intro to ActionScript CIS 126 Greg Shorts. What Is ActionScript? ActionScript is the scripting language Flash uses to control its movies and the objects.
UFCEKU-20-3Web Games Programming Instantiating World Objects.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
UFCFSU-30-13D Technologies for the Web An Introduction to Unity 3D.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
Expressive Intelligence Studio // Center for Games and Playable Media // Unity Pro John Murray Expressive.
JavaScript Tutorial First lecture 19/2/2016. Javascript is a dynamic computer programming language. It is lightweight and most commonly used as a part.
Behavior trees & The C# programming language for Java programmers
UFCEKU-20-3Web Games Programming Creating and Updating a Graphical Heads-Up Display (HUD)
Digital Game Design ACST 3710 Your First Unity Program 1.
EEC-693/793 Applied Computer Vision with Depth Cameras
Quick Intro to Unity Lecture 2.
var variableName:datatype;
CHAPTER 4 DECISIONS & LOOPS
>> Introduction to JavaScript
Programming Web Pages with JavaScript
Unity 2D: Step by Step, Part 4
EEC-693/793 Applied Computer Vision with Depth Cameras
HTML & teh internets.
EEC-693/793 Applied Computer Vision with Depth Cameras
Chapter 19 JavaScript.
Simple Windows Applications
Tutorial 6 Creating Dynamic Pages
Introduction to Unity 2D Game Development
EEC-693/793 Applied Computer Vision with Depth Cameras
Exercise : Animated Navigation Structure in Animate (= Flash)
Web Programming and Design
Exercise : Animated Navigation Structure in Flash
Presentation transcript:

Web Games Programming Unity Scripting Fundamentals

Agenda Scripting Languages in Unity Creating Script Assets Default Script Structure Attaching Scripts to Objects in the 3D Environment Communicating with Environment Objects using ‘tag’ Using the Debug Utility Function Establishing Script to Script Communication

Supported Languages in Unity Javascript C# (sharp) Boo Unity documentation provides examples for each type. Javascript is most widely used examples but C# now becoming first choice in current Unity tutorials . Module using Javascript to align with the set text: Unity Game Development Essentials.

Creating Script Assets From the Assets Menu choose Create Choose the language you want from the menu list The default name newly created scripts is NewBehaviorScript Rename the script to give a name that conveys the scripts functionality.

Javascript Example #pragma strict function Start () { } function Update () {

C# Example using UnityEngine; using System.Collections; public class NewBehaviourScript : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () {

Initialization Example (.js) #pragma strict function Start () { var anIntegerVariable:int = 5; var afloatVariable:float = 5.0f } function Update () {

Attaching Scripts to Objects Create the new script Drag the script from the Assets Window onto the object you want the script to affect. Or select Add Component from the Inspector Window and navigate to the Scripts Panel. Script behaviours can be switched on or off via the Component Panel checkbox.

Changing an Object’s Properties via Scripts Cube Object ColourSwitcher.js // fragment function Update () { if(Input.GetKeyDown(KeyCode.R)){ gameObject.renderer.material.color = Color.red; }

Referencing Objects Using ‘Tags’ Tags – tags are simply keywords that can be assigned to an object in the environment. Tagged objects can then be referenced inside scripts. Tags are similar to instance names in ActionScript. Adding tags to objects is a two-step process. First add your chosen tag name to a list in the Tag Manager. Then apply it to your chosen object. You can then make references to the tag name in your scripts.

Adding a Tags to Environment Objects e.g. Environment object Sphere with tag ‘aSphere’ // code fragment if(hit.collider.gameObject.tag == “aSphere”){ Debug.Log(‘I collided with the sphere’); }

Debug Utility Function Very useful debug and environment events utility function Debug.Log (“Message you to want to send to the Console Window”); Debug.Log("I have received " + numberOfMessages + ” messages from the transmit script");

Inter-Script Communication Sphere Cube Transmit Receive Transmit.js Code to send message to Receive.js attached to cube object Receive.js Code to handle message sent by Transmit.js attached to sphere object

Transmit.js Attached to Sphere Object #pragma strict // example of script - to - script communication // this script transmits messages to the script attached to the cube function Start () { } function Update () { if(Random.value > 0.5f){ Receive.messageReceived = true; else Receive.messageReceived = false;

Receive.js Attached to Cube Object #pragma strict /// this script receive messages from the transmit script attached to the sphere static var messageReceived:boolean;// important! static variable var numberOfMessages:int; function Start () { messagesReceived = false; numberOfMessages = 0; } function Update () { if (messageReceived == true){ numberOfMessages++; Debug.Log("I have received " + numberOfMessages + " messages from the transmit script"); else { Debug.Log("No messages received");

Static Variables Declaring variables as static make them available to be referenced by other scripts in the 3D environment. In programming parlance static variables have global scope // static variable declaration in Receive.js static var messageReceived:boolean;

Static Variable Referenced in Transmit.js if(Random.value > 0.5f){ Receive.messageReceived = true; } else { Receive.messageReceived = false;

Unity 3D Scripting Resources http://docs.unity3d.com/Documentation/ScriptReference/ http://answers.unity3d.com/index.html http://www.lynda.com