ReSharper 2024.2 Help

Predefined Live Templates for Unity

This topic lists all predefined live templates for Unity in ReSharper 2024.2. For more information about live templates, refer to Create source code using live templates.

Template

Details

ctx

Current file context

Scope Everywhere

Body

$CTX$

Parameters

  • CTX - Provides a list of items describing current context. This includes file name, containing type name, namespace name, etc.

nguid

Insert new GUID

Scope Everywhere

Body

$GUID$

Parameters

  • GUID - Generates a new Globally Unique Identifier (GUID)

assetmenu

Unity CreateAssetMenu attribute

Scope C# 2.0+ types and namespaces, Unity C# file

Body

[UnityEngine.CreateAssetMenu(fileName = $FILENAME$, menuName = $MENUNAME$, order = $ORDER$)]

Parameters

  • FILENAME - Shows basic code completion list at the point where the variable is evaluated

  • MENUNAME - Shows basic code completion list at the point where the variable is evaluated

  • ORDER - Shows basic code completion list at the point where the variable is evaluated

logwarn

Unity log warning

Scope C# 2.0+ statements, Unity C# file

Body

UnityEngine.Debug.LogWarning($VAR$);

Parameters

  • VAR - Shows basic code completion list at the point where the variable is evaluated

logex

Unity log exception

Scope C# 2.0+ statements, Unity C# file

Body

UnityEngine.Debug.LogException($VAR$);

Parameters

  • VAR - Shows basic code completion list at the point where the variable is evaluated

menuitem

Unity menu item handler

Scope C# 2.0+ type members, Unity C# file

Body

[UnityEditor.MenuItem($MENUNAME$)] public static void $NAME$() { $END$ }

Parameters

  • MENUNAME - Shows basic code completion list at the point where the variable is evaluated

  • NAME - Shows basic code completion list at the point where the variable is evaluated

  • END - The caret position after the template is applied.

sfield

Unity serialized field

Scope C# 2.0+ type members, Unity serializable type members

Body

[UnityEngine.SerializeField] private $TYPE$ $NAME$;$END$

Parameters

  • TYPE - no macro

  • NAME - When executed in a variable declaration (where variable name should stand), suggests a name for the variable

  • END - The caret position after the template is applied.

logerr

Unity log error

Scope C# 2.0+ statements, Unity C# file

Body

UnityEngine.Debug.LogError($VAR$);

Parameters

  • VAR - Shows basic code completion list at the point where the variable is evaluated

log

Unity log object/message

Scope C# 2.0+ statements, Unity C# file

Body

UnityEngine.Debug.Log($VAR$);

Parameters

  • VAR - Shows basic code completion list at the point where the variable is evaluated

reqcomp

Unity RequireComponent attribute

Scope C# 2.0+ types and namespaces, Unity C# file

Body

[UnityEngine.RequireComponent(typeof($TYPE$))]

Parameters

  • TYPE - Shows basic code completion list at the point where the variable is evaluated

sprop

Unity property with serialized backing field

Scope C# 2.0+ type members, Unity serializable type members

Body

[UnityEngine.SerializeField] private $type$ $fieldName$; public $type$ $propertyName$ { get { return this.$fieldName$; } }$END$

Parameters

  • type - no macro

  • propertyName - When executed in a variable declaration (where variable name should stand), suggests a name for the variable

  • fieldName - Decapitalizes string value (i.e. changes the case of the first letter to lowercase)

  • END - The caret position after the template is applied.

cor

Unity coroutine method

Scope C# 2.0+ type members, Unity C# file

Body

private System.Collections.IEnumerator $NAME$() { $END$yield break; }

Parameters

  • NAME - no macro

  • END - The caret position after the template is applied.

logvar

Unity log variable

Scope C# 2.0+ statements, Unity C# file

Body

UnityEngine.Debug.Log("$VAR$ = " + $VAR$);

Parameters

  • VAR - Shows basic code completion list at the point where the variable is evaluated

int

ShaderLab Integer property

Scope Unity ShaderLab Properties Block

Body

_$NAME$("$NAME$", Integer) = $VALUE$$END$

Parameters

  • NAME - no macro

  • VALUE - Evaluates to the specified constant value

  • END - The caret position after the template is applied.

blendmultiplicative2x

ShaderLab Blend 2x multiplicative (srcdst+dstsrc)

Scope Unity ShaderLab Category Block, Unity ShaderLab SubShader Block, Unity ShaderLab Pass Block

Body

