【发布时间】:2023-03-22 04:17:01
【问题描述】:
我是 Unity 和 NGUI 的新手,我不知道如何将自定义图集和精灵动态分配到按钮中。
using UnityEngine;
using System.Collections;
public class createButton : MonoBehaviour {
public createButton(){
GameObject newButton = new GameObject ();
newButton.name = "newButton" + 1;
//go.AddComponent<UISprite> ();
newButton.AddComponent<UIButton> ();
newButton.AddComponent<UISprite> ();
}
}
【问题讨论】:
-
您是否有理由动态执行此操作而不是实例化预制件?
-
Dan Puzey:我想用一个预制件动态创建不同的按钮,这会造成混乱吗?或者我现在做这件事太难了。
标签: c# button dynamic unity3d ngui