
Variables and Functions
Tutorial
Beginner
+10XP
10 mins
8410
Unity Technologies

What are Variables and Functions, and how do they store and process information for us?
This tutorial is included in the Beginner Scripting project.
Previous: Scripts as Behavior Components
Next: Conventions and Syntax
1. Variables and Functions
using UnityEngine;
using System.Collections;
public class VariablesAndFunctions : MonoBehaviour
{
int myInt = 5;
void Start ()
{
myInt = MultiplyByTwo(myInt);
Debug.Log (myInt);
}
int MultiplyByTwo (int number)
{
int result;
result = number * 2;
return result;
}
}