Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Can't change script's default template

Discussion in 'Scripting' started by Sonoshee, Sep 22, 2015.

  1. Sonoshee

    Sonoshee

    Joined:
    Jul 8, 2014
    Posts:
    77
    After installing Unity 5.2 I noticed that changing C# scripts' default templates from Unity\Editor\Data\Resources\ScriptTemplates doesn't work anymore.

    Here is my 81-C# Script-NewBehaviourScript.cs.txt file :


    Here is what a newly created C# script looks like:


    Is it the same for you guys?
    Note that I'm telling Unity that my script editor is Visual Studio, but I actually use Sublime Text to write my code. I do this so that VS generates solution files that Sublime's OmniSharp uses.
     
  2. Jordi-Bonastre

    Jordi-Bonastre

    Unity Technologies

    Joined:
    Jul 6, 2015
    Posts:
    102
    Open the file properties and change the Security settings. Apply the changes and you could modify the scripts templates.
     
  3. Sonoshee

    Sonoshee

    Joined:
    Jul 8, 2014
    Posts:
    77
    I believe you want to make sure that my file can be written to, it already can and it holds the desired values saved, however the problem still exists as though Unity can't read that file.
     
  4. Jordi-Bonastre

    Jordi-Bonastre

    Unity Technologies

    Joined:
    Jul 6, 2015
    Posts:
    102
    I tried with Unity 5.2.0p1 and it works fine on Windows 10 and OS X 10.10.5. For Win, I changed file's properties
     
  5. Sonoshee

    Sonoshee

    Joined:
    Jul 8, 2014
    Posts:
    77
    Oh welp, it works now! I have no idea how but it just worked after creating another script.
    Sorry for the inconvenience and thanks for helping out.
     
  6. TheRealMarco

    TheRealMarco

    Joined:
    Apr 19, 2015
    Posts:
    10
    Hi.
    I have the exact same problem. Everything work fine before I upgrade to the 5.6.1 (I was 5.3.5). But now, when I edit the NewBehaviorScript, he doesn't work, Unity continues to use the default BehaviorScript.

    I changed the security settings, but nothing change. Do I did it incorrectly ?

     
  7. KiomopeGames

    KiomopeGames

    Joined:
    Aug 31, 2017
    Posts:
    2
    I have the problem too.
    In my case, the following file was the cause.

    C:\Users\<Username>\AppData\Local\VirtualStore\Program Files\Unity...\81-C# Script-NewBehaviourScript.cs.txt
    Let's call it FORGERY.

    The file we want to edit is, to varying degrees,
    C:\Program Files\Unity\Editor\Data\Resources\ScriptTemplates\81-C# Script-NewBehaviourScript.cs.txt
    Lets' call it ORIGIN

    When we attempt to change ORIGIN without permission, some text editor doesn't show any alert but generate FORGERY under VirtualStore.
    After this, when we open ORIGIN with the text editor, the os show us FORGERY transparently so that we misconstrue the file is changed.
    However actual ORIGIN is not changed and Unity use the ORIGIN template.
    This is how the problem happen.

    To solve this, just delete FORGERY and change ORIGIN with permission.
     
  8. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,199
    Windows <3
     
  9. TheRealMarco

    TheRealMarco

    Joined:
    Apr 19, 2015
    Posts:
    10
    My VirtualStore folder is already empty...
     
  10. KiomopeGames

    KiomopeGames

    Joined:
    Aug 31, 2017
    Posts:
    2
    I deleted the template file as a test.
    Trying to create new C# script without the file, Unity shew me an error.
    So there should be another default template file which Unity uses.

    Maybe you can find the file by searching your PC for specific word, like "MonoBehaviour", with File Explorer.
     
  11. TheRealMarco

    TheRealMarco

    Joined:
    Apr 19, 2015
    Posts:
    10
    I tried, but there was like one million result. I then try with "NewBehaviourScript". And it's all good now.

    Thanks dude !

    You're the real MVP
    !
     
  12. WaltonV

    WaltonV

    Joined:
    May 25, 2017
    Posts:
    1
    I got it by going on Alt+Enter file > Security > Edit > Put all on Full Control settings. Enjoy!
     
  13. Dusty777

    Dusty777

    Joined:
    Jul 23, 2016
    Posts:
    9
    same as above, except I also had to change permissions on parent folder.
     
    reinfeldx likes this.