Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active January 1, 2016 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/8066386 to your computer and use it in GitHub Desktop.
Save tsubaki/8066386 to your computer and use it in GitHub Desktop.
[Unity] Resourcesに配置したパック済みのSpriteを取得する
public static Sprite Load (string fileName , string spriteName) {
// Resoucesから対象のテクスチャから生成したスプライト一覧を取得
Sprite[] sprites = Resources.LoadAll<Sprite>(fileName);
// 対象のスプライトを取得
return System.Array.Find<Sprite>( sprites, (sprite) => sprite.name.Equals(spriteName));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment