Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

What is #NOTRIM# for ? And using other MonoBehaviour template built-in magic variables.

Discussion in 'Scripting' started by AlanMattano, Apr 17, 2017.

  1. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,501
    I can understand what is: #SCRIPTNAME# for.
    But I do not know #NOTRIM# is it for.
    Are there more #FUNCTIONS# ? where to find them?
    http://stackoverflow.com/questions/39461801/unity-add-default-namespace-to-script-template

    Here is an example using #NOTRIM# inside a Unity default template 81 C# NewBehaviour Script
    https://gist.github.com/apkd/c111a0aba58500225c80e3ca4af9ef3d

    A short answer from https://support.unity3d.com/hc/en-us/articles/210223733-How-to-customize-Unity-script-templates

    What is this NOTRIM for and how to use it?
     
    Last edited: Apr 19, 2017
  2. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,501
    Does anybody know #NOTRIM# what is it for? Is inside the C# template.
     
  3. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    I'm not sure either. I'm guessing that it's there to prevent empty lines from being deleted depending on your operating system.

    It doesn't seem useful to me on a PC, so I don't bother using it. It might be more useful on a MacOS system, but I have no way to verify this theory.
     
  4. UnityCoach

    UnityCoach

    Joined:
    Mar 9, 2015
    Posts:
    5
    It doesn't seem to have any effect on MacOS either.
    I just tested with Unity 5.6.1 and MonoDevelop 5.9.6.
     
  5. JoshuaMcKenzie

    JoshuaMcKenzie

    Joined:
    Jun 20, 2015
    Posts:
    916
    You just answered your own question in your first post....

    In the MonoBehaviour template it preserves the indenting inside the empty functions. the auto-trimming of white-space may be platform or IDE specific, so #NOTRIM# likely can help standardize that. so that the intended behavior is consistent. Honestly #NOTRIM# is likely a noop. but simply cause its there it indirectly prevents the parser from clearing that line.


    Thats all its for. automatically setting indentation within the function.
     
    AlanMattano and Ryiah like this.
  6. GuidewireGames

    GuidewireGames

    Joined:
    Apr 20, 2017
    Posts:
    27
    is there a list of other placeholders?
     
  7. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 5, 2024
    Posts:
    418
    Not really. And there is not much to it.

    https://github.com/Unity-Technologi...Mono/ProjectBrowser/ProjectWindowUtil.cs#L613

    - #NOTRIM#
    - #NAME#
    - #SCRIPTNAME#
    - #SCRIPTNAME_LOWER#
    - #ROOTNAMESPACEBEGIN#
    - #ROOTNAMESPACEEND#

    And that's it.
    I also wrote this package: https://github.com/LurkingNinja/com.lurking-ninja.csharp-templates
    It's easy to extend to introduce new, whatever markers you like, although you will have to change the source code if you want.
     
    spiney199 likes this.