我无法让自定义 GUIskin 工作
本文关键字:GUIskin 工作 自定义 | 更新日期: 2023-09-27 17:55:24
我有这个代码
using UnityEngine;
using System.Collections;
public class InfoInput : MonoBehaviour {
public string charname = "Name";
public string usrname = "User Name";
public string charrace = "Race";
public string charclass = "Class";
public string charalli = "LG";
public string next = "Next";
void OnGUI() {
int x = 500;
int y = 150;
int w = 260;
int h = 20;
int buffer = 6;
charname = GUI.TextField (new Rect (x, y, w, h), charname, 24, CustomGUI);
y = y + h + buffer;
usrname = GUI.TextField (new Rect (x, y, w, h), usrname, 24, CustomGUI);
y = y + h + buffer;
charrace = GUI.TextField (new Rect (x, y, w, h), charrace, 12, CustomGUI);
y = y + h + buffer;
charclass = GUI.TextField (new Rect (x, y, w, h), charclass, 20, CustomGUI);
y = y + h + buffer;
charalli = GUI.TextField (new Rect (x, y, w, h), charalli, 2, CustomGUI);
y = y + h + buffer;
GUI.Button (new Rect (x, y, w, y / 4), next, CustomGUI);
}
}
并且它不是从自定义 GUI 加载的.guiskin 我在这里缺少一些东西吗(手册没有告诉我如何使用它)当我运行脚本时,它返回一个错误,指出我的自定义 GUI 不是有效的引用
我没有看到您在上面的代码中在哪里声明了 GUI 皮肤。
using UnityEngine;
using System.Collections;
public class InfoInput : MonoBehaviour {
public string charname = "Name";
public string usrname = "User Name";
public string charrace = "Race";
public string charclass = "Class";
public string charalli = "LG";
public string next = "Next";
public GUISkin CustomGUI // Add the from the Inspector panel by drag and drop
void OnGUI() {
int x = 500;
int y = 150;
int w = 260;
int h = 20;
int buffer = 6;
charname = GUI.TextField (new Rect (x, y, w, h), charname, 24, CustomGUI);
y = y + h + buffer;
usrname = GUI.TextField (new Rect (x, y, w, h), usrname, 24, CustomGUI);
y = y + h + buffer;
charrace = GUI.TextField (new Rect (x, y, w, h), charrace, 12, CustomGUI);
y = y + h + buffer;
charclass = GUI.TextField (new Rect (x, y, w, h), charclass, 20, CustomGUI);
y = y + h + buffer;
charalli = GUI.TextField (new Rect (x, y, w, h), charalli, 2, CustomGUI);
y = y + h + buffer;
GUI.Button (new Rect (x, y, w, y / 4), next, CustomGUI);
}
}
如果尚未执行此操作,请右键单击"资产"选项卡,转到"Create>GuiSkin
",在"资产"文件夹中进行GUISkin
。然后,您可以将皮肤添加到其中,并将其拖到检查器面板以供使用。
希望对您有所帮助。