Introducing Dragonfly Cloud! Learn More

Question: What Language Does Unity Use?

Answer

Unity primarily uses C# for scripting. C# is a versatile, modern programming language developed by Microsoft as part of its .NET framework. It was chosen for Unity due to its easy-to-understand syntax and powerful features, making it suitable for both beginners and experienced programmers.

Here's an example of a simple C# script in Unity that moves a GameObject when an arrow key is pressed:

using UnityEngine; public class MovementScript : MonoBehaviour { public float speed = 5.0f; // Speed of the GameObject void Update() { if (Input.GetKey(KeyCode.RightArrow)) { transform.position += Time.deltaTime * speed * Vector3.right; } if (Input.GetKey(KeyCode.LeftArrow)) { transform.position += Time.deltaTime * speed * Vector3.left; } } }

In this script, Update is a method called once per frame by the Unity engine. The Input.GetKey method checks for key presses, and transform.position modifies the position of the GameObject to which this script is attached.

While C# is the primary language used in Unity, Unity also supports JavaScript (also known as UnityScript) and Boo, but these languages are deprecated and no longer recommended for use.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Start building today 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.