Template C# Script for Unity

Template and placeholder post:
This is the default link in my standard C# script template. It’s planned to change the link inside the class, if there is a detailed description available online. However this is the default text and you read this lines because there was no better description and no matching url for the class you inspected.

Some Background Info:
Every time you create a new C# script in Unity a template file is loaded.
It’s possible to change the template txt file directly on you OS / in your environment – so your default values / codes / script templates are loaded instead of the Unity Standards.

On Windows – you will find the templates here…
C:\Program Files (x86)\unity\Editor\Data\Resources\ScriptTemplates

Mac: /Applications/Unity/Editor/Data/Resources/ScriptTemplates
Mac (since 5.2.1f1): /Applications/Unity/Unity.app/Contents/Resources/ScriptTemplates

The template for the standard C# Class is…
81-C# Script-NewBehaviourScript.cs.txt

Version 1 of my 2018 Template:

#region MegAgeM C# Template Header
/*
* Copyright (c) MegAgeM 2018 - @bgp
* https://www.MegAgeM.net/
*
* More Info         :   TXT or WWW https://www.megagem.net/2018/02/05/template-c-script-unity/?script=#SCRIPTNAME#
* C# Template Info  :   https://www.megagem.net/2018/02/05/template-c-script-unity/
* bgp - Internal    :   http://www.boegi.com/n2k/?p=6522
* Version           :   #SCRIPTNAME_LOWER#_20180000_0000_0
*/
#endregion
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

//[RequireComponent(typeof(Rigidbody))] // PlayerScript requires the GameObject to have a Rigidbody component
[HelpURL("https://www.megagem.net/?s=#SCRIPTNAME#")]
public class #SCRIPTNAME# : MonoBehaviour {
    
    #region variables
    //TODO - CLEAN THE TEMPLATE REGION IF NOT NEEDED! It's also available here! https://www.megagem.net/2018/02/05/template-c-script-unity/
    #region template variables
    /*
    [Header("Variables for #SCRIPTNAME#")]
    [Space]
    [SerializeField]
    private string tmpInfoPrivate = "Private but editable in the Unity editor";
    
    [Tooltip("This is a Tooltip for the Unity Editor")]
    [Space(10)]
    [SerializeField]
    private string tmpInfoEditor = "This field has a nice Tooltip in the Unity Editor";
    
    [HideInInspector]
    public string tmpInfoPublicButHidden = "Not visible in the Unity Editor";
    
    
    [TextArea] //https://docs.unity3d.com/ScriptReference/TextAreaAttribute.html
    [SerializeField]
    private string tmpInfoMultilineTextArea = "This is a multiline textarea in the editor";
    
    [Range(0.01f,1f)]
    public float tmpRangeTemplate = 0.5f;
        
    /// <summary>
    /// This XML summary is shown in Visual Studio if you place the mouse over it
    /// </summary>
    private string tmpInfoVisualStudio;
    */
    
    /* Learn this in 2018 
    Three times / will add the XML summary
    Write for and Tab to get a for Loop from VS
    Use the Book symbol next to standard components to find fast results
    */
    #endregion template variables
    #endregion variables
    
    #region methods
    #region template methods
    /*
    [ContextMenu("MethodCanBeCalledFromUnityEditor")]
    private void MethodCanBeCalledFromUnityEditor(){
        Debug.Log("YES the method was called!");
    }
    private void InvokeAfterNSeconds(){
        Debug.Log("Invoke was executed...");
    }
    */
    #endregion template methods
    void Start () {
        //if(templateVar == null){ Debug.Log("templateVar was not assigned in the Inspector - Please do or code a find method."); Debug.Break();}
        //Invoke("InvokeAfterNSeconds", 2f);
		#NOTRIM#
	}

	void Update () {
		#NOTRIM#
	}
    #endregion methods
}

Additional Links:
Source: https://youtu.be/_g1TyAGk6Lk?list=PLPV2KyIb3jR4dNDPcSiAY-73gAKRIiPk4&t=190

Hidden content detected! Please login.

Enum and State Machines:
Search for PanelHandler.cs and use the TAB key (plus Arrow right) in VisualStudio to get perfect switch case code blocks for the State machine and other Enum related switch case things.