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.

[Unity初級]prefabしてあるUIパーツをInstantiateで登場させる

Posted at

概要

UIパーツはCanvas上に置かないと、存在はしてるのに表示はされない状態になります。
Instantiateで登場させた直後はCanvasに置かれてないのでCanvasへ移す手順が必要になります。

本文


    public GameObject canvas;
    public GameObject InputButton;

    void Start()
    {
        GameObject prefab = (GameObject)Instantiate (InputButton);
        prefab.transform.SetParent (canvas.transform, false);
    }

スクリーンショット_(150).png

SetParentによってUI(ここではInputButton)をCanvasへ移してます。

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?