- Home /
Add stuff to script by default when created
Hello! I want to know how to add stuff to a script when it is created, like the way that scripts always include void
Update () {} void Start () {}
I want to add
if (GameObject.Find("Camera").GetComponent().Paused == false) { The Rest of void Update }
inside void Update to every script I create (so that the stuff only happens if the game's not paused) and I think i'd find myself adding that more often than i'd find myself deleting it if it were there by default.
Also,it'd be cool if there were a way so that it's a whole new type of script (so when right-clicking the project window and going to add>script I can select c# script, JavaScript script, Boo script, and Predefined Pause Script (C#) )
Answer by wangunity · Jan 26, 2015 at 02:22 AM
i think it may be the script template with unity3D. if you os is windows ,you can open the direction C:\Program Files (x86)\Unity\Editor\Data\Resources\ScriptTemplates . (if os is mac ,the path is /Applications/Unity/Unity.app/Contents/Resources/ScriptTemplates/81-C#\ Script-NewBehaviourScript.cs.txt ) there are four files ,include c# , boo, javascript template file. below is c# file : using UnityEngine; using System.Collections;
public class #SCRIPTNAME# : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
so if you want to add some code to the script when you create , you can add the code in the file. maybe it will help you.
Thanks! I had a feeling it'd a file in the unity application support folder. I'm actually using mac though, but this gives me a good idea of where to find them. do you think it'll work if I add another file?
Yep. /Applications/Unity/Unity.app/Contents/Resources/ScriptTemplates/81-C#\ Script-NewBehaviourScript.cs.txt
Thanks, Dude!
Ps. Can you edit that directory into your answer?
Your answer
![](https://koobas.hobune.stream/wayback/20220613181530im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Assigning script to a variable with a variable 1 Answer
Calculate one lap completion Unity3d 2 Answers
In game TV set. 1 Answer
Loop through all meshes in fbx 0 Answers
MonoDevelop and UniSciTE not auto completing JavaScript with 3.4 3 Answers