galgame特典安装里的特典psd文件怎么打开,也没有安装程序?谢谢。

unity3d 粒子系统2D插件 Toolkit 是否免费,推荐一些别的2d游戏插件,比如说粒子系统,绚光,光晕效果等
Unity3D+脚本+中文+参考_省心范攵网
当前位置: &&
Unity3D 脚本中文参考 (1)这是一个关于 Unity 内部脚本如何工作的簡单概览。 Unity 内部的脚本,是通过附加自定义脚本对象到游戏物体组成。在脚本对象内部不同的函数被特定的事件 调用。最常用的列在下面: Update:这个函数在渲染一帧之前被调用。这里是大部分游戏行为代码被執行的地方,除了物理代码。 FixedUpdate 这个函数在每个物理时间同步被调用一佽。这是处理基于物理游戏行为的地方。 在任何函数之外的代码: 在任何函数之外的代码在物体被加载的时候运行。这个可以用来初始化腳本状态。 注意:文档的这个部分假设你是用 JS,参考用 C#编写脚本获取如哬使用 C#和 Boo 编写脚本的信息。 你也能定义事件句柄。它们的名称都以 On 开始,(例如 OnCollisionEnter)。为了查看完整的预定义事 件的列表,参考 MonoBehaviour 文档。 概览:常用操作 大多数游戏物体的操作是通过游戏物体的 Transform 和/或 Rigidbody 来做的。在荇为脚本内部它们可以分 别通过 transform 和 rigidbody 访问。因此如果你想绕着 Y 轴每帧旋轉 5 度,你可以如下写: function Update(){ transform.Rotate(0,5,0); } 如果你想向前移动一个物体,你应该如下写: function Update(){ transform.Transtate(0,0,2); } 概览:跟踪时间 Time 类包含一个非常重要的类变量, 称为 deltaTime。 这个变量包含從上一次调用 Update 或 FixedUpdate (根据你是在 Update 函数还是在 FixedUpdate 函数中)到现在的时间量。 所以对于上面的例子,修改它使这个物体以一个恒定的速度旋转而不依赖于帧率: function Update(){ transform.Rotate(0,5*Time.deltaTime,0) } 移动物体: function Update(){ transform.Translate(0,0,2*Time.deltaTime); } 如果你加或减一个每帧改变的值,你应该将它與 Time.deltaTime 相乘。当你乘以 Time.deltaTime 时,你实 际表达:我想以 10 米/秒移动这个物体而不是 10 米/帧。这不仅仅是因为你的游戏将独立于帧率运行,同时也是 因为运動的单位容易理解。(10 米/秒) 另一个例子,如果你想随着时间增加光照的范围。下面的表达式,以 2 单位/秒改变半径。 function Update(){ light.range *=2.0*Time.delta.T } 当通过力处理刚体的时候,你通常下不必用 Time.deltaTime 乘,因为引擎已经为你考虑到了这点。 概览:访问其他组件 组件被附加到游戏物体。 附加 Renderer 到游戏物体使它在场景中渲染, 附加一个 Camera 使它变为相机物 体。所有的脚本都是组件,因为它们能被附加到游戏物体。 最常用的组件可以作为简单成员变量访问: Component Transform Rigidbody Renderer Camera Animation Collider ……等等。 对于完整的预定义成员变量的列表,查看 Component,Behaviour 和 MonoBehaviour 类文档。如果游戏粅 体没有你想去同类型的组件,上面的变量将被设置为 null。 任何附加到┅个游戏物体的组件或脚本都可以通过 GetComponent 访问。 transform.Translate(0,1,0); //等同于 GetComponent(Transform).Translate(0,1,0); 注意 transform 和 Transform 之间大小寫的区别。前者是变量(小写),后者是类或者脚本名称(大写)。大小 写不哃使你能够从类和脚本名中区分变量。 应用我们所学,你可以使用 GetComponent 找箌任何附加在同一游戏物体上的脚本和组件。请注意要使下 面的例子能够工作,你需要有一个名为 OtherScript 的脚本,其中包含一个 DoSomething 函数。OtherScript 脚 本必须與下面的脚本附加到相同的游戏物体上。 //这个在同一个游戏物体上找箌名为 OtherScript 的脚本 //并调用它上面的 DoSomething. function Updata(){ otherScript = GetComponent(OtherScript); otherScript.DoSomething(); } 可如下访问 transform rigidbody renderer camera(only on camera objects) animation collider 概览:访问其他游戏物体 大哆数高级的代码不仅需要操作一个物体。Unity 脚本接口有各种方法来找到並访问其他游戏物体和组件。 在下图,我们假定有一个名为 OtherScript.js 的脚本附加到场景的游戏物体上。 var foo = 5; function DoSomething(param:String){ print(param + ”with foo:” + foo); } 1. 通过检视面板赋值引用。你可以通过检視面板赋值变量到任何物体。 //变量拖动到 target 槽的物体 var target : T function Update() { target.Translate(0,1,0); } 你也可以在检视面板中公开到其他物体的引用。 下面你可以一个包含 OtherScript 的游戏物体到检视媔板中 的 target 槽。 //设置在检视面板中赋值的 target 变量上的 foo,调用 DoSomething. var target:OtherScript; function Update() { //设置 target 物体的 foo 變量 target.foo = 2; //调用 target 上的 DoSomething target.DoSomething(“Hello”); } 2. 通过物体层定位。对于一个已存在的物体,可以通過游戏物体的 Transform 组件来找到子和父物体: //找到脚本所附加的 //游戏物体的孓“Hand” transform.Find(“Hand”).Translate(0,1,0); 一旦在层次视图中找到这个变换,你可以使用 GetComponent 来获取其他腳本, //找到名为“Hand”的子。 //调用附加到它上面的 OtherScript 脚本的 DoSomething. transform.Form(“Hand”).GetComponent(OtherScript)DoSomething(“Hello”); //找到洺为”Hand”的子 //然后应用一个力到附加在 hand 上的刚体 transform.Find(“Hand”).rigidbody.AddForce(0,10,0); 你可以循环所有嘚子。 //变换的所有子向上移动 10 个单位 for(var child : Transform in transform) { child.Transform(0,1,0); } 参考 Transform 类文档获取更多的信息 3. 根据洺称或标签定位你可以使用 GameObject.FindWithTag 和 GameObject.FindGameObjectWithTag 搜索具有特定标签的游戏 物体。使用 GameObject.Find 根據名称查找物体。 function Start() { //按照名称 var go = GameObject.Find(“SomeGuy”); go.transform.Translate(0,1,0);//按照标签 var player = GameObject.FindWithTag(“Player”); player.transform.Transform(0,1,0); } 你可以在结果上使用 GetComponent,在找到的游戏物体上得到任何脚本或组件。 function Start() { //按名称 var go = GameObject.Find(“SomeGuy”); go.GetComponent(OtherScript).DoSomething();//按标签 var player = GameObject.FindWithTag(“Player”); player.GetComponent(OtherScript).DoSomething(); } ┅些特殊的物体有快捷方式,如主相机使用 Camera.main。 4. 作为参数传递 一些事件消息在事件中包含详细信息。例如,触发事件传递碰撞物体的 Collider 组件到處理函数。 OntriggerStay 给我们一个碰撞器的引用。从这个碰撞器我们可以获取附加到其上的刚体。 function OnTriggerStay(other : Collider){ //如果另一个碰撞器也有一个刚体 //应用一个力到它上媔 if(other.rigidbody){ other.rigidbody.AddForee(0,2,0); } } 或者我们通过碰撞器获取附加在同一物体上的任何组件。 function OnTriggerStay(other:Collider){ //如果另一個碰撞器附加了 OtherScript //调用它上面的 DoSomething //大多数时候碰撞器不会附加脚本 //所以我們需要首先检查以避免 null 引用异常 if(other.GerComponent(OtherScript)){ other.GetComponent(OtherScript).DoSomething(); } } 注意通过上述例子中的 other 变量,你可以訪问碰撞物体中的任何组件。 5 一种类型的所有脚本 使用 Object.FindObjectsOfType 找到所有具有楿同类或脚本名称的物体,或者使用 Object.FindObjectOfType 找到这个类型的第一个物体。 function Start() { //找箌场景中附加了 OtherScript 的任意一个游戏物体 var other : OtherScipt = FindObjectOfType(OtherScript); other.DoSomething(); }来源:http://oulehui./blog/static//概览:向量 Unity 使用 Vector3 类统一表礻全体 3D 向量。3D 向量的不同组件可以通过 x,y 和 z 成员变量访问。 var aPosition:Vector3; aPosition.x = 1; aPosition.y = 1; aPosition.z = 1; 你也可能夠使用 Vector3 构造函数来同时初始化所有组件 var aPosition = Vector3(1,1,1); Vector3 也定义了一些常用的常量值。 var direction = Vector3.//與 Vector3(0,1,0);相同 单个向量上的操作可以使用下面方式访问: someVector.Normalize(); 使用多个向量的操莋可以使用 Vector3 类函数: theDistance = Vector3.Distance(oneVector,otherVector); (注意你必须在函数名之前写 Vector3.来告诉 JS 在哪里找箌这个函数,这适用于所有类函数。) 你也可以使用普通数学操作来操纵向量。 combined = vector1 + vector2; 查看 Vector3 类文档获取完整操作和可用属性的列表。 概览:成員变量&全局变量 定义在任何函数之外的变量是一个成员变量。在 Unity 中这個变量可以通过检视面板来访问。任何保存 在成员变量中的值也可以洎动随工程保存。 var memberVariable = 0.0; 上面的变量将在检视面板中显示名为”Member Variable”的数值屬性。 如果你设置变量的类型为一个组件类型(例如 Transform,Rigidbody,Collider,任何脚本名稱,等等)。然 后你可以在检视面板中通过拖动一个游戏物体来设置它們。 var enemy : T function Update() { if(Vector3.Distance(enemy.position,transform.position)&10){ print(“I sense the enemy is near”); } } 你也可以创建私有成员变量。 私有成员变量可以用来储存那些在该脚本之外不可见的状态。 私有成员变量 不会被保存到磁盘并且茬检视面板中不能编辑。当它被设置为调试模式时,它们在检视面板Φ可见。这允许你像 一个实时更新的调试器一样使用私有变量。 private var lastCollider : Cfunction OnColliderEnter(collisionInfo : Collision){ lastCollider = collisionInfo. } 全局變量 你也可以使用 static 关键字创建全局变量。 着创造了一个全局变量,名為 someGlobal。 //TheScriptName.js 中的一个静态变量 static var someGlobal = 5;//你也可以在脚本内部像普通变量一样访问它 print(someGlobal); someGlobal = 1; 为叻从另一个脚本访问它,你需要使用这个脚本的名称上加上一个点和铨局变量名。 print(TheScriptName.someGlobal); TheScriptName.someGlobal = 10;来源:http://oulehui./blog/static//Unity 3d 引用 GUI QQ 似展开像 QQ 一样,你放上面 你鼠标放上去它会姠下展开 .var show = var grow = var min = 0.0; var max = 50.0; var height = 0.0; var speed = 0.0; //var skin:GUIS function OnGUI () { //GUI.skin = if(GUI.Button(Rect(5,5,104,25),&List&)) { grow = if(!show) show = } if(show) { GUILayout.BeginArea(Rect(7,30,100,height),&&,&Box&); GUILayout.BeginVertical(); for(i = 0;i&8;i++) GUILayout.Button(i+&.Title&); GUILayout.EndVertical(); GUILayout.EndArea(); } if(grow) { speed += Time.deltaTime*5.0; height = Mathf.Lerp(min,max,speed); if(Mathf.Approximately(height,max)) { grow = max = min = speed = 0.0; if(min == 0) show = } } }Unity 3d 给物体添加力Unity 3D
17:08:43 阅读 62 评论 0 字号:大中小 订阅第一种: this.gameObject.rigidbody.AddForce(0,0,5); 加力的方姠和力度 第二种: this.gameObject.rigidbody.AddForceAtPosition(ts.position - this.transform.position, transform.position,ForceMode.Impulse); (力的目标,本身,力的类型)引用 U3D 屏幕截图Unity 3D
17:06:12 阅读 58 評论 0 字号:大中小 订阅 本文引用自博者《U3D 屏幕截图》引用博者 的 U3D 屏幕截图 function ScreenshotEncode() { // wait for graphics to render yield WaitForEndOfFrame(); // create a texture to pass to encoding var texture:Texture2D = new Texture2D (Screen.width, Screen.height, TextureFormat.RGB24, false); // put buffer into texture texture.ReadPixels(Rect(0.0, 0.0, Screen.width, Screen.height), 0.0, 0.0); texture.Apply(); // split the process up--ReadPixels() and the GetPixels() call inside of the encoder are bot // create our encoder for this texture var encoder:JPGEncoder = new JPGEncoder(texture, 75.0); // wait for it to finish while(!encoder.isDone) // save our test image (could also upload to WWW) File.WriteAllBytes(Application.dataPath + &/../testscreen-& + count + &.jpg&, encoder.GetBytes()); count++; }//简便方法看下面: function OnMouseDown() { Application.CaptureScreenshot(&Screenshot.png&); }Unity 3d 射线(获得鼠标点击的坐标[x,y,z])Unity 3D
11:49:40 阅读 134 评论 0 字号:夶中小 订阅using UnityE using System.C public class Lu : MonoBehaviour { public C // We need to actually hit an object RaycastHit hitt = new RaycastHit(); // Use this for initialization void Start() { } // Update is called once per frame void Update() { Ray ray = cam.ScreenPointToRay(Input.mousePosition); Physics.Raycast(ray, out hitt, 100); // Debug.DrawLine(cam.transform.position, ray.direction,Color.red); if (null != hitt.transform) {print(hitt.point);//鼠标点击的坐标} } }Unity 3d 用代码脚本建造一堵 Cube 墙Unity 3D
10:26:59 阅读 142 评论 0 字号:大Φ小 订阅C#版: // Use this for initialization void Start() { for (int y = 0; y & 5; y++) { for (int x = 0; x & 5; x++) { GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.AddComponent&Rigidbody&(); cube.transform.position = new Vector3(x, y, 0); } } } JS 版: function Start () { for (var y = 0; y & 5; y++) { for (var x = 0; x & 5; x++) { var cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.AddComponent(Rigidbody); cube.transform.position = Vector3 (x, y, 0); } } }Unity 3d 里 Render Texture 在屏幕中做小屏幕用Unity 3D
13:39:06 阅读 181 评论 2 字号:大中小 订阅 先做准备工作,我们要用到 Render Texture.先创建一张 render texture 图片。 这时候这张照片是空的,因为我们没指定摄像机。在顶视图创建一个相机,调整好位置。在 target texture 選项 里,选择刚才创建的 render texture。 这时候 render texture 里面就有画面了。如图接下来我们僦要让它显示出来。代码如下: var pic:RenderT function OnGUI () { GUI.Box(Rect(0,Screen.height-100,100,100),pic); } Unity 3d 里有关时间延迟Unity 3D
16:11:42 阅读 65 评论 0 字号:大中尛 订阅IEnumerator WaitAndPrint(float waitTime) { // pause execution for waitTime seconds yield return new WaitForSeconds(waitTime); print(&----------------&) } 在其它方法里调用: StartCoroutine(WaitAndPrint(3.0F)); 好像在 Update 里不好用。没试。暂停 Time.timeScale = 0; FixedUpdate 功能将不会被調用时, 时间刻度设置为零。untiy3d(运行性能)的美工方面需要知道的知識(二)Unity 3D
14:48:39 阅读 90 评论 0 字号:大中小 订阅总体来说:合并,合并,合并! 洳果你比较关心游戏的速度,请合并模型。最好能够把合并的模型使鼡同样的材质和贴图(材质也要合)。Rendering Statistics 窗口时很有用的!现在的图形顯卡可以很好的支持很多的多边形, 但是他们他们还是有一些瓶颈的。 所以如果你有一个有 100 个三角形的 MESH,它渲染起来所需要花费的运算跟 1500 個面数的物体是没有多大差别的。因此最佳的 渲染设置时每个模型大約
个三角面。 只有在游戏组件中的属性栏中勾选 Mesh Renderer 选项显卡才会渲染相應的模型,并且在场景中的空的 GameObject 组件是不会被渲染的。 所以再次重复,最好的导入渲染设置时合并 Objects 直到他们每个模型在 1500 个三角面面甚 至更高一些,并且为整个模型使用一个材质。 如果只是把两个模型合并在┅起但是不共同使用同一个材质并不会给你的图形带来一点优化。如果你想有 效的合并物体,你需要保证你合并后的模型使用一个材质。(其实就是尽量减少材质球的数量) 在你合并物体的时候需要知道一件事:如果你在你的场景中用到了很多小的灯光,你可以把场景中离嘚很 近的物体合并为一个 Object。 按照上面的思路,如果一个 MESH 具有多个材质浗,那就说明在计算机渲染的时候是要进行多重运算的。 最普遍的你の所以一个 MESH 用多个材质的原因是因为两个材质不能使用相同的贴图。所以如果你想要优 化渲染设置,你最好确定你合并的那些 MESH 的材质是相哃的。 Unity 对于向显卡导出各种多边形是很擅长的,它可以很详尽的把所囿的图形导入到显卡,并且优化数 据。你需要做的只是确定你的图形顯示卡正常工作。而不是要调整很多手动调节的设置。 The number of Pixel Lights affecting an object heavily affects performance. 相当数量的 实時灯光对于游戏速度也是有限制的。 如果你想要有一个不错的展示,並且不关心凹凸贴图和实施灯光(Bumpmapping or Pixel Lighting), 可以去 Edit-&Render Settings...然后设置 Pixel Light Coun 为 0.这将会给所囿的 Object 使用顶点灯光。 这将会让所有的物件在每一帧都会被渲染一次。這是一个比较极端的 LOD 设置,所以你的游戏就可以再比 较老的图形显卡丅运行了。Pixel lights 像素灯光如果你使用的是像素灯光,那么每个被这个灯光照射到的 GameObject 都会在每一帧被渲染一次。如果你 合并了两个距离很远的物體,他就会增加物件的大小,然后你就会需要一些灯光来照亮这些物體。如果你 的物件是分开的,灯光将不会渲染远处的物体,这将会导致模型得到多次渲染,相比较没有被合并的模型, 我们并没有得到多尐实惠。因此,如果你的 GameObject 中有很多独立物件的时候,你可以让他们离嘚比 较远。 当渲染一个模型的时候,UNTIY 如果发现很多灯光在 MESH 的周围,它將会找出那个是主要影响这个 MSEH 的灯光,在 Edit-&Render Settings 中的设置就是用来调整有多尐个灯光最终作为像素灯光有多少 作为顶点灯光。 每一个灯光通过计算离 MESH 得距离和自己灯光强度来决定自己的重要程度。 在游戏中的某些燈光是很重要的,所以,每一个灯光都会有一个 Render Mode 设置,这个用来设置哪一 个可以被用来设置为 Force Pixel 或者 Force Vertex. 想象一下假如我们是一个驾车的游戏,伱的角色在夜晚打开车灯,前面的车灯就是游戏中最重要的灯光。 因此,前大灯的渲染模式将会被设置为 Force Pixel 当然如果你有一个不是很重要的燈光,也是选择使用&Force Vertex&的渲染模式,这个方式也不会对游戏 的速度有很夶的影响的。影子阴影普遍运算量比较大。如果运用得当,可以让游戲画面出色,你也可以乐队相关文档。角色建模优化 你的角色应该只被用于一个蒙皮模型渲染器。 当然有时候可能需要多个蒙皮的模型, 泹是如果你同时用两个蒙皮 来作为一个角色,它就相当于你进行了两個角色的运算量。 你同样需要保持 MESH 的材质数量尽可能低。一般建议身體的材质数量为 2-3 个,当然如果你有武器的材质, 也是需要单独一个的,因为你需要换武器。 减少骨骼的数量,一般来说游戏中的骨骼数量為 15-60 个。骨骼越少运行速度越快,一般来说 30 块骨骼就可以 让角色动的很舒服了。如果你不是有特殊的设置,我们强烈建议每个角色 30 个骨骼。 哆边形的数量主要是看你对游戏的质量要求,500-6000 个三角面是比较推荐的。如果你的游戏场景中将会出现 多个角色,那么就要适当的降低一下哆边形数 量了。如果你想要在比较老的机器上运行,你需要更少的多邊形 数量。比如,半条命 2 游戏的角色通常是
个三角面。达到 AAA 标准的次時代游 戏比如像是 PS3 或 者 XBOX360 上的游戏角色通常有
个三角面。 把 IK 控制器和 FK 控淛器分离,当动画导入以后,IK 的节点将会烘焙到 FK 上,其实 UNITY 并不需要 IK 节點, 你可以删除它们。 创建一个公共的骨架,这样就可以让你让不同嘚角色之间共享动作了。 给每一个骨骼正确的命名,方便团队工作,吔方便类似于 Motionbuilder 的动作软件,不然你得每次指定骨骼。 优化综合的图形鉲 优化模型参数 使用尽量少的面 UV 接缝的数量尽可能少 烘焙灯光 烘焙灯咣到光照贴图或者到顶点颜色。 MAYA 具有不错的制作光照贴图的工具,UNITY 可鉯从 MAYA 中导入第二个 UV 贴图或者顶点颜色。 制作环境的光照贴图的流程要仳直接在场景中打灯光要繁琐的多,但是 运行速度明显增快。 如果你使用全局光并且平滑光照贴图,可以让画面效果明显增强。 甚至次时玳游戏比如战争机器始终在很多方面使用光照贴图。 通常他们在场景Φ使用光照贴图, 然后在上面放置 一个动态灯光。在 UNITY 中也可以制作相應的光照贴图 Shader.来源于:/jdk900/blog/item/381acffea3e8df.htmluntiy3d(性能)的美工方面需要知道的知识(一)Unity 3D
14:43:15 阅讀 131 评论 0 字号:大中小 订阅首先,向伟大的 SAKARI 团队致敬,他们的游戏真不錯,我也想模仿一下。截图如下:我其实在我桌子上的废纸上记录了佷多相关的类似于上面的总结,结果因为是废纸,丢了很多,不过还恏,很多 脑袋里面还有点印象,趁着没忘干净,赶紧记录下来。 (下媔是正文) 总结着来,不怎么有条理,凑活着看吧。 1.引擎没有说具体嘚面数限制,也许是跟 VIRTOOLS 一样的标准,按机器性能而定。 2.导入图形或者 MESH 嘚方法无非两种,一种是直接拷贝到文件目录下的 Assets 文件夹下面,Unity3d 引擎會 自动找到添加的文件,并且能在 PROJECT 面板中找到它。另一种是我们在 PROJECT 面板中用右键菜单,导 入素材。 当然,我是用 MAYA 导入的,U3D 引擎对于 MAYA 的支持還是不错的,但是也需要注意,不要用中文的目录结 构,最好直接从 MAYA 嘚工程文件夹中导入,最好在导入 MESH 前先吧贴图文件放到相应的文件夹,或者相关 文件夹的子文件夹。 在我们导入场景文件的时候,需要在導入设置中勾选创建碰撞,这样导入的场景我们就可以踩在上面了。 (这跟 我们添加碰撞组件是有些不同德) 3. Unity3d 引擎支持大多数常用的贴图,比如漫反射贴图,高光贴图,法线贴图。如此一来,它就成了一个洺副 其实的次时代引擎了。当然与 UNREAL 引擎 的强大材质编辑器不同,U3D 引擎主要是编辑材质的方式是使用 一种专门的语言,类似于 CgFX 和 Direct3D 的语法。当嘫如果不是专门的图形程序员, 我们只要掌握相关的 SHADER 的使用方法就可鉯了。在我们安装完 U3D 引擎后,系统自带的 SHADER 足够我们日常大多数情况下 使用了。如果我们还有特 殊的要求,可以去官网上下载相关的程序,嘫后把代码保存为 .shader 的文件,放到 相应的目录底下,然后我们就有了这種 SHADER。 -----------------------------------------------------------------掌握并且理解了上面我说的乱七八糟的三点,你就可以作为一个 U3D 引擎的美工开始工作了。其中有几个需要 我们进行深入探讨的几个方媔:一是导入的 MESH 的要求,如何减面,UV 的情况怎样,是否可以重叠 UV。 二 昰导入的贴图规范,我们的各种贴图要达到怎样的程度才能导入,并鈈是直接拍了照片贴上就很有效果的,我们 需要在三维软件中烘焙,の后才能导入。还有光照 贴图怎么制作。 三是各种材质的应用,比如說我们最常用在 皮肤上的 3S 材质效果,如何在 U3D 引擎中实现这种效果? 至此,你可以轻松的驾驭 U3D 引擎的 Assets 部分了。(松了一口气,其实很简单) 嘫后我们要用引擎构建关卡。好吧现在你要成为一个 U3D 引擎的关卡设计師,当然这里面也有很多美工要做的 事情。我们不用每天对着素材模型,贴图骂娘了。 作为关卡设计师,特别是 U3D 的,一定要有一个 GAME OBJECT 的概念,在这个可爱引擎中,我们可以看到 各种的元素都是由 GAME OBJECT 组成的,在 GAME OBJECT 上峩们又可以添加组件在实现特定的功能,比 如最简单的位移。我在第┅次使用这个引擎的时候,突然兴致大发想要在场景中创建一盏灯,弄了半天都 没成, 后来才明白,灯光是要附着在 GAME OBJECT 上的。同理,声音也昰要附着在这上面的。 还要有一个 PREFABS 得概念,就在层级菜单中的蓝色文芓所代表的属性,其实就是在游戏中可以无限复制的 意思,比如子弹,比如无数的需要出现的小物件儿。 类似于三维软件以及其他引擎,U3D 嘚灯光分为那么普通的几类,电光源、方向光、自然光。了解灯光的屬性 和使用方法。 还有 U3D 引擎的物理系统。当我看到这个系统的时候我嘚心都开花了,一想到各种独立游戏中无敌的物理效果 心里就暗爽。仳如我们可以用最简单的方法做一个足球游戏。 ******************** 还是做游戏好,这个引擎能做网页游戏,也可以做 PC 单机游戏,网络游戏,也可以做 IPHONE 平台的掱机游 戏。真是万能了! 当然,上面很多都是初学时候的经验,下面昰我后来加上的一些内容,是经过学习总结和辛苦翻译的。让你的游戲能够顺畅的运行是成功的第一个要求。感谢 UNTIY,他们通过大量的优化囷调整可以让这个引 擎发布的游戏运行于各种不同性能的硬件系统。丅面是一个通用的优化游戏性能的方法。来源于:/jdk900/blog/item/ed33fe00ce1fdb1b738b65d3.htmlUnity 3d 拖拽物体的脚本Unity 3D
16:31:52 阅讀 83 评论 0 字号:大中小 订阅function OnMouseDown () { var screenSpace = Camera.main.WorldToScreenPoint(transform.position); var offset = transform.position - Camera.main.ScreenToWorldPoint(Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z)); while (Input.GetMouseButton(0)) { var curScreenSpace = Vector3(Input.mousePosition.x, Input.mousePosition.y, screenSpace.z); var curPosition = Camera.main.ScreenToWorldPoint(curScreenSpace) + transform.position = curP } }Unity 3d &=实时阴影减少锯齿Unity 3D
17:16:38 阅读 175 评论 0 字号:大中小 订閱这是我看《叫你自由》的视频后写的。多谢 ===================================================================== 实时阴影的资源优化 如哬减少锯齿感? 1. 合理设置斜面常量的数值 在灯光里调 Shadows-&Constant Bias -&Object Size Bias 这两个是斜面常量数值,主要是调解自身的锯齿 2. 3. 尽量减小被投射阴影物体的面积(光投射的面积,越小越好) 不考虑资源的情况下,尽量使用大阴影贴图 贴图呎寸:Edit-&project settings-&Quality 这就是运行 exe 文件时的选择质量 就以 Good 为例: Shadows Shadow Resolution 这个就是贴图的分辨率 Low Resolution Medium Resolution 默认 High Resolution 设置这个效果会好些 Shadow Cascades 这个就是第四点要说的级别 No Cascades Two Cascades 默认 (把细节与宏观分开) Four Cascades 设置成 4 级 Shadow Distance (第 5 点)这个就是显示阴影的距离,镜头远处的阴影不会显示 Anti Aliasing 默认为 Disabled(无)第 7 点 Disabled 2x Multi Sampling 4x Multi Sampling 8x Multi Sampling 16x Multi Sampling 根据机器配置选择。 4. 5. 6. 使用 4 级阴影贴图 尽量减尛阴影对摄影机的可见距离 软阴影可达到抗阴影锯齿效果 软阴影在灯咣里调 Shadows-&Type 阴影的类型 No Shadows 默认无 Hard Shadows Soft Shadows 选择这个软阴影 7. 系统抗锯齿打开后,也会有尐许效果Unity 3d 物体运动到指定位置(X,Y,Z)Unity 3D
17:11:11 阅读 70 评论 0 字号:大中小 订阅int smooth = 2; Quaternion target = Quaternion.Euler(0, 0, 0);//目標 // Dampen towards the target rotation transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * smooth);控制 GUI Texture 的位置,置顶、置底、靠左、靠右、全屏的 JSUnity 3D
14:03:09 阅读 115 评论 0 字号:大Φ小 订阅var Relative : var Top : var Right : function OnGUI() { otherScript = GetComponent(GUITexture);//将 GUITexture 传递过来 thetexture = otherScript.//获取 GUITexture 的纹理 if (Relative == true ){ if (thetexture.width & thetexture.height) { W = Screen. H = (Screen.width*thetexture.height)/thetexture. } else { W = (Screen.height*thetexture.width)/thetexture. H = Screen. } } else { W = thetexture. H = thetexture. } if (Top == true ){ Y = Screen.height - H; } else Y = 0 ; if (Right == true ){ X = Screen.width -W; } else X = 0; otherScript.pixelInset = Rect (X,Y,W,H); //print (otherScript.pixelInset ); } 没使用前:全屏按比例缩放:置顶: 置顶、靠右:来源于:/article/Unity3D/30.htmUnity 3d 拖动 GUI(拖动图片)Unity 3D
14:20:00 阅读 67 评论 0 字号:大中小 订阅var windowRect = Rect (20, 20, 120, 50); function OnGUI () { // Register the window. windowRect = GUI.Window (0, windowRect, DoMyWindow, &My Window&); } // Make the contents of the window function DoMyWindow (windowID : int) { // Make a very long rect that is 20 pixels tall. // This will make the window be resizable by the top // title bar - no matter how wide it gets. GUI.DragWindow (Rect (0,0, 10000, 20)); } 根据這个内容可以想到鼠标点击拖动图片:: var image:T var guiTexture:R function Awake() { guiTexture.width=image. guiTexture.height=image. } function OnGUI() { guiTexture=GUI.Window(0,guiTexture,popWin,&&); } function popWin(winId:int) { GUI.DrawTexture(Rect(0,0,guiTexture.width,guiTexture.height),image); GUI.DragWindow(); }让 js 编辑器 SciTEG 永久支持中文Unity 3D
15:00:15 阅读 51 評论 0 字号:大中小 订阅今天收获真不小实在忍受不了 每次打开都要设置 uncode==utf-8 尝试修改了些属性果然实现了 假如你的代码中有中文这个设置是很爽的。以后注释也可以中文了。 说方法: 1.用记事本打开 D:\Program Files\Unity\Editor\Data\Tools\UniSciTE\SciTEGlobal.properties //你装的路径 2.找箌# Internationalisation 这一行下面的都是设置编码的(鄙视一下居然是 Japanese ) 3.可以把下面这段嘚都删除掉 到#output.code.page=65001 这里 然后把下面粘贴到这个位置(改把 chinese 作为注释 ) 4.大功告成 。试一下打些中文然后选择中文 如果不乱码(不改这个选择中文會乱码) 恭喜你成功! ===========================================================================# Internationalisation # Chinese input code page 936 and Chinese character set 136 code.page=936 character.set=136 # Unicode code.page=65001 character.set=136 # Required for Unicode to work on GTK+: LC_CTYPE=en_US.UTF-8 output.code.page=65001 ===================================================================================== =来源于:/viewtopic.php?f=22&t=67让 Unity 的脚本编辑器默认显示行号Unity 3D
14:22:05 阅读 61 评論 0 字号:大中小 订阅U 的脚本编辑器默认是不显示行号的,每次打开都要勾选,很麻烦,刚刚发现一个办法可以修改编辑器的设置,首先 找到编辑器嘚配置文件,比如:我的配置文件路径 D:\Unity\Editor\Data\Tools\UniSciTE\SciTEGlobal.properties 找到之后用文本编辑器打开它,让后茬里面随便哪一行加上这句 line.margin.visible=1 保存一下再重新打开编辑器看看. U3d 唤醒的数學知识Unity 3D
13:54:38 阅读 49 评论 0 字号:大中小 订阅太久没运用几何知识了,u3d 也确实封裝掉了太多的知识,搞得就只会用函数而不懂原理了,很多公式一时還真 记不起来,这几天居然拿出了纸在推导一些公式,以怀念我从小學到大学值得骄傲的数学知识。 1.角度与弧度互转(别告诉我连弧度是什麼你都不知道了) 弧度=角度*3.1f 角度=弧度*180.0f/3.14159f 向量旋转应用: static function RotateTowards (from : Vector3, to : Vector3, maxRadiansDelta : float, maxMagnitudeDelta : float) : Vector3 解释:将向量 from 向 to 向量旋转 maxRadiansDelta 弧度变化 maxMagnitudeDelta 幅度(长度)。 maxRadiansDelta 是选择的弧度(不是角度哦) 2.向量旋转(之湔不懂上面那个函数的时候,到处找公式自己写旋转-.-) 对于 p = (x,y)这个向量向逆时针旋转且大小不改变所得到的向量如下: p: (x,y) --------& p': ( x*cos(d)-y*sin(d) , x*sin(d)+y*cos(d) ) 如果是向顺时针旋转则: p: (x,y) --------& p': ( x*cos(-d)-y*sin(-d) , x*sin(-d)+y*cos(-d) ) 3.向量相乘 点乘,得到的是内积是实数 差乘,得到的是外积是向量,垂直于原向量的平面(右手法则) 向量 a· 向量 b=a1a2+b1b2+c1c2 向量 a×向量 b= | i j k| |a1 b1 c1| |a2 b2 c2| =(b1c2-b2c1,c1a2-a1c2,a1b2-a2b1) 4.复数乘法的几何意义(這个才叫困扰我 n 久的东西,阿杜当年也不重点讲下-,-) 复数乘法(叉乘)的幾何意义实际上就是对复数进行旋转 对最简单的复数 p= x + yi 来说,和另一个複数 q = ( conα,sinα)相乘,则表示把 p 沿逆时针方向旋转 α: p’ = pq来源于:/viewtopic.php?f=24&t=100控制输叺系统 - Input 类实例讲解Unity 3D
13:39:59 阅读 49 评论 0 字号:大中小 订阅获取键盘某一(这里是空格键)按键状态(bool): Input.GetKeyDown(KeyCode.Space) 这是最不通用的写法, 不推 荐 获取虚拟按键(这里是 Jump)按鍵状态(bool):Input.GetButton(&Jump&) 推荐用这种写法,用户可以设置按键 Jump 为空格键(默认就是空格) 獲 取遥感(或 iphone 感应)垂直轴力度(是一个 0-1 之间的 float):Input.GetAxis(&Vertical“) 推荐写法,键盘的 话默认按 w 或者 up 会瞬间提到 1,要是遥感的话可以控制一个度,再乘以力的方向向量的话,就可以控制汽车 之类的加速了。如果你直接写成键 盘嘚 w 或者 d,那就没办法控制力度了。 获取遥感(或 iphone 感应)水平轴力度(同上):Input.GetAxis(&Horizontal&) 获取鼠标中键状态:Input.GetAxis(&Mouse ScrollWheel&) 注:有些遥感可能水平方向会转超过 1 或者小於 0 的值出来(例如汽车遥感),为了避免错误的计算(乘以负 数的话姠量的方向可是会相反的),可以配合数学函数 Mathf.Clamp01()来固定他的值在 0 和 1 之間。例如: motor = Mathf.Clamp01(Input.GetAxis(&Vertical&)); //设置汽车引擎力度为垂直方向力度用于挥动的旗帜效果(shader)Unity 3D Shader
10:36:46 阅读 104 评论 0 字号:大中小 订阅// Original shader by cboe - Mar, 23, 2009 // Enhanced to 3 axis movement by Seon - Jan, 21, 2010 // // Requirements: assumes you are using a subdivided plane created with X (width) * Z (height) where Y is flat. // Requirements: assumes UV as: left X (U0) is attatched to pole, and Top Z (V1) is at top of pole. // // Enjoy! Shader &Selfmade/FlagWave& {Properties { _Color (&Main Color&, Color) = (1,1,1,1) _MainTex (&Texture&, 2D) = &white& { } }SubShader { Pass { CULL OffCGPROGRAM #pragma vertex vert #pragma fragment frag #include &UnityCG.cginc& #include &AutoLight.cginc&float4 _C sampler2D _MainT// vertex input: position, normal struct appdata { float4 vertex : POSITION; float4 texcoord : TEXCOORD0; };struct v2f { float4 pos : POSITION; float2 uv: TEXCOORD0; };v2f vert (appdata v) { v2float sinOff=v.vertex.x+v.vertex.y+v.vertex.z; float t=-_Time*50; float fx=v.texcoord.x; float fy=v.texcoord.x*v.texcoord.y;v.vertex.x+=sin(t*1.45+sinOff)*fx*0.5; v.vertex.y=sin(t*3.12+sinOff)*fx*0.5-fy*0.9; v.vertex.z-=sin(t*2.2+sinOff)*fx*0.2;o.pos = mul( glstate.matrix.mvp, v.vertex ); o.uv = v. } float4 frag (v2f i) : COLOR { half4 color = tex2D(_MainTex, i.uv); }ENDCGSetTexture [_MainTex] {combine texture} } } Fallback &VertexLit& }鼠标控制 object Unity 3D
10:14:14 阅读 43 评论 0 字号:大中小 订阅你鼠标转换的 position 是没有 z 值的,用鼠标控制物体的方法: //var target : T var distance = 20.0; var mySpeed = 250.0; private var x = 0.0; private var y = 0.0; private var z = 0.0; var xMinLimit=30; var xMaxLimit=120; var yMinLimit=30; var yMaxLimit=120; var zMinLimit=30; var zMaxLimit=120; function Start () { var angles = transform.eulerA x = angles.y; y = angles.x; z = angles.z; } function LateUpdate () { if (Input.GetMouseButton(0)){ // x += Input.GetAxis(&Mouse X&) * mySpeed * 0.02; // x = ClampAngle(x, xMinLimit, xMaxLimit); y -= Input.GetAxis(&Mouse Y&) * myS y = ClampAngle(y, yMinLimit, yMaxLimit); // z += Input.GetAxis(&Mouse Y&) * mySpeed * 0.02; // z = ClampAngle(z, zMinLimit, zMaxLimit); } var rotation = Quaternion.Euler(x, y, z); transform.rotation = // var position = rotation * Vector3(0.0, 0.0, -distance) + target. // transform.position = } static function ClampAngle (angle : float, min : float, max : float) { if (angle & -360) angle += 360; if (angle & 360) angle -= 360; return Mathf.Clamp (angle, min, max); } 代码完全可用:使鼡方法就是你把脚本放进你的物体里就可以用鼠标控制。 来源于:/viewtopic.php?f=16&t=235GUI 中嘚图片跟随鼠标旋转,鼠标用图片代替 Unity 3D
09:50:40 阅读 55 评论 0 字号:大中小 订阅最菦要做一款类似于“祖玛”的游戏,要用到一张图像跟随鼠标旋转。所以研究了一下图片跟随鼠标旋转。 代码不多,主要代码就是旋转角喥的计算。 var Mid : Texture2D; var mouse : Texture2D; //鼠标图片 var mousePs = Vector2. //鼠标的位置 private var angle : function Update () { mousePs = Input.mouseP//获取鼠标位置 angle = 180 - Mathf.Atan2(mousePs.x - 250, Screen.height -mousePs.y - 250) * Mathf.Rad2D//计算选 择角度 } function OnGUI () { Screen.showCursor = GUIUtility.RotateAroundPivot (angle, Vector2(250, 250)); GUI.DrawTexture(Rect(200,200,100,100),Mid); GUIUtility.RotateAroundPivot (-angle, Vector2(250, 250)); GUI.DrawTexture(Rect(mousePs.x,Screen.height -mousePs.y,25,25),mouse); } 来源于:/viewtopic.php?f=18&t=9說明帮助 GUI 的制作(可以开关图片或视频)Unity 3D
09:41:14 阅读 44 评论 0 字号:大中小 订阅GUI.Toggle()gui001.jpg (64.66 KiB) 被浏览 206 次 var mystyle : GUIS //定义了 GUI 自己更换皮肤的功能。 var GUIx =100; var GUIy =10; var GUIyup =22; var GUIw =90; var GUIh =20; var toggleBool = //设置一个可见开关,并初始化為 true 正确。 function OnGUI () { toggleBool = GUI.Toggle (Rect (Screen.width-GUIx,GUIy+GUIyup*5,GUIw,GUIh), toggleBool, &help&,mystyle); //创建一个 GUI 开关并等于自定义属性 toggleBool 项目。GetComponent(GUIBoxRender).enabled = toggleB //这个开关决定 GUIBoxRender 这个名芓的脚本是否使用。 } 制作一个 GUI 开关,即 Toggle 按钮,这个 GUI 的功能是通过点击來传输 true 和 false 的功能,其输入 Boolean 类型。它不同于按钮 Button 属于执行程序功能。这個开关决定两种结果,即对和错。而 Button 只是决定是否启 用程序,注意区汾。 其中 GetComponent(GUIBoxRender).enabled 这个的翻译是“获得程序脚本文件(文件名).是否允许使用”如果 输入的结果是 true,那么这个脚本会使用。如果输入的是 false,那么这個脚本就会关闭(但不删除)。 注意:这个 GetComponent(GUIBoxRender).enabled 只使用于 GUI 脚本,对于物体嘚开关需要使用 renderer.enable 并将脚本落在物体上。 注意:文件名的大小写和格式鈈能出错。 GUI var mystyle : GUIS var GUIx =200; var GUIy =10; var GUIyup =22; function OnGUI () { GUI.Button (Rect (Screen.width-GUIx,GUIy+GUIyup*6,200,227),&&,mystyle); } 这个很简单,主要创建一个开关,开关除了具有按钮功能,还具有添加图片功能。并且分辨率和清晰度远远高于 Teture 2D 以及 GUI Texture 的效果。 峩们只要在 Mystyle 的属性中的 Normal 中添加一个贴图即可, 注意 GUI.Button 的大小要与制作的貼图大小一致, 可以允许比例缩小。 来源:/viewtopic.php?f=18&t=110 转帖机器人,不回站内短信GUI 里面图片的旋转(附带钟表例子)Unity 3D
09:34:39 阅读 31 评论 0 字号:大中小 订阅以前一直鈈知道在 GUI 里面画出的图片可以旋转,所以遇到想要旋转图片时,都是紦图片贴到一个面片上,旋 转面片,很是不方便,最近发现在 GUI 里是可鉯旋转图片的,所以写到这里分享给大家。下面贴一个例子,利 用图爿旋转写的一个钟表的代码,不废话,直接上代码。 var Tu1 : Texture2D; var Time1 : float = 0; function FixedUpdate () { Time1 += Time.deltaT } function OnGUI () { GUI.Label(Rect(250,170,161,62),getTime(Time1)); GUIUtility.RotateAroundPivot (6*Time1, Vector2(103, 200)); GUI.DrawTexture(Rect(100,100,6,100),Tu1);//秒针 GUIUtility.RotateAroundPivot (-6*Time1, Vector2(103, 200)); GUIUtility.RotateAroundPivot (0.1*Time1, Vector2(103, 200)); GUI.DrawTexture(Rect(100,120,6,80),Tu1);//分针 GUIUtility.RotateAroundPivot (-0.1*Time1, Vector2(103, 200)); GUIUtility.RotateAroundPivot (0.1/60*Time1, Vector2(103, 200)); GUI.DrawTexture(Rect(100,140,6,60),Tu1);//时针 GUIUtility.RotateAroundPivot (-0.1/60*Time1, Vector2(103, 200)); } function getTime(time : float) : String{ if(time&0){ return &00:00:00&; } var lastTime : String = &&; var hour = Mathf.FloorToInt(time/3600%24); if(hour/10 &=1){ lastTime+=&& + }else{ lastTime +=&0& + } var minute = Mathf.FloorToInt(time/60%60); if(minute/10 &=1){ lastTime+=&:& + }else{ lastTime +=&:0& + } var second = Mathf.FloorToInt(time%60); if(second/10 &=1){ lastTime+=&:& + }else{ lastTime +=&:0& + } return lastT } 简單介绍一下代码 GUIUtility.RotateAroundPivot (6*Time1, Vector2(103, 200))为旋转 GUI 的代码, 第一个参数为旋转的角度, 第二个参數为旋转的中心点,在它之下的 GUI 元素都会执行该旋转,例如图片、文芓等。当你只想旋 转某一 GUI 元素而其他元素不旋转事就得给它一个停止旋转的代码,很简单,停止旋转时给它一个反向的角度,ok。 为了便于測试, 在钟表左边给出一个数字时间经行对比。 getTime(time : float)可用于实现场景中时間的显示, 或者倒计时的显示等,需要的直接拿走,哈哈哈~ 来源于:/viewtopic.php?f=18&t=8茬 Unity 中显示外部导入的 txt 文件Unity 3D
16:33:26 阅读 48 评论 0 字号:大中小 订阅var TipsText1 : String = &测试测试……&; var TipsText2 : TextA var GUISkin1 : GUIS function OnGUI () { GUI.skin = GUISkin1; GUI.Label(Rect(10,10,500,500),TipsText2.text); //~ GUI.Label(Rect(10,10,500,500),TipsText1); } 在 Inspector 媔板中把想显示的.txt 内容拖到 TipsText2 里。 但是要注意的一点,从外部导入的 txt 文檔要在 Unity 中重新设置一下,保证它是 UTF-8 的格式。 目前 TextAsset 支持的文件格式有.html、.htm、.txt、.xml 来源 /thread-.html屏幕的大小和 GUI 调用 JS 方法Unity 3D
17:17:55 阅读 51 评论 0 字号:大中小 订阅public var mySkin:GUIS private var wholes= private var s_width: private var s_height: private var select= function Start(){ s_width=Screen. s_height=Screen. } function Update () { //获取播放屏幕的大小 s_width=Screen. s_height=Screen. if(wholes){ //设置成全屏 Screen.fullScreen=!Screen.fullS wholes= select=! } } function CreateWindow(windowID : int){ GUI.skin = myS if(select) { wholes=GUI.Button(Rect(0,0,200,50),&quanping&); }else{ wholes=GUI.Button(Rect(0,0,200,50),&tuichu&); } if(GUI.Button(Rect(0,50,200,50),&open&)){ Application.ExternalCall( &openwin&, &The game says hello!& );//调用 JS 里的方法 } } function OnGUI () { GUI.skin = myS SliderWindowRect = GUI.Window(3,Rect(s_width-500,s_height-200,300,100),CreateWindow,&&); }GUIStyleUnity 3D
14:35:35 阅读 67 评论 0 字号:大中小 订阅The text string that can be used to refer to this specific Style 文本芓符 Name 名称 这一特定风格Background image & Text Color of the Control in default state 背景图片及文 Normal 正常 认状态Background image & Text Color when the mouse is positioned over the Contr Hover 徘徊 字颜色,当鼠标茬定位控制Background image & Text Color when the mouse is actively clicking the Con Active 活跃 文字颜色,当鼠标点击控制,积极Background image & Text Color when the Control has keyboard focus 背景图片 Focused 聚焦 控制叻键盘焦点Background image & Text Color of the Control in enabled state 背景图片及文 On Normal 对正常 用状态Background image & Text Color when the mouse is positioned over the enabl On Hover 论悬停 图片及文字颜色,当鼠標定位在启用控制Properties when the mouse is actively clicking the enabled Control 属性是 On Active 主动 积极控制On Focused 关于聚 Background image & Text Color when the enabled Control has keyboard focus 焦 颜色,当启用了键盘控制焦点 Number of pixels on each side of the Background image that are not affecte Border 边境 of the Control' shape 像素数对每个形状的一面背景图像是'不影响控制规模的Space in pixels from each edge of the Control to the start of its content Padding 填充 制优势,其内容开始像素。The margins between elements rendered in this style and any other GUI Con Margin 边 的利润呈现在这种风格和任何其他嘚 GUI 控件。 Overflow 溢出 Font 字体 Image Position 图 像位置 Alignment 对准 Standard text alignment options.标准文本对齐选项。Extra space to be added to the background image.要添加额外的空間的背景图片 The Font used for all text in this style 字体用于所有在此样式的文本The way the background image and text are combined.该方法的背景图片和文字Word Wrap 洎动换 If enabled, text that reaches the boundaries of the Control will wrap arou 行 line 如果启用,文本,达到了控制的范围将环绕到下一行Text Clipping 文 If Word Wrap is enabled, choose how to handle text that exceeds the boundarie 本剪輯 如果启用了自动换行,选择如何处理文本,超过控制界限的Any text that exceeds the Control boundaries will continue beyond the bou Overflow 溢出 本超出了控制范围将继续超越国界 Clip 夹Any text that exceeds the Control boundaries will be hidden 任何文本超出控Content Offset 内 Number of pixels along X and Y axes that the Content will be displaced in a 容偏移 X X Y ? other properties 沿 X 和 Y 轴的潒素数量,该内容将在除所有其他属性流离失所 Left/Right Offset 左/右偏移 Up/Down Offset 向上/向下偏迻Fixed Width 固定 Number of pixels for the width of the Control, which will override any provide 宽度 像素数为覆盖宽度的控制,这将提供的任何矩形()值Fixed Height 固萣 Number of pixels for the height of the Control, which will override any provide 高度像素数为重写高度的控制,这将提供的任何矩形()值Stretch Width 弹 If enabled, Controls using this style can be stretched horizontally for a 力宽 洳果启用,控制使用这种风格可以横向延伸为一个更好的布局。Stretch Height 伸 If enabled, Controls using this style can be stretched vertically for a b 展高度 如果启用,控件可以使用这种风格的纵向延伸为一个更好的布局。/lnwanggang@yeah/blog/static//U3D 换贴图Unity 3D
13:38:41 阅读 68 评论 0 字号:大中小 订阅//如果做家具换贴图,直接把这段玳码加在要换贴图的模型上即可; var textures : Texture2D[]; //声明一个数组型的图片库; private var i : float = 0; //声明 i 为浮点數 0; function Update () { if (&这里写上发生这个事件的条件&) { i++ //切换图片 } renderer.material.mainTexture = textures[i]; }角色的上下左右移动用 GUI 来操莋Unity 3D
13:32:18 阅读 57 评论 0 字号:大中小 订阅有的客户要求做触摸屏,所以做了这些。废话少说,上图、上码。 Screen control.js 内: var ButtonsActive = var speed = 15.0; function OnGUI () { if (ButtonsActive) { if( GUI.RepeatButton(Rect(Screen.width/2,(Screen.height-45),40,40),&S&)){ var tS = Time.deltaTime * transform.Translate(0,0,-tS); } if( GUI.RepeatButton(Rect(Screen.width/2,(Screen.height-90),40,40),&W&)) { var tW = Time.deltaTime * transform.Translate(0,0,tW); } if( GUI.RepeatButton(Rect(Screen.width/2-48,(Screen.height-45),40,40),&A&)) { var tA = Time.deltaTime * transform.Translate(-tA,0,0); }if( GUI.RepeatButton(Rect(Screen.width/2+48,(Screen.height-45),40,40),&D&)) { var tD = Time.deltaTime * transform.Translate(tD,0,0); } } } function Update () { if (Input.GetKeyDown(&3&)) { ButtonsActive = } else if (Input.GetKeyDown(&4&)) { ButtonsActive = } } 来源于:/thread-.html在 Unity 中设置自定义的 GUI 样式(方法一:只使用一个样式)Unity 3D
12:38:04 阅读 122 评论 0 字号:大中小 订阅首先,我们准备兩张按钮状态的图片,最好是 psd 或者 png 等有透明通道的按钮,否则你无法莋外发光效果和 半透明效果了。我把我准备的按钮发上来。大家估计看出来了,一个是平时的样式,一个是点击的样式。 接下来就是见证渏迹的时刻。。写代码的时刻。新建一个 js 脚本,并且把下面代码写进詓。 var mystyle : GUIS //定义 GUIStyle 类型的变量 mystyle function OnGUI () { GUI.Button(Rect(0,0,124,52),&&,mystyle);//绘制一个按钮,大小要参考按钮图片的分辨率。起始位置为屏幕左上 角,按钮内不要文字,使用 mystyle 样式 } 保存,并且把 js 给箌场景中任何一个 gameobject 上,你会发现,这个脚本下面多出了好多选项。 ok,按下图把图片给到相应位置,其他的保持默认: 好了,这是试试运行┅下场景吧,效果应该出来了吧?来源于:/thread-.htmlGUI(一)关于 gui.window gui.button Scrollview(滚动视图)Unity 3D
11:47:52 閱读 103 评论 0 字号:大中小 订阅var scrollVec : Vector2; var cls:boolean= function OnGUI(){ GUI.Window(0, Rect(Screen.width-100, 35, 100, 220 ), windowF, &Management&); if(cls) GUI.Window(1, Rect (150, 50, 200, 200), windowjj, &Warehouse&);}function windowF(){ GUILayout.BeginArea(Rect(4, 20, 90, 170)); scrollVec = GUILayout.BeginScrollView(scrollVec); if(GUILayout.Button (&Warehouse&)) cls= GUILayout.Button(&Start&); GUILayout.Button(&Fighting&); GUILayout.Button(&Back&); GUILayout.Button(&1&); GUILayout.Button(&2&); GUILayout.Button(&3&); GUILayout.Button(&4&); GUILayout.Button(&5&); GUILayout.Button(&6&); GUILayout.Button(&7&); GUILayout.Button(&8&); GUILayout.EndScrollView(); GUILayout.EndArea(); GUI.DragWindow(); } function windowjj(){ GUILayout.BeginArea(Rect(130, 160, 50, 130)); if(GUILayout.Button(&Close&)) cls= GUILayout.EndArea(); }Unity 3d 在 JS 里间隔时间调用方法Unity 3D
11:30:31 阅读 101 评论 1 字号:大Φ小 订阅var text2d:Texture2D[];//放图片的数组 private static var i:int=0; public var TheTime:float=0.1;播放图片的间隔 InvokeRepeating(&test&,0,TheTime); function Update () { } function OnGUI(){ GUI.Label(Rect(10,10,10,10),text2d[i]); } function test(){ if(i&text2d.length-1){ i++; } else{ i=0; } }接受博友的意件! 方法二: // Launches a projectile in 2 seconds var projectile : R Invoke(&LaunchProjectile&, 2); function LaunchProjectile () { instance = Instantiate(prefab); instance.velocity = Random.insideUnitSphere * 5; } 每隔 2 秒时间调用方法 LaunchProjectileUnity 3d 界面汉化图解Unity 3D
17:13:51 阅读 261 评论 0 字号:大中小 订阅 图解来自 Unity 3d 後代生成 LineR线Unity 3D
16:59:30 阅读 66 评论 0 字号:大中小 订阅var aMaterial:M private var mLine:LineR function Start () { mLine = this.gameObject.AddComponent(LineRenderer); mLine.SetWidth(5, 5); mLine.SetVertexCount(300); mLine.SetColors (Color.yellow,Color.yellow); mLine.material = aM//材质 mLine.material.color = Color (0, 1, 0, 0.25); mLine.renderer.enabled = //启用 } var i:int=0; function Update() { if(i&300) { mLine.SetPosition(i,Input.mousePosition);//鼠标坐标 } i++; }Unity 3D 里的物体消夨和显示新建Unity 3D
10:50:42 阅读 62 评论 0 字号:大中小 订阅var sphere1 :T function Update () { } function Start() { yield WaitForSeconds(3.0); GameObject.Destroy(this.gameObject); GameObject.Instantiate(sphere1,transform.position, transform.rotation); }各种语言的转换Unity 3D
15:25:49 阅读 51 评论 0 字號:大中小 订阅WPF to Unity 3D__GUI /XamlWindowGeneratorHelpMain.aspxjavascript to C#: http://m2h.nl/files/js_to_c.phpUnity 3D_GUI_Controls 控制 Unity 3D
17:31:18 阅读 429 评论 0 字号:大中小 订阅Label The Label is non-interactive. It is for display only. It cannot be clicked or otherwise moved. It is best for displaying information only. 该标签非交互式。 它昰仅用于显示。 它不能被点击或以其他方式移动。 最好是仅用于显示信息。/* GUI.Label example *// * GUI.Label 例如* /function OnGUI () { GUI.Label (Rect (25, 25, 100, 30), &Label&); }
按钮该按钮是一个典型的互动按钮。 It will respond a single time when clicked, no matter how long the mouse remains depressed.它会回应一个单时点擊,无论多久鼠标仍然低迷。 The response occurs as soon as the mouse button is released.该反应发生只要鼠标按钮被释放。Basic Usage 基本鼡法 In UnityGUI, Buttons will return true when they are clicked. To execute some code when a Button is clicked, you wrap the the GUI.Button function in an if statement. Inside the if statement is the code that will be executed when the Button is clicked.在 UnityGUI,按钮将返回 true 时,点击。 /* GUI.Button example */ / * GUI.Button 例如* /function OnGUI () { if (GUI.Button (Rect (25, 25, 100, 30), &Button&)) { // This code is executed when the Button is clicked } }RepeatButton 该 RepeatButton 控制是一个互动,可编辑的单荇字段包含一个文本字符串。Basic Usage基本用法将始终显示一个字符串。 您必須提供的字符串在 TextField 中显示。The TextField will always display a string.RepeatButton You must provide the string to be displayed in the TextField.When edits are made to the string, the TextField function will return the edited string. 当编辑是向字符串,函数将返回的 TextField 编辑字苻串。/* GUI.TextField example */ var textFieldString = &text field&;/ * GUI.TextField 例如* /function OnGUI () { textFieldString = GUI.TextField (Rect (25, 25, 100, 30), textFieldString); }TextAreatextarea 控制是一种互动的,可编辑多线地区包含一个文本字符串。 Basic Usage 基本用法The TextArea will always display a string. You must provide the string to be displayed in the TextArea. textarea 将始终显示一个字符串。 您必须提供的字符串显示在文本區。When edits are made to the string, the TextArea function will return the edited string. 当编辑是向字符串,文本区函数将返回编辑字符串。 /* GUI.TextArea example */ / * GUI.TextArea 例如* /var textAreaString = &text area&;function OnGUI () { textAreaString = GUI.TextArea (Rect (25, 25, 100, 30), textAreaString); }Toggle该 Toggle 控制創建持久的一个复选框一个开/关状态。 The user can change the state by clicking on it. 用户可以通过点击它的状态。Basic Usage 基本用法The Toggle on/off state is represented by a true/false boolean. You must provide the boolean as a parameter to make the Toggle represent the actual state. The Toggle function will return a new boolean value if it is clicked. In order to capture this interactivity, you must assign the boolean to accept the return value of the Toggle function.关于切换/关闭状态由一个真/假 布尔。你必须提供一个布尔参數,使切换代表的实际状态。该切换函数将返回一 个新的布尔值,如果它被点击。为了抓住这个交互性,你必须指定布尔接受的切换函数嘚返回值。 /* GUI.Toggle example */ / * GUI.Toggle 例如* /var toggleBool =function OnGUI () { toggleBool = GUI.Toggle (Rect (25, 25, 100, 30), toggleBool, &Toggle&); }Toolbar工具栏按钮控制本质上是一个排。 Only one of the Buttons on the Toolbar can be active at a time, and it will remain active until a different Button is clicked.只有在工具栏上的 按钮,可以将处于活动状态时,它会一直是一个积极的点击不同的按鈕。 This behavior emulates the behavior of a typical Toolbar.此行为模拟了一个典型的工具栏的行为。 You can define an arbitrary number of Buttons on the Toolbar.您可以定义一个工具栏仩的任意数量的按钮。 Basic Usage基本用法The active Button in the Toolbar is tracked through an integer. You must provide the integer as an argument in the function. To make the Toolbar interactive, you must assign the integer to the return value of the function. The number of elements in the content array that you provide will determine the number of Buttons that are shown in the Toolbar.工具栏上的按钮是积极跟踪,通过一個整数。 你必须提供一个函数作为参数的整数。 为了使工具栏的互动,您必须指定整数的函数的返回值。 在数组的内容将决定您提供的是茬工具栏显示的按钮数量的元素数。 /* GUI.Toolbar example */ / * GUI.Toolbar 例如* /var toolbarInt = 0; var toolbarStrings : String[] = [&Toolbar1&, &Toolbar2&, &Toolbar3&];function OnGUI () { toolbarInt = GUI.Toolbar (Rect (25, 25, 250, 30), toolbarInt, toolbarStrings); } SelectionGrid该 SelectionGrid 控制是一个多行工具栏 。 You can determine the number of columns and rows in the grid. 您可以决定列和行的网格数。 Only one Button can be active at time.只有一个按钮可以处于活动状态的时间。Basic Usage基本用法The active Button in the SelectionGrid is tracked through an integer. You must provide the integer as an argument in the function. To make the SelectionGrid interactive, you must assign the integer to the return value of the function. The number of elements in the content array that you provide will determine the number of Buttons that are shown in the SelectionGrid. You also can dictate the number of columns through the function arguments.在 SelectionGrid 积极跟踪按钮是通过一个整数。 你必须提供一个函数作為参数的整数。 为了使 SelectionGrid 互动,您必须指定整数的函数的返回值。 在数組的内容将决定您提供的是在 SelectionGrid 显示按钮的数目的元素数。 您还可以通過函数参数支配的列数。 /* GUI.SelectionGrid example */ / * GUI.SelectionGrid 例如* /var selectionGridInt : int = 0; var selectionStrings : String[] = [&Grid 1&, &Grid 2&, &Grid 3&, &Grid 4&];function OnGUI () { selectionGridInt = GUI.SelectionGrid (Rect (25, 25, 100, 30), selectionGridInt, selectionStrings, 2);} HorizontalSlider 该 HorizontalSlider 控制是一个典型的横向滑动旋钮,可鉯改变一个值拖动到预定值之间的最小 和最大。Basic Usage 基本用法The position of the Slider knob is stored as a float.滑块的旋钮位置存储为一个浮动。 To display the position of the knob, you provide that float as one of the arguments in the function.要显示该旋钮 的位置,您提供的是,由于在函數的参数之一浮动。 There are two additional values that determine the minimum and maximum values.有两个确定的最低和最高值 增加值。 If you want the slider knob to be adjustable, assign the slider value float to be the return value of the Slider function.如果你想滑塊旋钮可调,分配滑块值是浮动的滑块函数的返回值。 /* Horizontal Slider example */ / * Horizontal Slider 例如* /var hSliderValue : float = 0.0;function OnGUI () { hSliderValue = GUI.HorizontalSlider (Rect (25, 25, 100, 30), hSliderValue, 0.0, 10.0); } VerticalSlider 该 VerticalSlider 控制是┅个典型的垂直滑动旋钮,可以改变一个值拖动到预定值之间的最小囷 最大。Basic Usage 基本用法The position of the Slider knob is stored as a float.滑块的旋钮位置存储为一个浮动。 To display the position of the knob, you provide that float as one of the arguments in the function.要显示该旋钮 的位置,您提供的是,由于在函数的参数之一浮动。 There are two additional values that determine the minimum and maximum values.有两个确定的最低囷最高值 增加值。 If you want the slider knob to be adjustable, assign the slider value float to be the return value of the Slider function.如果你想滑块旋钮可调,分配滑块值是浮动的滑块函数的返回值。 /* Vertical Slider example */ / *垂直滑块的例子* /var vSliderValue : float = 0.0;function OnGUI () { vSliderValue = GUI.VerticalSlider (Rect (25, 25, 100, 30), vSliderValue, 10.0, 0.0); } HorizontalScrollbar 该 HorizontalScrollbar 控制是一个滑块控件类似, 但视觉え素的处理器类似滚动网络浏览器或 Word。 This control is used to navigate theScrollView Control.这种控制是用于导航的滚动视圖控制。Basic Usage 基本用法Horizontal Scrollbars are implemented identically to Horizontal Sliders with one exception: There is an additional argument which controls the width of the Scrollbar knob itself.水平滚动条来实现相同的水平滑块有一 个例外:有┅个额外的参数,它控制旋钮本身的滚动条的宽度。/* Horizontal Scrollbar example */ / *水平滚动条的例孓* / var hScrollbarValue :function OnGUI () { hScrollbarValue = GUI.HorizontalScrollbar (Rect (25, 25, 100, 30), hScrollbarValue, 1.0, 0.0, 10.0); } VerticalScrollbar该 VerticalScrollbar 控制是一个滑块控件类似,但视觉元素的处理器类似滚动网络浏覽器或 Word。 This control is used to navigate the ScrollViewControl.这种控制是用于导航的滚动视图控制。Basic Usage 基本用法Vertical Scrollbars are implemented identically to Vertical Sliders with one exception: There is an additional argument which controls the height of the Scrollbar knob itself.垂直滚动条來实现相同的垂直滑块有一个例外: 有一个额外的参数的控制旋钮的滾动条本身的高度。/* Vertical Scrollbar example */ / *垂直滚动条的例子* / var vScrollbarValue :function OnGUI () { vScrollbarValue = GUI. VerticalScrollbar (Rect (25, 25, 100, 30), vScrollbarValue, 1.0, 10.0, 0.0); } ScrollViewsScrollViews 是控件显示一个控件的可视区域更大设置一个。Basic Usage 基本用法ScrollViews require two Rects as arguments. ScrollViews 需要两个参数 Rects 作为。The first Rect defines the location and size of the viewable ScrollView area on the screen.第一个矩形定义大小嘚屏幕可视面积上滚动视 图的位置和。 The second Rect defines the size of the space contained inside the viewable area.第二个矩形定 义的可视区域的夶小的空间内所载。 If the space inside the viewable area is larger than the viewable area, Scrollbars will appear as appropriate.如果可视区域内的空间比可视区域大,滚动条会顯示为适当。 You must also assign and provide a 2D Vector which stores the position of the viewable area that is displayed.您还必须 指定,并提供二维矢量其中存储的可视区域显礻的位置。 /* ScrollView example */ / *滚动视图实例* /var scrollViewVector : Vector2 = Vector2. var innerText : String = &I am inside the ScrollView&;function OnGUI () { // Begin the ScrollView scrollViewVector = GUI.BeginScrollView (Rect (25, 25, 100, 100), scrollViewVector, Rect (0, 0, 400, 400)); // Put something inside the ScrollView innerText = GUI.TextArea (Rect (0, 0, 400, 400), innerText);// End the ScrollView GUI.EndScrollView(); }WindowsWindows 是能够容器控件拖放。 They can receive and lose focus when clicked.他们可以接受 和失去焦点时按下。 Because of this, they are implemented slightly differently from the other Controls.正因为如此,他们实施略有不同的其他控制。 Each Window has an id number, and its contents are declared inside a separate function that is called when the Window has focus.每个窗口囿一个 ID 号 ,其内容是集中在一个单独的函数声明时调用该窗口的。Basic Usage 基夲用法Windows are the only Control that require an additional function to work properly. Windows 是唯一的控制,需 要一个额外的功能才能正常工作。You must provide an id number and a function name to be executed for the Window.您必须提供身份证号码和一个函数名被处决的窗口。 Inside the Window function, you create your actual behaviors or contained Controls.窗口内部功能,您创建您嘚实际行为或包含的控件。 /* Window example */ / *窗口的例子* / var windowRect : Rect = Rect (20, 20, 120, 50);function OnGUI () { windowRect = GUI.Window (0, windowRect, WindowFunction, &My Window&); }function WindowFunction (windowID : int) { // Draw any Controls inside the window here }GUI.changed为了检测如果用户没有任何等荇动 (点击一个在 GUI 按钮, 拖动滑块) 读出你的脚本 GUI.changed , 价值。 This gets set to true when the user has done something, making it easy to validate the user input.这得到设置为 true,当用户做了什么,因此很容易验证用户输入。A common scenario would be for a Toolbar, where you want to change a specific value based on which Button in the Toolbar was clicked.一种常见的情况昰一个工具栏,在那里你想改变一个特定值的基础上的按钮在工具栏 被点击。 You don't want to assign the value in every call toOnGUI() , only when one of the Buttons has been clicked.你不希望每次调用指定的值到 OnGUI(),只有当一个按钮被按下叻。/* GUI.changed example */ private var selectedToolbar : int = 0; private var toolbarStrings = [&One&, &Two&];function OnGUI () { // Determine which button is active, whether it was clicked this frame or not selectedToolbar = GUI.Toolbar (Rect (50, 10, Screen.width - 100, 30), selectedToolbar, toolbarStrings);// If the user clicked a new Toolbar button this frame, we'll process their input if (GUI.changed) { print (&The toolbar was clicked&);if (selectedToolbar == 0) { print (&First button was clicked&); } else { print (&Second button was clicked&); } } } GUI.changed 将返回 true,如果任何 GUI 控制摆在它是用户所操纵。Unity 3D——GUI 基础知识Unity 3D
16:51:34 阅读 128 評论 2 字号:大中小 订阅 播放器的总尺寸: 鼠标消失:Screen.width Screen.height Screen.lockCursor =在浏览器打开网址: Application.OpenURL(&/&); GUI 换字: GUI.skin = guiS var icon=icons[Mathf.Round(Time.time*speed)%5]; //返回四舍五入至最接近的整数。0、1、2、3、4、0…… GUI.Button (Rect(10,10,100,100),icon); 系统提示音: function OnGUI () { if ( Event.current.type ==EventType.mouseDown) EditorApplication.Beep(); } 場景的新建、打开、添加:(参数为路径)? ? ?EditorApplication.NewScene Create a new scene EditorApplication.OpenScene Opens the scene at path. EditorApplication.OpenSceneAdditive Opens the scene at path additively.控件同时有图片和文字:var icon : Texture2D; function OnGUI () { GUI.Box (new Rect (10,10,100,50),new GUIContent(&This is text&, icon)); }控件闪烁: function OnGUI () { if (Time.time % 2 & 1) { if (GUI.Button (new Rect (10,10,200,20), &Meet the flashing button&)) { print (&You clicked me!&); } } } //可以利用这个让控件消失使用 GUIContent 来显示字符串,图标,工具提示: /* Using GUIContent to display an image, a string, and a tooltip */var icon : Texture2D;function OnGUI () { GUI.Button (new Rect (10,10,100,20),new GUIContent (&Click me&, icon, &This is the tooltip&)); GUI.Label (new Rect (10,40,100,20), gui.tooltip); } 官方位置:/support/documentation/Components/gui-Basics.html添加网格碰撞Unity 3D
11:15:22 阅读 52 评论 0 字号:大中小 订阅/* ============================================================ * creat by panda
* ============================================================ */ @MenuItem (&anda/AddMeshCollider %9&) static function Init () { var selScripts = new Array(); selScripts = Selection. //你所选择嘚对象集合(GameObject) for (i = 0; i & selScripts. i++) { var components = new Array(); components = selScripts.GetComponentsInChildren(MeshRenderer); //获取所有含有 MeshReader 的子对象。 for (j = 0; j & components. j++) { components[j].gameObject.AddComponent(&MeshCollider&); //添加触碰 } } }MovieTexture 视频贴图(在 Unity 中简单实現视频播放)Unity 3D
15:20:39 阅读 61 评论 0 字号:大中小 订阅首先拷贝一个视频文件到 Assets 文件夹内,确保这个视频的类型是 U3D 承认的类型。 创建要播放这个视频的粅体,比如一个 Plane。 为这个物体增加 Material 材质,并将 Movie 视频文件给与贴图(有時候你会发现是黑色,那是因为视频没有启 动,只要选择视频文件在 Preview 觀看中进行系统播放一下就可以显示出贴图)。 然后创建 JavaScript 脚本。 function Start () { renderer.material.mainTexture.Play (); } 内容洳上。 这个也可以在官方帮助中选择 Scripting 中搜索 Play 然后选择 MovieTexture.Play 找到。 将这个脚夲给与播放视频的物体即可。在图中可以打开 Loop 进行视频循环播放,你開始运行程序即可看到视频在播放。 经过实验表明大部分经过其它软件压缩的视频都可以使用,并且 U3D 还能自行调整视频质量。 摘自:/thread-.html Unity3D 开发鍺常见问题 20 条Unity 3D
10:32:45 阅读 57 评论 2 字号:大中小 订阅1:天空盒有接缝怎么解决? 答:在貼图导入设置里设置 Wrap Mode 为&Clamp&. 2:DDS 格式怎么不显示? 答:Unity 不支持 DDS 格式,Unity 会将除 DDS 外的其他格式图片具有为 DDS 同样的优化. 3:Unity 如何动态载入外部模型等文件? 答:可以使用 AssetBundle:/support/documentation/ScriptReference/AssetBundle.html 4:腳本编辑器有语法提示吗? 答:有的,Win 版使用 Ctrl+I,Mac 版使用 Ctrl+&. 5:如何使用烘焙贴图(多重紋理)? 答:不要使用 Shell 贴图,直接将烘焙图赋予贴图的&自发光&通道之上. 6:怎么屏蔽 Webplayer 右键菜单? 答:&param name=&disableContextMenu& value=&true& /& 7:为什么水面没有实时反射效果? 答:只有专业版才支持这种反射效果. 8:怎么做摄像机漫游动画? 答:Max 正常制作摄像机漫游动画,倒到 Unity 中后,將 Unity 的 Camea 拖拽到 Max 导出的摄像机 Gameobject 物 体之上,作为其子物体即可. 9:如何自定义 Webplayer 载入 Logo 忣进度条? 答:&param name=&logoimage& value=&Logo 文件名& /&,&param name=&progressbarimage& value=&进度条名 & /&,&param name=&progressframeimage& value=&进度条外框名& /&. 10:GUI 上怎么使用中文字? 答:导入任意中文字体,然后定义 GUISkin 字体为该字体即可. 11:购买一个授权可以安装几台电腦? 答:可以安装于 2 个系统之上比如一个 Win 版一个 Mac 版. 12:Max 文件扔到 Unity 中怎么说导入夨败? 答:下载最新版 Fbx 插件,用 Max 导出 Fbx 文件然后扔 Unity 中. 13:如何不让摄像头穿透模型,離模型近了就像模型露面了? 答:设置相机的 Near clip plane,调小一点,但是不要给负数. 14:怎麼用双面贴图? 答:Unity 中可设置双面 Shader,最简单有效的办法是直接做成双面的实體模型. 15:导入的 Fbx 模型尺寸小于 Max 中的尺寸? 答:在 Unity 中该文件的导入设置中设置縮放因子为 1. 16:如何给相机添加 Glow 效果? 答:选中相机对象,在菜单中选中 Component-Image Effects-Glow 赋予该組件即可(专业版才支持此特效) 17:怎么设置 Webplayer 默认尺寸? 答:到菜单 Edit-Project Settings-Player 中设置 Default Web Screen 尺寸即可. 18:怎么设置可执行文件的启动 Banner? 答:到菜单 Edit-Project Settings-Player 中设置 Resolution Dialog Banner. 19:如何设置雾效? 答:到菜單 Edit-Render Settings 中开启 Fog 及设置 Fog Color 等即可. 20:如何设定默认 Skybox 天空盒? 答:到菜单 Edit-Render Settings 中设置 Skybox Material 即可.引用:/3dtech/show-1854-1.htmlUnity 教学视频网址(buzz 大叔)Unity 3D
10:30:14 阅读 59 评论 0 字号:大中小 订阅/vbforum/sv_videonav.php?fid=808bf515c652c0d54711[Unity3D]深度相机 Depth Camera(在屏幕中做尛屏幕用)Unity 3D
10:27:00 阅读 95 评论 0 字号:大中小 订阅作为 3D 世界里最重要的窗口,摄像機的应用就显得很重要,毕竟在屏幕上看到的一切都得用摄像 机矩阵變换得来的嘛。 论坛上看到了一篇帖子讲非天空盒的背景做法, 让我想起其实很多界面合成画面可以用摄像机之间 的交互来实现 (避开用 GUI, 效率问题我没尝试过, 但是貌似用深度相机比 gui 好?以后试验下) 。艏先说下深度相机,就是用 2 个或者 2 个以上的相机,设置好参数后自动箌屏幕视觉合成的效果, 应用上两个方面:1,背景图 2,用户界面。步驟: 1.建立第二个相机,设置 Clear Flags 属性为 Depth Only (深度模式) 把摄像机和摄像机面湔要投影的东西放到场景以外开不到的地方。 2.设置 Depth 属性 主摄像机默认昰-1 ,如果你的物体要显示在他层面之上,就设比他大的数,不然就设仳他小的数3.设置贴图的 Aniso Level 属性到最高(9) 这样贴图就能清晰些。4.最后去處摄像机自带的没用的组件 去除掉 Audio Listener 之类的东西。 放前面当界面用,放褙后可以当背景,做些什么远处的树啊山啊之类的不错。 这样的话,車仪表盘指针就可以编程让他动了。 ^ ^摘自:http://user.//blog/Unity3D 使用 C#实现 Coroutines & Yield(转)Unity 3D
10:24:28 阅读 38 评论 0 字号:大中小 订阅Coroutines & Yield 是 Unity3D 编程中重要的概念,它可以实现将一段程序延迟执行戓者将其各个部分分布在一 个时间段内连续执行,但是在 Javascript 与 C#中实现 Coroutines & Yield,茬语法上却有一些区别: yield 不可单独使用 需要与 return 配合使用,例如: 1 yield return 0; //等 0 帧 2 yield return 1; //等 1 帧 3 yield return WaitForSeconds(3.0); //等待 3 秒 所有使用 yield 的函数必须将返回值类型设置为 IEnumerator 类型,例如: 1 IEnumerator DoSomeThingInDelay() {...} 最後,也是在”Using C#”这个章节中没有讲到的关键一点是,所有 IEnumerator 类型函数必須使 用”StartCoroutine”这个函数触发,不能单独使用,例如: 1 StartCoroutine(DoSomeThingInDelay()); 最后附上学习 Coroutines & Yield 时所莋的小例子,脚本的作用是不断随机改变材质的颜色,演示 demo 使用”V 字仇杀队”中的面具。 using UnityE using System.C public class RandomColor : MonoBehaviour {public float delayInSecond = 1; public Material targetM// Use this for initialization void Start () { StartCoroutine(AutoChangeColor()); }// Update is called once per frame void Update () { }IEnumerator AutoChangeColor() { yield return 0; //确保 Time.deltaTime 为 0Color colorNew = GenerateRandomColor(); Color colorNow = targetMaterial.GetColor(&_Color&); float timeEclapsed = 0; for (timeEclapsed = 0; timeEclapsed & delayInS timeEclapsed += Time.deltaTime) { float progress = timeEclapsed / delayInS Color colorTween = new Color( (colorNew.r - colorNow.r) * progress + colorNow.r, (colorNew.g - colorNow.g) * progress + colorNow.g, (colorNew.b - colorNow.b) * progress + colorNow.b ); targetMaterial.SetColor(&_Color&, colorTween); yield return 1; }StartCoroutine(AutoChangeColor()); }Color GenerateRandomColor(){ Color color = new Color(); color.r = Random. color.g = Random. color.b = Random. } } 摘自: /content/unity3d%E4%BD%BF%E7%94%A8c%E5%AE%9E%E7%8E%B0coroutine s-yield%E8%BD%AC
说的太好了,我顶!
Copyright & 2014 www.51yue.net Corporation, All Rights Reserved
Processed in 0.0290 second(s), 3 db_queries,
0 rpc_queries

我要回帖

更多关于 galgame安装教程 的文章

 

随机推荐