Blend DstColor SrcColor

    float

    ShaderLab Float property

    Scope Unity ShaderLab Properties Block

    Body

    _$NAME$("$NAME$", Float) = $VALUE$$END$

    Parameters

    • NAME - no macro

    • VALUE - Evaluates to the specified constant value

    • END - The caret position after the template is applied.

    surf

    ShaderLab Surface Shader

    Scope Unity ShaderLab Shader Block

    Body

    SubShader { Tags { "RenderType" = "Opaque" } CGPROGRAM #pragma surface surf Lambert struct Input { float4 color : COLOR; }; void surf(Input IN, inout SurfaceOutput o) { o.Albedo = 1; } ENDCG }

      shader

      ShaderLab Shader block

      Scope Unity ShaderLab Root

      Body

      Shader "$NAME$" { $END$ }

      Parameters

      • NAME - no macro

      • END - The caret position after the template is applied.

      tex3d

      ShaderLab 3D property

      Scope Unity ShaderLab Properties Block

      Body

      _$NAME$("$NAME$", 3D) = "$TEXTURE$" { $END$ }

      Parameters

      • NAME - no macro

      • TEXTURE - Evaluates to the specified constant value

      • END - The caret position after the template is applied.

      vec

      ShaderLab Vector property

      Scope Unity ShaderLab Properties Block

      Body

      _$NAME$("$NAME$", Vector) = ($X$, $Y$, $Z$, $W$)$END$

      Parameters

      • NAME - no macro

      • X - Evaluates to the specified constant value

      • Y - Evaluates to the specified constant value

      • Z - Evaluates to the specified constant value

      • W - Evaluates to the specified constant value

      • END - The caret position after the template is applied.

      blendadditivesoft

      ShaderLab Blend soft additive (src*(1-dst)+dst)

      Scope Unity ShaderLab Category Block, Unity ShaderLab SubShader Block, Unity ShaderLab Pass Block

      Body

      Blend OneMinusDstColor One

        blendadditive

        ShaderLab Blend additive (src + dst)

        Scope Unity ShaderLab Category Block, Unity ShaderLab SubShader Block, Unity ShaderLab Pass Block

        Body

        Blend One One

          vfshader

          ShaderLab Vertex/Fragment Shader

          Scope Unity ShaderLab Shader Block

          Body

          SubShader { Tags { "RenderType"="Opaque" } Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; }; struct v2f { float4 vertex : SV_POSITION; }; v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); return o; } half4 frag (v2f i) : SV_Target { return 1; } ENDCG } }

            tex2d

            ShaderLab 2D property

            Scope Unity ShaderLab Properties Block

            Body

            _$NAME$("$NAME$", 2D) = "$TEXTURE$" { $END$ }

            Parameters

            • NAME - no macro

            • TEXTURE - Evaluates to the specified constant value

            • END - The caret position after the template is applied.

            blendtransparent

            ShaderLab Blend traditional transparency (src*srcAlpha+(1-srcAlpha)*dst)

            Scope Unity ShaderLab Category Block, Unity ShaderLab SubShader Block, Unity ShaderLab Pass Block

            Body

            Blend SrcAlpha OneMinusSrcAlpha

              cubearr

              ShaderLab CubeArray property

              Scope Unity ShaderLab Properties Block

              Body

              _$NAME$("$NAME$", CubeArray) = "$TEXTURE$" { $END$ }

              Parameters

              • NAME - no macro

              • TEXTURE - Evaluates to the specified constant value

              • END - The caret position after the template is applied.

              blendmultiplicative

              ShaderLab Blend multiplicative (src*dst)

              Scope Unity ShaderLab Category Block, Unity ShaderLab SubShader Block, Unity ShaderLab Pass Block

              Body

              Blend DstColor Zero

                cube

                ShaderLab Cube property

                Scope Unity ShaderLab Properties Block

                Body

                _$NAME$("$NAME$", Cube) = "$TEXTURE$" { $END$ }

                Parameters

                • NAME - no macro

                • TEXTURE - Evaluates to the specified constant value

                • END - The caret position after the template is applied.

                tex2darr

                ShaderLab 2DArray property

                Scope Unity ShaderLab Properties Block

                Body

                _$NAME$("$NAME$", 2DArray) = "$TEXTURE$" { $END$ }

                Parameters

                • NAME - no macro

                • TEXTURE - Evaluates to the specified constant value

                • END - The caret position after the template is applied.

                color

                ShaderLab Color property

                Scope Unity ShaderLab Properties Block

                Body

                _$NAME$("$NAME$", Color) = ($R$, $G$, $B$, $A$)$END$

                Parameters

                • NAME - no macro

                • R - Evaluates to the specified constant value

                • G - Evaluates to the specified constant value

                • B - Evaluates to the specified constant value

                • A - Evaluates to the specified constant value

                • END - The caret position after the template is applied.

                blendtransparentpremul

                ShaderLab Blend premultiplied transparency (src+(1-srcAlpha)*dst)

                Scope Unity ShaderLab Category Block, Unity ShaderLab SubShader Block, Unity ShaderLab Pass Block

                Body

                Blend One OneMinusSrcAlpha

                  vfpass

                  ShaderLab Vertex/Fragment Shader Pass

                  Scope Unity ShaderLab SubShader Block

                  Body

                  Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; }; struct v2f { float4 vertex : SV_POSITION; }; v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); return o; } half4 frag (v2f i) : SV_Target { return 1; } ENDCG }

                    Last modified: 22 April 2024