2
4

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.

Sprite.Create

Last updated at Posted at 2015-06-08

sprite差し替えをやる必要があるので、いろいろ調べてたけど、わかってきたのでまとめ

Sprite.Create(Texture2D texture,Rect rect,Vector2 pivot, float pixelPerUnit)

texture
テクスチャ
rect
スプライトの大きさ
pivot
中心(回転の中心)
pixelPerUnit
Unit内のピクセル数

で、試してみた

Texture texture = Resource.Load<Texture>("/Asset/Resources以下のpathとファイル名");

Sprite spr = Sprite.Create( texture,
    new Vector3( texture.width, texture.height, 0.1f ), // 厚みほぼなし
    new Vector2( 0.5f, 0.5f ) // 中心
);

pixelPerUnit は100にすると等倍、50にすると倍の大きさ
でも、そのままの4点ポリゴンにテクスチャはっつけるだけであれば、指定しなければ等倍なので指定しなくてもいい気がする。

2
4
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
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?