using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class ScrollView
{
public GameObject Item;//Scroll View组件 Content下的子物体
public Transform Content;///Scroll View组件 Content
public string [] sprite_images=new string[5] { "fire", "icon", "LaserBeamerIcon","MissileLauncherIcon", "MissileLauncherIcon" };//图片资源的名字
//Scroll View组件动态生成的方法
private void OnBtnView()
{
for (int i=0;i<sprite_images.Length;i++)
{
GameObject tran = null;
if (i < Content.childCount )
{
tran = Content.GetChild (i).gameObject ;
}
else
{
tran = GameObject.Instantiate(Item).gameObject;
tran.transform.parent = Content;
}
滑动视图动态加载Scroll View组件
最新推荐文章于 2024-02-13 18:07:31 发布
本文介绍如何在Unity游戏开发中,利用C#脚本动态加载Scroll View组件的内容,提升用户体验并优化资源管理。
摘要由CSDN通过智能技术生成