JetBrains Rider 2023.2 Help

Predefined File Templates for Unity

This topic lists all predefined file templates for Unity in JetBrains Rider 2023.2. For more information about file templates, refer to Create files from templates.

Template

Details

IComponentData

Scope Unity DOTS projects

Body

$HEADER$namespace $NAMESPACE$ { public struct $COMPONENT$ : Unity.Entities.IComponentData { $END$ } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • COMPONENT - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

Assembly Definition File

Assembly Definition File

Scope Unity projects, Unity 2017.3 and later projects

Body

{ "name": "$NAME$" }

Parameters

  • NAME - Evaluates current file name without whitespace characters

Play Mode Test

Play Mode Test

Scope Unity projects

Body

$HEADER$namespace $NAMESPACE$ { public class $CLASS$ { [NUnit.Framework.Test] public void $CLASS$SimplePasses() { // Use the Assert class to test conditions. $END$ } // A UnityTest behaves like a coroutine in PlayMode // and allows you to yield null to skip a frame in EditMode [UnityEngine.TestTools.UnityTest] public System.Collections.IEnumerator $CLASS$WithEnumeratorPasses() { // Use the Assert class to test conditions. // yield to skip a frame yield return null; } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

IJobEntity

Scope Unity DOTS projects

Body

$HEADER$namespace $NAMESPACE$ { public partial struct $JOBENTITY$ : Unity.Entities.IJobEntity { public void Execute($END$) { } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • JOBENTITY - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

Image Effect Shader

Image Effect Shader

Scope Unity projects

Body

Shader "Hidden/$NAME$" { $END$Properties { _MainTex ("Texture", 2D) = "white" {} } SubShader { // No culling or depth Cull Off ZWrite Off ZTest Always Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = v.uv; return o; } sampler2D _MainTex; fixed4 frag (v2f i) : SV_Target { fixed4 col = tex2D(_MainTex, i.uv); // just invert the colors col = 1 - col; return col; } ENDCG } } }

Parameters

  • NAME - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

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

Asset Postprocessor

Asset Postprocessor

Scope Unity Editor folder

Body

$HEADER$namespace $NAMESPACE$ { public class $CLASS$ : UnityEditor.AssetPostprocessor { public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { $END$ } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

Scriptable Object

Scriptable Object

Scope Unity projects

Body

$HEADER$namespace $NAMESPACE$ { [UnityEngine.CreateAssetMenu(fileName = "$FILENAME$", menuName = "$MENUNAME$", order = 0)] public class $CLASS$ : UnityEngine.ScriptableObject { $END$ } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

  • 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

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

Mono Behaviour

Mono Behaviour

Scope Unity projects

Body

$HEADER$namespace $NAMESPACE$ { public class $CLASS$ : UnityEngine.MonoBehaviour {$END$} }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

Editor Window

Editor Window

Scope Unity Editor folder, Unity 2022.2 and later projects

Body

$HEADER$namespace $NAMESPACE$ { public class $CLASS$ : UnityEditor.EditorWindow { [UnityEditor.MenuItem("$MENUITEM$/$MENUITEMCOMMAND$")] private static void ShowWindow() { var window = GetWindow<$CLASS$>(); window.titleContent = new UnityEngine.GUIContent("$TITLE$"); window.Show(); } private void CreateGUI() { $END$ } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

  • MENUITEM - no macro

  • MENUITEMCOMMAND - no macro

  • TITLE - no macro

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

State Machine Behaviour

State Machine Behaviour

Scope Unity projects

Body

$HEADER$namespace $NAMESPACE$ { public class $CLASS$ : UnityEngine.StateMachineBehaviour { public override void OnStateEnter(UnityEngine.Animator animator, UnityEngine.AnimatorStateInfo stateInfo, int layerIndex) { $END$ } public override void OnStateExit(UnityEngine.Animator animator, UnityEngine.AnimatorStateInfo stateInfo, int layerIndex) { } public override void OnStateUpdate(UnityEngine.Animator animator, UnityEngine.AnimatorStateInfo stateInfo, int layerIndex) { } public override void OnStateMove(UnityEngine.Animator animator, UnityEngine.AnimatorStateInfo stateInfo, int layerIndex) { } public override void OnStateIK(UnityEngine.Animator animator, UnityEngine.AnimatorStateInfo stateInfo, int layerIndex) { } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

Editor EntryPoint C# script

Editor EntryPoint C# script

Scope Unity Editor folder

Body

$HEADER$namespace $NAMESPACE$ { [UnityEditor.InitializeOnLoad] public static class $CLASS$ { static $CLASS$() {$END$} } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

Property Drawer (IMGUI)

Property Drawer (IMGUI)

Scope Unity Editor folder, Unity 2022.1 and earlier projects

Body

$HEADER$namespace $NAMESPACE$ { [UnityEditor.CustomPropertyDrawer(typeof($TYPE$))] public class $CLASS$ : UnityEditor.PropertyDrawer { public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) { $END$ } public override float GetPropertyHeight(UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) { return base.GetPropertyHeight(property, label); } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

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

Custom Editor (IMGUI)

Custom Editor (IMGUI)

Scope Unity Editor folder, Unity 2022.1 and earlier projects

Body

$HEADER$namespace $NAMESPACE$ { [UnityEditor.CustomEditor(typeof($TYPE$))] public class $CLASS$ : UnityEditor.Editor { public override void OnInspectorGUI() { $END$ base.OnInspectorGUI(); } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

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

ISystem

Scope Unity DOTS projects

Body

$HEADER$namespace $NAMESPACE$ { public partial struct $SYSTEM$ : Unity.Entities.ISystem { [Unity.Burst.BurstCompile] public void OnCreate(ref Unity.Entities.SystemState state) { $END$ } [Unity.Burst.BurstCompile] public void OnUpdate(ref Unity.Entities.SystemState state) { } [Unity.Burst.BurstCompile] public void OnDestroy(ref Unity.Entities.SystemState state) { } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • SYSTEM - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

Scriptable Wizard

Scriptable Wizard

Scope Unity Editor folder

Body

$HEADER$namespace $NAMESPACE$ { public class $CLASS$ : UnityEditor.ScriptableWizard { [UnityEditor.MenuItem("$MENUITEM$/$MENUITEMCOMMAND$")] public static void CreateWizard() { DisplayWizard<$CLASS$>("$TITLE$", "$CREATE$", "$OTHER$"); } public void OnWizardCreate() { $END$ } public void OnWizardUpdate() { } public void OnWizardOtherButton() { } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

  • MENUITEM - no macro

  • MENUITEMCOMMAND - no macro

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

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

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

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

Standard Surface Shader

Standard Surface Shader

Scope Unity projects

Body

Shader "Custom/$NAME$" { $END$Properties { _Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo (RGB)", 2D) = "white" {} _Glossiness ("Smoothness", Range(0,1)) = 0.5 _Metallic ("Metallic", Range(0,1)) = 0.0 } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM // Physically based Standard lighting model, and enable shadows on all light types #pragma surface surf Standard fullforwardshadows // Use shader model 3.0 target, to get nicer looking lighting #pragma target 3.0 sampler2D _MainTex; struct Input { float2 uv_MainTex; }; half _Glossiness; half _Metallic; fixed4 _Color; // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader. // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing. // #pragma instancing_options assumeuniformscaling UNITY_INSTANCING_BUFFER_START(Props) // put more per-instance properties here UNITY_INSTANCING_BUFFER_END(Props) void surf (Input IN, inout SurfaceOutputStandard o) { // Albedo comes from a texture tinted by color fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; o.Albedo = c.rgb; // Metallic and smoothness come from slider variables o.Metallic = _Metallic; o.Smoothness = _Glossiness; o.Alpha = c.a; } ENDCG } FallBack "Diffuse" }

Parameters

  • NAME - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

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

Edit Mode Test

Edit Mode Test

Scope Unity Editor folder, Unity firstpass Editor folder

Body

$HEADER$using UnityEditor; namespace $NAMESPACE$ { public class $CLASS$ { [NUnit.Framework.Test] public void $CLASS$SimplePasses() { // Use the Assert class to test conditions. $END$ } // A UnityTest behaves like a coroutine in PlayMode // and allows you to yield null to skip a frame in EditMode [UnityEngine.TestTools.UnityTest] public System.Collections.IEnumerator $CLASS$WithEnumeratorPasses() { // Use the Assert class to test conditions. // yield to skip a frame yield return null; } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

Custom Editor

Custom Editor

Scope Unity Editor folder, Unity 2022.2 and later projects

Body

$HEADER$namespace $NAMESPACE$ { [UnityEditor.CustomEditor(typeof($TYPE$))] public class $CLASS$ : UnityEditor.Editor { public override UnityEngine.UIElements.VisualElement CreateInspectorGUI() { $END$ return base.CreateInspectorGUI(); } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

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

Unlit Shader

Unlit Shader

Scope Unity projects

Body

Shader "Unlit/$NAME$" { $END$Properties { _MainTex ("Texture", 2D) = "white" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 100 Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag // make fog work #pragma multi_compile_fog #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct v2f { float2 uv : TEXCOORD0; UNITY_FOG_COORDS(1) float4 vertex : SV_POSITION; }; sampler2D _MainTex; float4 _MainTex_ST; v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv, _MainTex); UNITY_TRANSFER_FOG(o,o.vertex); return o; } fixed4 frag (v2f i) : SV_Target { // sample the texture fixed4 col = tex2D(_MainTex, i.uv); // apply fog UNITY_APPLY_FOG(i.fogCoord, col); return col; } ENDCG } } }

Parameters

  • NAME - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

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

IAspect

Scope Unity DOTS projects

Body

$HEADER$namespace $NAMESPACE$ { public readonly partial struct $ASPECT$ : Unity.Entities.IAspect { $END$ } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • ASPECT - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

Editor Window (IMGUI)

Editor Window (IMGUI)

Scope Unity Editor folder, Unity 2022.1 and earlier projects

Body

$HEADER$namespace $NAMESPACE$ { public class $CLASS$ : UnityEditor.EditorWindow { [UnityEditor.MenuItem("$MENUITEM$/$MENUITEMCOMMAND$")] private static void ShowWindow() { var window = GetWindow<$CLASS$>(); window.titleContent = new UnityEngine.GUIContent("$TITLE$"); window.Show(); } private void OnGUI() { $END$ } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

  • MENUITEM - no macro

  • MENUITEMCOMMAND - no macro

  • TITLE - no macro

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

SystemBase

Scope Unity DOTS projects

Body

$HEADER$namespace $NAMESPACE$ { public partial class $SYSTEM$ : Unity.Entities.SystemBase { protected override void OnUpdate() { $END$ } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • SYSTEM - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

Property Drawer

Property Drawer

Scope Unity Editor folder, Unity 2022.2 and later projects

Body

$HEADER$namespace $NAMESPACE$ { [UnityEditor.CustomPropertyDrawer(typeof($TYPE$))] public class $CLASS$ : UnityEditor.PropertyDrawer { public override UnityEngine.UIElements.VisualElement CreatePropertyGUI(UnityEditor.SerializedProperty property) { $END$ return base.CreatePropertyGUI(property); } } }

Parameters

  • HEADER - Inserts the file header specified in settings

  • CLASS - Evaluates to the current file name without extension and with all non-alphanumeric characters replaced with underscores

  • NAMESPACE - Evaluates to the default namespace for the current file

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

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

Last modified: 27 March 2023