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 3 years have passed since last update.

【Unity】オブジェクトをクリックで非表示にする

Last updated at Posted at 2021-09-23

オブジェクトを追加する

  1. 任意の3Dオブジェクトを追加する

  2. オブジェクトにEventTriggerを追加する

スクリーンショット 2021-09-23 11.34.26.png

Scriptを追加する

//クリックしたらオブジェクトを非表示にする
public void OnClickObj()
    {
        gameObject.SetActive(false);
    }

MainCameraでPhisicsRaycasterを追加する

クリックしたとき、レーザーを出して、オブジェクトを検知するため、
PhisicsRaycasterを追加するスクリーンショット 2021-09-23 11.36.16.png

EventSystemを追加する

Event処理するため、HierarchyにEventSystemを追加する
スクリーンショット 2021-09-23 11.37.10.png

試す

クリックで消えることを確認する
スクリーンショット 2021-09-23 11.37.44.png

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?