Variables and Functions

Tutorial

Beginner

+10XP

10m

(8473)

Unity Technologies

Variables and Functions

What are Variables and Functions, and how do they store and process information for us?

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;
    }
}

Complete this Tutorial