Skip to content

Instantly share code, notes, and snippets.

@udasan
Forked from neon-izm/Unity.snippet
Last active November 8, 2016 13:55
Show Gist options
  • Save udasan/b98c871ff11fd3c58971b4c07d12b0da to your computer and use it in GitHub Desktop.
Save udasan/b98c871ff11fd3c58971b4c07d12b0da to your computer and use it in GitHub Desktop.
Unity Serialized propety()
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Propety</Title>
<Author>izm</Author>
<Description>AccessCache</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
<Shortcut>props</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>Tooltip</ID>
<Default>Description Here</Default>
</Literal>
<Literal>
<ID>target</ID>
<Default>target</Default>
</Literal>
<Literal>
<ID>Component</ID>
<Default>Transform</Default>
</Literal>
<Literal>
<ID>Name</ID>
<Default>Name</Default>
</Literal>
</Declarations>
<Code Kind="any" Language="CSharp"><![CDATA[[SerializeField]
[Tooltip("$Tooltip$")]
private $Component$ _$target$;
public $Component$ $target$
{
get {
if(_$target$ ==null){
_$target$= GameObject.Find("$Name$").GetComponent<$Component$>();
}
return this._$target$; }
set { this._$target$ = value; }
}]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
@udasan
Copy link
Author

udasan commented Nov 8, 2016

izm 氏の neon-izm/Unity.snippet をちょっと修正させていただきました。

タグ閉じてないのと StackOverflow と private Target が使われないのを修正

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment