fbpx

 

Code Snippets for D...
 

Code Snippets for Debug,Log()  

  RSS
kdub (Kerry)
(@kdub)
Mesozoic relic

I'd like a dollar for every time I've typed Debug.Log("Bla ummm"); recently ... So ..

If you don't use String Interpolation just change the CDATA entry to  Debug.Log("$end$");

C:\Users\**user**\Documents\Visual Studio 2019\Code Snippets\Visual C#\My Code Snippets\dl1.snippet

 

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>DL1</Title>
<Shortcut>DL1</Shortcut>
<Description>Code snippet for Debug.Log with Interpolation in Unity3D</Description>
<Author>Kerry Brown</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="false">
<ID>dollar</ID>
<Default>$</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[Debug.Log($dollar$"$end${}");]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

 

 

 

 
This topic was modified 2 months ago 10 times by kdub (Kerry)
Quote
Posted : 22/09/2019 5:54 am
kdub (Kerry)
(@kdub)
Mesozoic relic

SNIPPET FOR:   if (Input.GetKeyDown(KeyCode.Space)) { }

Fairly self explanatory. ( see piccys )

Save to C:\Users\**user**\Documents\Visual Studio 2019\Code Snippets\Visual C#\My Code Snippets\IGK.snippet
command IGK Tab+Tab for empty body  ( or Ctrl+K, Ctrl+X )
or Select code to surround, RtClick and select IGK from Snippets->  ( or Ctrl+K, Ctrl+S  after selecting body to surround)

The Keycode variable is selected and editable.


<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>IGK</Title>
<Shortcut>IGK</Shortcut>
<Description>Code snippet for Input.GetKeyDown(...) in Unity3D</Description>
<Author>Kerry Brown</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal >
<ID>expression</ID>
<ToolTip>Keycode to test</ToolTip>
<Default>Space</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[if(Input.GetKeyDown(KeyCode.$expression$)){
$selected$ $end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>


Result:

 

Regards,

ReplyQuote
Posted : 27/10/2019 2:31 am
kdub (Kerry)
(@kdub)
Mesozoic relic

SNIPPET FOR:   SINGLETON Declaration code Snippet

Save to C:\Users\**user**\Documents\Visual Studio 2019\Code Snippets\Visual C#\My Code Snippets\singleton.snippet
command sing Tab+Tab

Modify the first field by typing the Class name, and press Enter ... all fields will update

 

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>Singleton</Title>
<Author>Kerry Brown
</Author>
<Description>
</Description>
<HelpUrl>
</HelpUrl>
<Shortcut>sing</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>class</ID>
<ToolTip>instance Class</ToolTip>
<Default>Class</Default>
<Function>
</Function>
</Literal>
</Declarations>
<Code Language="csharp" Delimiter="$"><![CDATA[ private static $class$ instance;

public static $class$ Instance {
get {
if (instance == null) {
Debug.LogError("The $class$ is NULL.");
}
return instance;
}
}

private void Awake() {
instance = this;
}]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>

 

This is the output :

 

Regards,

ReplyQuote
Posted : 27/10/2019 11:35 pm
Share:

 

 

Scroll to Top

Please Login or Register