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?

はじめてのアドベントカレンダーAdvent Calendar 2024

Day 1

ScrollViewを使ったアイテムリストの作成

Last updated at Posted at 2024-12-15

ScrollViewの作成

1.まず、UI>ScrollViewからScrollViewを作成する
2.strechにしておく
3.Hirizontalを削除する
4.ViewPortの水平をoffに
5.contentに下記のContentスクリプト、GridRayout、ContentSizeFitterをアタッチ
6.ViewPort、handle、GridRayoutを調整
7.Constrainntを変更
8.ContentスクリプトのTargetにはcontentを、_objectには増やしたいオブジェクトを入れる
9.ボタンなどでcontentスクリプトを操作する

スクリプト

Content.cs
     [SerializeField] GameObject _object;
     [SerializeField] GameObject Target;
     void Update()
     {
            ContentNum = Target.transform.childCount;
            count1 = ContentNum;
            
            Object2 = Instantiate(_object);
            Object2.name = _object.name + (count1 + 1);
            Object2.transform.SetParent(Target.transform);
            var rect=Object2.GetComponent<RectTransform>();
            Object2.transform.localScale = new Vector3(43.8f, 63.6f, 0);
            rect.transform.localPosition = new Vector3(0, 0, 0);
}
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?