1.GUI基础:
一.Label:
Label (position : Rect, text : string) : void
Label (position : Rect, image : Texture) : void
Label (position : Rect, content : GUIContent) : void
Label (position : Rect, text : string, style : GUIStyle) : void
Label (position : Rect, image : Texture, style : GUIStyle) : void
Label (position : Rect, content : GUIContent, style : GUIStyle) : void
public Texture2D img;
void OnGUI() {
GUI.Label(new Rect(10, 10, 100, 20), "Hello World!");
GUI.Label(new Rect(10,50,img.width,img.height),img);
}
二.Box
Box (position : Rect, text : string) : void
Box (position : Rect, image : Texture) : void
Box (position : Rect, content : GUIContent) : void
Box (position : Rect, text : string, style : GUIStyle) : void
Box (position : Rect, image : Texture, style : GUIStyle) : void
Box (position : Rect, content : GUIContent, style : GUIStyle) : void
public Texture2D img;
void OnGUI() {
GUI.Label(new Rect(10, 10, 100, 20), "Hello World!");
GUI.Label(new Rect(10,50,img.width,img.height),img);
}
2.泛型的概念
泛型是程序设计语言的一种特性。允许程序员在类型程序设计语言中编写代码时定义一些可变部分,那些部分在使用前必须作出指明。各种程序设计语言和其编译器,运行环境对泛型的支持均不一样将类型参数化达到代码复用提高软件工作效率的一种数据类型。泛型类是引用类型,是堆对象,主要是引入类型参数这个概念,字符串不是基本类型。
声明:此篇文档时来自于【狗刨学习网】社区-unity极致学院,是网友自行发布的Unity3D学习文章,如果有什么内容侵犯了你的相关权益,请与官方沟通,我们会即时处理。
3.集合的格式
[code] ArrayList
List 泛型
Arraylisa a:new ArrList ();
A.dd(object);
A.dd(“aaaa”);
A.dd(“bbbb”);
Foreach (string s in a){
}
a.Sort();
a.Remove(“cccc”);
a.Remove(0);
4.泛型的用法
List<string > a=new List<string >();
a.Add(“aa”);
A.add(“bb”);
Class Person{
Private int id;
Private strring name;
封装 }
}
Public void Get() {
List <Person> a= new List<Person>();
Person p1=new Person();
P1.Id=101;
P1.Name=”2ling”;
Person p2=new person();
P2.name=”c:”;
A.add(p1);
Q.add(p2);
}[/code]