---
title: "Extension Methods "
content_type: tutorial
url: "https://learn.unity.com/tutorial/extension-methods?language=en"
language: en
difficulty: intermediate
duration_minutes: 5
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/extension-methods.md?language=en&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/tutorial/extension-methods.md?language=en&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/tutorial/extension-methods.md?language=en&version=2019.1"
  - name: "2018.4"
    url: "https://learn.unity.com/tutorial/extension-methods.md?language=en&version=2018.4"
  - name: "2018.3"
    url: "https://learn.unity.com/tutorial/extension-methods.md?language=en&version=2018.3"
  - name: "2018.2"
    url: "https://learn.unity.com/tutorial/extension-methods.md?language=en&version=2018.2"
  - name: "2018.1"
    url: "https://learn.unity.com/tutorial/extension-methods.md?language=en&version=2018.1"
  - name: "2017.4"
    url: "https://learn.unity.com/tutorial/extension-methods.md?language=en&version=2017.4"
  - name: "2017.3"
    url: "https://learn.unity.com/tutorial/extension-methods.md?language=en&version=2017.3"
  - name: "2017.2"
    url: "https://learn.unity.com/tutorial/extension-methods.md?language=en&version=2017.2"
  - name: "2017.1"
    url: "https://learn.unity.com/tutorial/extension-methods.md?language=en&version=2017.1"
  - name: "5.x"
    url: "https://learn.unity.com/tutorial/extension-methods.md?language=en&version=5.x"
  - name: "4.x"
    url: "https://learn.unity.com/tutorial/extension-methods.md?language=en&version=4.x"
last_updated: "2026-08-04T14:23:58.000Z"
---

# Extension Methods 

Learn how to define, implement, and call C# extension methods to extend existing types.

 How to create, implement, and call an extension method.

## Extension Methods

[Video](https://connect-mediagw.unity.com/h1/20220112/videos/10993a62-2d5e-4fe7-9f5c-9307e0b2660c_U_Scripting_Intermediate_R1_11.mp4) ([Transcript (en)](https://connect-mediagw.unity.com/h1/20220112/244169f3-9673-4592-9be8-43f500cd4222_I_11_Extension_Methods__v2.0.vtt))

**ExtensionMethods**

```csharp
using UnityEngine;
using System.Collections;

//It is common to create a class to contain all of your
//extension methods. This class must be static.
public static class ExtensionMethods
{
    //Even though they are used like normal methods, extension
    //methods must be declared static. Notice that the first
    //parameter has the 'this' keyword followed by a Transform
    //variable. This variable denotes which class the extension
    //method becomes a part of.
    public static void ResetTransformation(this Transform trans)
    {
        trans.position = Vector3.zero;
        trans.localRotation = Quaternion.identity;
        trans.localScale = new Vector3(1, 1, 1);
    }
}
```

**SomeClass**

```csharp
using UnityEngine;
using System.Collections;

public class SomeClass : MonoBehaviour 
{
    void Start () {
        //Notice how you pass no parameter into this
        //extension method even though you had one in the
        //method declaration. The transform object that
        //this method is called from automatically gets
        //passed in as the first parameter.
        transform.ResetTransformation();
    }
}
```
