Changing Unity Default Script Content
Changing Unity Default (Template) Script Content
Hello friends, in this article I will explain how you can change the base script layout that appears when you create a script in Unity.
If I need to explain what we are going to change and give an example, Unity has a built-in script template as shown below.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DemoScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
We will set the code template above as we like, and from now on, when we create a script, the script we have set will appear, allowing us to create our own template script.
Before setting our own template script, I will use the template code below for this article, in other words, from now on the scripts we create will come as shown below.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DemoScript : MonoBehaviour
{
// Command that runs in the first frame
void Start()
{
// Created by UrhobA
}
// Command that runs every frame
void Update()
{
// Created by UrhobA
}
}
Let's start with the arrangements.
Changing the Template
Windows
C:\ProgramFiles\Unity\Hub\Editor\YourVersion\Editor\Data\Resources\ScriptTemplatesMac
/Applications/Unity/Hub/Editor/YourVersion/Unity.app/Contents/Resources/ScriptTemplates
s
According to the operating system we use, we go to the locations above and open the script named "81-C# Script-NewBehaviourScript.cs" and edit it as we wish. From now on, when we create a new script within Unity, this new template we have created will open, and we can automatically embed commands we use often or our signature into each script.
(Unity Windows Templates)
(Unity Mac Templates)
Additionally, you can also edit the other script templates here and add your own templates for other scripts created as well.




Yorum Gönder