Last active
November 23, 2016 16:12
-
-
Save neon-izm/1a4da1e2702090e29485512ba3019b44 to your computer and use it in GitHub Desktop.
Unity Serialized propety()
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
<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> |
[SerializeField]
[Tooltip("Description Here")]
private Transform _target;
public Transform target
{
get
{
if (_target == null)
{
_target = GameObject.Find("Name").GetComponent<Transform>();
}
return this._target;
}
set { this._target = value; }
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ウダサンのコードレビューを受けて更新!