Created
July 3, 2017 05:14
-
-
Save fredimachado/34fdb0203892279c7cc6a00fcce76137 to your computer and use it in GitHub Desktop.
Visual Studio snippet to create a Unity serializable field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>field</Title> | |
<Shortcut>field</Shortcut> | |
<Description>Code snippet for a Unity serializable field | |
Language Version: C# 3.0 or higher</Description> | |
<Author>Fredi Machado</Author> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> | |
</SnippetTypes> | |
</Header> | |
<Snippet> | |
<Declarations> | |
<Literal> | |
<ID>type</ID> | |
<ToolTip>Field type</ToolTip> | |
<Default>int</Default> | |
</Literal> | |
<Literal> | |
<ID>field</ID> | |
<ToolTip>Field name</ToolTip> | |
<Default>fieldName</Default> | |
</Literal> | |
</Declarations> | |
<Code Language="csharp"><![CDATA[[SerializeField] $type$ $field$;$end$]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
A very nice thing about VS snippets is that after you expand it using TAB, you can navigate through the literal declarations (In this snippet they are the field type, which defaults to int, and the field name which defaults to fieldName) using TAB and when you're done, just press ENTER. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In case you're wondering: To make Visual Studio aware of the snippet you should save this content as a file named field.snippet in this folder: C:\Users\YOUR_USER\Documents\Visual Studio 2017\Code Snippets\Visual C#\My Code Snippets
After that, restart Visual Studio, open any C# file, type "field" (the name of the snippet without double quotes) and press TAB twice. :)