---
title: "Variables y funciones"
content_type: tutorial
url: "https://learn.unity.com/tutorial/variables-and-functions-1?language=es"
language: es
difficulty: beginner
duration_minutes: 10
unity_version:
  - "2019.3"
  - "2019.2"
  - "2019.1"
  - "2018.4"
  - "2018.3"
  - "2018.2"
  - "2018.1"
  - "2017.4"
  - "2017.3"
  - "2017.2"
  - "2017.1"
  - "5.x"
  - "4.x"
supported_unity_versions:
  - name: "2019.3"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es&version=2019.1"
  - name: "2018.4"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es&version=2018.4"
  - name: "2018.3"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es&version=2018.3"
  - name: "2018.2"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es&version=2018.2"
  - name: "2018.1"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es&version=2018.1"
  - name: "2017.4"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es&version=2017.4"
  - name: "2017.3"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es&version=2017.3"
  - name: "2017.2"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es&version=2017.2"
  - name: "2017.1"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es&version=2017.1"
  - name: "5.x"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es&version=5.x"
  - name: "4.x"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es&version=4.x"
available_languages:
  - name: "en"
    url: "https://learn.unity.com/tutorial/variables-and-functions.md?language=en"
  - name: "es"
    url: "https://learn.unity.com/tutorial/variables-and-functions-1.md?language=es"
  - name: "ja"
    url: "https://learn.unity.com/tutorial/bian-shu-toguan-shu-nitsuite.md?language=ja"
  - name: "ko"
    url: "https://learn.unity.com/tutorial/byeonsu-mic-hamsu.md?language=ko"
  - name: "zh-cn"
    url: "https://learn.unity.com/tutorial/bian-liang-he-han-shu.md?language=zh-cn"
last_updated: "2026-08-04T14:21:20.000Z"
---

# Variables y funciones

Aprende qué son las variables y funciones en C# y cómo almacenan y procesan datos dentro de tus scripts de Unity.

¿Qué son las Variables y las Funciones y cómo guardan y procesan información por nosotros?

Este tutorial está incluido en el proyecto [_Scripting_ para principiantes. ](https://learn.unity.com/project/scripting-para-principiantes?language=es&publish=true)

Previo: [Scripts como componentes de comportamiento](https://learn.unity.com/tutorial/scripts-como-componentes-de-comportamiento?language=es&publish=true#)

Siguiente: Convenciones y sintaxis

## 1. Variables y funciones

[Video](http://www.youtube.com/watch?v=-c1RsydH2nA)

```csharp
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 ret;
        ret = number * 2;
        return ret;
    }
}
```
