0
0

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.

uGUIのオブジェクトが最前かどうかを判定する

Posted at

前提

  • unity 2017.4、2018.4
  • staticクラス内で定義しない(拡張メソッドにしない)場合は、引数のthisを取ってください。

できること

  • オブジェクトがヒエラルキーで末弟かどうかを判定します。

コード

/// <summary>オブジェクトが最前かどうかを判定</summary>
public static bool IsLastSibling (this GameObject child) {
	return (child.transform.GetSiblingIndex () == child.transform.parent.childCount - 1);
}

使い方

if (!this.IsLastSibling ()) return; // 自身が最前でなければ何もしない
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?