├── .gitignore ├── 30-Text File__Text-NewDoc.txt.txt ├── 30-Text File__JSON-NewJSONData.json.txt ├── 22-Scripting__Assembly Definition-NewAssembly.asmdef.txt ├── 30-Text File__XML-NewXMLData.xml.txt ├── menu-example.png ├── 23-Scripting__Assembly Definition Reference-NewAssemblyReference.asmref.txt ├── 30-Text File__MarkDown-NewDoc.md.txt ├── 21-Scripting__Assembly Definition-NewTestAssembly.asmdef.txt ├── 20-Scripting__Assembly Definition-NewEditModeTestAssembly.asmdef.txt ├── 3-Scripting__Empty C# Script-NewEmptyCSharpScript.cs.txt ├── 1-Scripting__MonoBehaviour Script-NewMonoBehaviourScript.cs.txt ├── 2-Scripting__ScriptableObject Script-NewScriptableObjectScript.cs.txt ├── 4-Shader__Compute Shader-NewComputeShader.compute.txt ├── 2-Scripting__Playables__Playable Asset Script-NewPlayableAsset.cs.txt ├── 5-Shader__Ray Tracing Shader-NewRayTracingShader.raytrace.txt ├── 103-Scene__Scene Template Pipeline-NewSceneTemplatePipeline.cs.txt ├── 1-Scripting__Editor__Custom Editor-NewCustomEditor.cs.txt ├── 3-Scripting__MonoBehaviour Script-NewTestScript.cs.txt ├── 1-Scripting__Playables__Playable Behaviour Script-NewPlayableBehaviour.cs.txt ├── 1-Scripting__Editor__Editor Window-NewEditorWindow.cs.txt ├── 3-Shader__Image Effect Shader-NewImageEffectShader.shader.txt ├── 6-Scripting__MonoBehaviour Script-NewStateMachineBehaviourScript.cs.txt ├── 2-Shader__Unlit Shader-NewUnlitShader.shader.txt ├── 1-Shader__Standard Surface Shader-NewSurfaceShader.shader.txt ├── 6-Scripting__MonoBehaviour Script-NewSubStateMachineBehaviourScript.cs.txt └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | DefaultTemplates/ -------------------------------------------------------------------------------- /30-Text File__Text-NewDoc.txt.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /30-Text File__JSON-NewJSONData.json.txt: -------------------------------------------------------------------------------- 1 | { 2 | 3 | } -------------------------------------------------------------------------------- /22-Scripting__Assembly Definition-NewAssembly.asmdef.txt: -------------------------------------------------------------------------------- 1 | { 2 | "name": "#SCRIPTNAME#" 3 | } 4 | -------------------------------------------------------------------------------- /30-Text File__XML-NewXMLData.xml.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /menu-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hubertgdev/unity-script-templates/HEAD/menu-example.png -------------------------------------------------------------------------------- /23-Scripting__Assembly Definition Reference-NewAssemblyReference.asmref.txt: -------------------------------------------------------------------------------- 1 | { 2 | "reference": "" 3 | } -------------------------------------------------------------------------------- /30-Text File__MarkDown-NewDoc.md.txt: -------------------------------------------------------------------------------- 1 | # Title 2 | 3 | [Markdown Cheat Sheet](https://www.markdownguide.org/cheat-sheet): https://www.markdownguide.org/cheat-sheet -------------------------------------------------------------------------------- /21-Scripting__Assembly Definition-NewTestAssembly.asmdef.txt: -------------------------------------------------------------------------------- 1 | { 2 | "name": "#SCRIPTNAME#", 3 | "optionalUnityReferences": [ 4 | "TestAssemblies" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /20-Scripting__Assembly Definition-NewEditModeTestAssembly.asmdef.txt: -------------------------------------------------------------------------------- 1 | { 2 | "name": "#SCRIPTNAME#", 3 | "optionalUnityReferences": [ 4 | "TestAssemblies" 5 | ], 6 | "includePlatforms": [ 7 | "Editor" 8 | ] 9 | } -------------------------------------------------------------------------------- /3-Scripting__Empty C# Script-NewEmptyCSharpScript.cs.txt: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #ROOTNAMESPACEBEGIN# 4 | 5 | /// 6 | /// 7 | /// 8 | [System.Serializable] 9 | public class #SCRIPTNAME# 10 | { 11 | 12 | public #SCRIPTNAME#() 13 | { 14 | #NOTRIM 15 | } 16 | 17 | } 18 | 19 | #ROOTNAMESPACEEND# 20 | -------------------------------------------------------------------------------- /1-Scripting__MonoBehaviour Script-NewMonoBehaviourScript.cs.txt: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #ROOTNAMESPACEBEGIN# 4 | 5 | /// 6 | /// 7 | /// 8 | //[AddComponentMenu("#SCRIPTNAME#")] 9 | public class #SCRIPTNAME# : MonoBehaviour 10 | { 11 | 12 | #region Fields 13 | #endregion 14 | 15 | 16 | #region Lifecycle 17 | #endregion 18 | 19 | 20 | #region Public API 21 | #endregion 22 | 23 | } 24 | 25 | #ROOTNAMESPACEEND# 26 | -------------------------------------------------------------------------------- /2-Scripting__ScriptableObject Script-NewScriptableObjectScript.cs.txt: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #ROOTNAMESPACEBEGIN# 4 | 5 | /// 6 | /// 7 | /// 8 | [CreateAssetMenu(fileName = "#SCRIPTNAME#", menuName = "Scriptable Objects/#SCRIPTNAME#")] 9 | public class #SCRIPTNAME# : ScriptableObject 10 | { 11 | 12 | #region Fields 13 | #endregion 14 | 15 | 16 | #region Public API 17 | #endregion 18 | 19 | } 20 | 21 | #ROOTNAMESPACEEND# 22 | -------------------------------------------------------------------------------- /4-Shader__Compute Shader-NewComputeShader.compute.txt: -------------------------------------------------------------------------------- 1 | // Each #kernel tells which function to compile; you can have many kernels 2 | #pragma kernel CSMain 3 | 4 | // Create a RenderTexture with enableRandomWrite flag and set it 5 | // with cs.SetTexture 6 | RWTexture2D Result; 7 | 8 | [numthreads(8,8,1)] 9 | void CSMain (uint3 id : SV_DispatchThreadID) 10 | { 11 | // TODO: insert actual code here! 12 | 13 | Result[id.xy] = float4(id.x & id.y, (id.x & 15)/15.0, (id.y & 15)/15.0, 0.0); 14 | } 15 | -------------------------------------------------------------------------------- /2-Scripting__Playables__Playable Asset Script-NewPlayableAsset.cs.txt: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Playables; 3 | 4 | #ROOTNAMESPACEBEGIN# 5 | 6 | /// 7 | /// 8 | /// 9 | [System.Serializable] 10 | public class #SCRIPTNAME# : PlayableAsset 11 | { 12 | 13 | // Factory method that generates a playable based on this asset 14 | public override Playable CreatePlayable(PlayableGraph graph, GameObject go) 15 | { 16 | return Playable.Create(graph); 17 | } 18 | 19 | } 20 | 21 | #ROOTNAMESPACEEND# 22 | -------------------------------------------------------------------------------- /5-Shader__Ray Tracing Shader-NewRayTracingShader.raytrace.txt: -------------------------------------------------------------------------------- 1 | RWTexture2D RenderTarget; 2 | 3 | // Uncomment this pragma for debugging the HLSL code in PIX. GPU performance will be impacted. 4 | //#pragma enable_ray_tracing_shader_debug_symbols 5 | 6 | #pragma max_recursion_depth 1 7 | 8 | [shader("raygeneration")] 9 | void MyRaygenShader() 10 | { 11 | uint2 dispatchIdx = DispatchRaysIndex().xy; 12 | 13 | RenderTarget[dispatchIdx] = float4(dispatchIdx.x & dispatchIdx.y, (dispatchIdx.x & 15)/15.0, (dispatchIdx.y & 15)/15.0, 0.0); 14 | } 15 | -------------------------------------------------------------------------------- /103-Scene__Scene Template Pipeline-NewSceneTemplatePipeline.cs.txt: -------------------------------------------------------------------------------- 1 | using UnityEditor.SceneTemplate; 2 | using UnityEngine; 3 | using UnityEngine.SceneManagement; 4 | 5 | #ROOTNAMESPACEBEGIN# 6 | 7 | /// 8 | /// 9 | /// 10 | public class #SCRIPTNAME# : ISceneTemplatePipeline 11 | { 12 | 13 | public virtual bool IsValidTemplateForInstantiation(SceneTemplateAsset sceneTemplateAsset) 14 | { 15 | return true; 16 | } 17 | 18 | public virtual void BeforeTemplateInstantiation(SceneTemplateAsset sceneTemplateAsset, bool isAdditive, string sceneName) 19 | { 20 | #NOTRIM# 21 | } 22 | 23 | public virtual void AfterTemplateInstantiation(SceneTemplateAsset sceneTemplateAsset, Scene scene, bool isAdditive, string sceneName) 24 | { 25 | #NOTRIM# 26 | } 27 | 28 | } 29 | 30 | #ROOTNAMESPACEEND# 31 | -------------------------------------------------------------------------------- /1-Scripting__Editor__Custom Editor-NewCustomEditor.cs.txt: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | #ROOTNAMESPACEBEGIN# 5 | 6 | /// 7 | /// Custom editor for objects. 8 | /// 9 | [CustomEditor(typeof(#SCRIPTNAME#))] 10 | public class #SCRIPTNAME# : Editor 11 | { 12 | 13 | #region Fields 14 | #endregion 15 | 16 | 17 | #region Lifecycle 18 | 19 | /// 20 | /// Called when this editor is loaded. 21 | /// 22 | private void OnEnable() 23 | { 24 | #NOTRIM# 25 | } 26 | 27 | #endregion 28 | 29 | 30 | #region UI 31 | 32 | /// 33 | /// Draws the GUI for the edited object(s). 34 | /// 35 | public override void OnInspectorGUI() 36 | { 37 | base.OnInspectorGUI(); 38 | } 39 | 40 | #endregion 41 | 42 | } 43 | 44 | #ROOTNAMESPACEEND# -------------------------------------------------------------------------------- /3-Scripting__MonoBehaviour Script-NewTestScript.cs.txt: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using NUnit.Framework; 3 | using UnityEngine; 4 | using UnityEngine.TestTools; 5 | 6 | #ROOTNAMESPACEBEGIN# 7 | 8 | public class #SCRIPTNAME# 9 | { 10 | 11 | /// 12 | /// A Test behaves as an ordinary method 13 | /// 14 | [Test] 15 | public void #SCRIPTNAME#SimplePasses() 16 | { 17 | // Use the Assert class to test conditions 18 | } 19 | 20 | /// 21 | /// A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use yield return null;` to skip a frame. 22 | /// 23 | [UnityTest] 24 | public IEnumerator #SCRIPTNAME#WithEnumeratorPasses() 25 | { 26 | // Use the Assert class to test conditions. 27 | // Use yield to skip a frame. 28 | yield return null; 29 | } 30 | 31 | } 32 | 33 | #ROOTNAMESPACEEND# 34 | -------------------------------------------------------------------------------- /1-Scripting__Playables__Playable Behaviour Script-NewPlayableBehaviour.cs.txt: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Playables; 3 | 4 | #ROOTNAMESPACEBEGIN# 5 | 6 | /// 7 | /// A behaviour that is attached to a playable. 8 | /// 9 | public class #SCRIPTNAME# : PlayableBehaviour 10 | { 11 | 12 | // Called when the owning graph starts playing 13 | public override void OnGraphStart(Playable playable) 14 | { 15 | #NOTRIM# 16 | } 17 | 18 | // Called when the owning graph stops playing 19 | public override void OnGraphStop(Playable playable) 20 | { 21 | #NOTRIM# 22 | } 23 | 24 | // Called when the state of the playable is set to Play 25 | public override void OnBehaviourPlay(Playable playable, FrameData info) 26 | { 27 | #NOTRIM# 28 | } 29 | 30 | // Called when the state of the playable is set to Paused 31 | public override void OnBehaviourPause(Playable playable, FrameData info) 32 | { 33 | #NOTRIM# 34 | } 35 | 36 | // Called each frame while the state is set to Play 37 | public override void PrepareFrame(Playable playable, FrameData info) 38 | { 39 | #NOTRIM# 40 | } 41 | 42 | } 43 | 44 | #ROOTNAMESPACEEND# 45 | -------------------------------------------------------------------------------- /1-Scripting__Editor__Editor Window-NewEditorWindow.cs.txt: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | #ROOTNAMESPACEBEGIN# 5 | 6 | /// 7 | /// 8 | /// 9 | public class #SCRIPTNAME# : EditorWindow 10 | { 11 | 12 | #region Fields 13 | 14 | private const string WINDOW_TITLE = "#SCRIPTNAME#"; 15 | private const string MENU_ITEM = "Tools/" + WINDOW_TITLE; 16 | 17 | #endregion 18 | 19 | 20 | #region Lifecycle 21 | 22 | /// 23 | /// Called when this window is open. 24 | /// 25 | private void OnEnable() 26 | { 27 | #NOTRIM# 28 | } 29 | 30 | #endregion 31 | 32 | 33 | #region Public API 34 | 35 | /// 36 | /// Opens this editor window. 37 | /// 38 | [MenuItem(MENU_ITEM)] 39 | public static #SCRIPTNAME# Open() 40 | { 41 | #SCRIPTNAME# window = GetWindow<#SCRIPTNAME#>(false, WINDOW_TITLE, true); 42 | window.Show(); 43 | return window; 44 | } 45 | 46 | #endregion 47 | 48 | 49 | #region UI 50 | 51 | /// 52 | /// Draws this window GUI on screen. 53 | /// 54 | private void OnGUI() 55 | { 56 | #NOTRIM# 57 | } 58 | 59 | #endregion 60 | 61 | } 62 | 63 | #ROOTNAMESPACEEND# -------------------------------------------------------------------------------- /3-Shader__Image Effect Shader-NewImageEffectShader.shader.txt: -------------------------------------------------------------------------------- 1 | Shader "Hidden/#NAME#" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Texture", 2D) = "white" {} 6 | } 7 | SubShader 8 | { 9 | // No culling or depth 10 | Cull Off ZWrite Off ZTest Always 11 | 12 | Pass 13 | { 14 | CGPROGRAM 15 | #pragma vertex vert 16 | #pragma fragment frag 17 | 18 | #include "UnityCG.cginc" 19 | 20 | struct appdata 21 | { 22 | float4 vertex : POSITION; 23 | float2 uv : TEXCOORD0; 24 | }; 25 | 26 | struct v2f 27 | { 28 | float2 uv : TEXCOORD0; 29 | float4 vertex : SV_POSITION; 30 | }; 31 | 32 | v2f vert (appdata v) 33 | { 34 | v2f o; 35 | o.vertex = UnityObjectToClipPos(v.vertex); 36 | o.uv = v.uv; 37 | return o; 38 | } 39 | 40 | sampler2D _MainTex; 41 | 42 | fixed4 frag (v2f i) : SV_Target 43 | { 44 | fixed4 col = tex2D(_MainTex, i.uv); 45 | // just invert the colors 46 | col.rgb = 1 - col.rgb; 47 | return col; 48 | } 49 | ENDCG 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /6-Scripting__MonoBehaviour Script-NewStateMachineBehaviourScript.cs.txt: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #ROOTNAMESPACEBEGIN# 4 | 5 | /// 6 | /// 7 | /// 8 | public class #SCRIPTNAME# : StateMachineBehaviour 9 | { 10 | // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state 11 | //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 12 | //{ 13 | // #NOTRIM# 14 | //} 15 | 16 | // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks 17 | //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 18 | //{ 19 | // #NOTRIM# 20 | //} 21 | 22 | // OnStateExit is called when a transition ends and the state machine finishes evaluating this state 23 | //override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 24 | //{ 25 | // #NOTRIM# 26 | //} 27 | 28 | // OnStateMove is called right after Animator.OnAnimatorMove() 29 | //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 30 | //{ 31 | // // Implement code that processes and affects root motion 32 | //} 33 | 34 | // OnStateIK is called right after Animator.OnAnimatorIK() 35 | //override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 36 | //{ 37 | // // Implement code that sets up animation IK (inverse kinematics) 38 | //} 39 | } 40 | 41 | #ROOTNAMESPACEEND# 42 | -------------------------------------------------------------------------------- /2-Shader__Unlit Shader-NewUnlitShader.shader.txt: -------------------------------------------------------------------------------- 1 | Shader "Unlit/#NAME#" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Texture", 2D) = "white" {} 6 | } 7 | SubShader 8 | { 9 | Tags { "RenderType"="Opaque" } 10 | LOD 100 11 | 12 | Pass 13 | { 14 | CGPROGRAM 15 | #pragma vertex vert 16 | #pragma fragment frag 17 | // make fog work 18 | #pragma multi_compile_fog 19 | 20 | #include "UnityCG.cginc" 21 | 22 | struct appdata 23 | { 24 | float4 vertex : POSITION; 25 | float2 uv : TEXCOORD0; 26 | }; 27 | 28 | struct v2f 29 | { 30 | float2 uv : TEXCOORD0; 31 | UNITY_FOG_COORDS(1) 32 | float4 vertex : SV_POSITION; 33 | }; 34 | 35 | sampler2D _MainTex; 36 | float4 _MainTex_ST; 37 | 38 | v2f vert (appdata v) 39 | { 40 | v2f o; 41 | o.vertex = UnityObjectToClipPos(v.vertex); 42 | o.uv = TRANSFORM_TEX(v.uv, _MainTex); 43 | UNITY_TRANSFER_FOG(o,o.vertex); 44 | return o; 45 | } 46 | 47 | fixed4 frag (v2f i) : SV_Target 48 | { 49 | // sample the texture 50 | fixed4 col = tex2D(_MainTex, i.uv); 51 | // apply fog 52 | UNITY_APPLY_FOG(i.fogCoord, col); 53 | return col; 54 | } 55 | ENDCG 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /1-Shader__Standard Surface Shader-NewSurfaceShader.shader.txt: -------------------------------------------------------------------------------- 1 | Shader "Custom/#NAME#" 2 | { 3 | Properties 4 | { 5 | _Color ("Color", Color) = (1,1,1,1) 6 | _MainTex ("Albedo (RGB)", 2D) = "white" {} 7 | _Glossiness ("Smoothness", Range(0,1)) = 0.5 8 | _Metallic ("Metallic", Range(0,1)) = 0.0 9 | } 10 | SubShader 11 | { 12 | Tags { "RenderType"="Opaque" } 13 | LOD 200 14 | 15 | CGPROGRAM 16 | // Physically based Standard lighting model, and enable shadows on all light types 17 | #pragma surface surf Standard fullforwardshadows 18 | 19 | // Use shader model 3.0 target, to get nicer looking lighting 20 | #pragma target 3.0 21 | 22 | sampler2D _MainTex; 23 | 24 | struct Input 25 | { 26 | float2 uv_MainTex; 27 | }; 28 | 29 | half _Glossiness; 30 | half _Metallic; 31 | fixed4 _Color; 32 | 33 | // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader. 34 | // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing. 35 | // #pragma instancing_options assumeuniformscaling 36 | UNITY_INSTANCING_BUFFER_START(Props) 37 | // put more per-instance properties here 38 | UNITY_INSTANCING_BUFFER_END(Props) 39 | 40 | void surf (Input IN, inout SurfaceOutputStandard o) 41 | { 42 | // Albedo comes from a texture tinted by color 43 | fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; 44 | o.Albedo = c.rgb; 45 | // Metallic and smoothness come from slider variables 46 | o.Metallic = _Metallic; 47 | o.Smoothness = _Glossiness; 48 | o.Alpha = c.a; 49 | } 50 | ENDCG 51 | } 52 | FallBack "Diffuse" 53 | } 54 | -------------------------------------------------------------------------------- /6-Scripting__MonoBehaviour Script-NewSubStateMachineBehaviourScript.cs.txt: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | #ROOTNAMESPACEBEGIN# 4 | 5 | /// 6 | /// 7 | /// 8 | public class #SCRIPTNAME# : StateMachineBehaviour 9 | { 10 | // OnStateEnter is called before OnStateEnter is called on any state inside this state machine 11 | //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 12 | //{ 13 | // #NOTRIM# 14 | //} 15 | 16 | // OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine 17 | //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 18 | //{ 19 | // #NOTRIM# 20 | //} 21 | 22 | // OnStateExit is called before OnStateExit is called on any state inside this state machine 23 | //override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 24 | //{ 25 | // #NOTRIM# 26 | //} 27 | 28 | // OnStateMove is called before OnStateMove is called on any state inside this state machine 29 | //override public void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 30 | //{ 31 | // #NOTRIM# 32 | //} 33 | 34 | // OnStateIK is called before OnStateIK is called on any state inside this state machine 35 | //override public void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 36 | //{ 37 | // #NOTRIM# 38 | //} 39 | 40 | // OnStateMachineEnter is called when entering a state machine via its Entry Node 41 | //override public void OnStateMachineEnter(Animator animator, int stateMachinePathHash) 42 | //{ 43 | // #NOTRIM# 44 | //} 45 | 46 | // OnStateMachineExit is called when exiting a state machine via its Exit Node 47 | //override public void OnStateMachineExit(Animator animator, int stateMachinePathHash) 48 | //{ 49 | // #NOTRIM# 50 | //} 51 | } 52 | 53 | #ROOTNAMESPACEEND# 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity Script Templates 2 | 3 | This repository is a bundle of the Script Templates I use in my Unity Projets. 4 | 5 | Updated for *Unity 6000+*. 6 | 7 | --- 8 | 9 | ⚠️ Even if this package is still maintained, I worked on the [***Asset Template*** package](https://github.com/side-xp/unity-asset-templates) from *Sideways Experiments*, which allow the use of templates for scripts, text files or even serializanle assets by just using the right name, prefix or suffix to a file to create. 10 | 11 | That package is open source and free to use in any projects, and is a way better approach than copy-pasting templates from a *Unity* version's install folder to another. 12 | 13 | --- 14 | 15 | ## Setup Script templates in Unity 16 | 17 | Are called "script templates" the source of the content generated by Unity when you create a new C# Script for examples. 18 | 19 | They are written in your *Unity* install folder, in `Editor/Data/Resources/ScriptTemplates`. You can notice a specific file naming, see below for more informations about it. 20 | 21 | To setup my custom Unity script tempates, download or clone this repo into your Unity install folder. If your Unity editor is open when you set these files, close it and reopen it. 22 | 23 | ```bash 24 | git clone https://github.com/hubertgdev/unity-script-templates 25 | ``` 26 | 27 | Now, if you try to create a new asset (by right-clicking in the `Project` view, or from `Assets > Create` menu), you can see some new menus for script creation ! 28 | 29 | ![Create asset menu example](menu-example.png) 30 | 31 | Obviously, you can create your own script templates, or simply adapt these ones for your own use. 32 | 33 | ## Script Templates naming 34 | 35 | You can see that all the template scripts files have a specific naming syntax : 36 | 37 | ``` 38 | 1-Scripting__MonoBehaviour Script-NewMonoBehaviourScript.cs.txt 39 | ``` 40 | 41 | | 1 | Scripting | MonoBehaviour Script | NewMonoBehaviourScript | .cs | 42 | | - | - | - | - | - | 43 | | Menu position | Menu name | Submenu name | Default name of the new created file | Created file extension | 44 | 45 | Note that submenus are facultative, but you can setup as many submenus as you want, by separating elements with "`__`". 46 | 47 | ## Script Template content 48 | 49 | You can make script templates of any text asset you want (it can be C#, JSON, XML, YAML, TXT, or any code or text content). 50 | 51 | Inside these scripts, you can also use `#SCRIPTNAME#` keyword. When Unity generates the new asset, it will replace that keyword by the created file name. It can be useful for automating class name generation. --------------------------------------------------------------------------------