2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Unity+NGUIでSpriteを反転する

Posted at

一般的にSpriteを反転させるには

一般的なやり方
sprite.x *= -1

のようにtransform上の数値をいじる。

しかしNGUIにはflipというフィールドがあり、これを差し替えることで自由に反転することができる。

NGUIの場合
UI2dSprite _sprite;

void hoge() {
  //左右を反転させる
  _sprite.flip = UIBasicSprite.Flip.Horizontally;
  //上下を反転させる
  _sprite.flip = UIBasicSprite.Flip.Vertically;
  //左右かつ上下を反転させる
  _sprite.flip = UIBasicSprite.Flip.Both;
  //反転をやめる
  _sprite.flip = UIBasicSprite.Flip.Nothing;
}

transformをいじるよりはるかに意図が伝わりやすくていいね><

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?