随笔分类 -  unity

上一页 1 ··· 8 9 10 11 12 13 下一页

unity, 查看内置shader源码
摘要:1,建一个球体。2,建一个材质,将材质拖到球体上。3,在材质的shader下拉列表中选择想查看的内置shader,点材质栏右上设置按钮->Select Shader 进入shader面板。4,点Compile and show code查看shader代码。(在此之前可点按钮右边箭头在弹出的下拉菜单... 阅读全文

posted @ 2015-04-15 23:03 wantnon 阅读(2472) 评论(1) 推荐(0)

unity, Find References In Scene
摘要:材质,脚本,shader等都可以通过Find References In Scene查看引用情况,如图。当对一个文件点击Find References In Scene后,搜索命令会显示到Scene视图右上角的搜索框里(同时也显示在Hierarchy窗口的搜索框里)。如果想恢复原貌,清空搜索框中的内... 阅读全文

posted @ 2015-04-15 22:26 wantnon 阅读(3325) 评论(0) 推荐(0)

unity 主循环
摘要:在unity官方文档中看到这个图,感觉很有用,各事件的先后时机看得较清楚。连接:http://docs.unity3d.com/Manual/ExecutionOrder.html 阅读全文

posted @ 2015-04-15 20:46 wantnon 阅读(508) 评论(0) 推荐(0)

unity 显示帧率
摘要:Game视图右上角Stats按钮按下即可显示统计信息。 阅读全文

posted @ 2015-04-15 18:38 wantnon 阅读(699) 评论(0) 推荐(0)

unity5, custom PBS shader
摘要:unity5中引入了基于物理着色(PBS)的Standard shader。由于这种着色器通过调节参数和贴图可逼真模拟各种硬质表面,所以不必再像unity4时代那样需要对各种质感材质单独编写着色器,而且能得到更好的效果(参考:http://docs.unity3d.com/Manual/shader... 阅读全文

posted @ 2015-04-06 01:28 wantnon 阅读(1794) 评论(0) 推荐(0)

unity, 延迟执行代码
摘要:使用协程实现比较方便,可以带参数。 void Start(){ StartCoroutine(delayLaunchRocket(rocket,2.0f)); } IEnumerator delayLaunchRocket(Obj rocket,float delayTime){ yield ret 阅读全文

posted @ 2015-04-01 02:24 wantnon 阅读(659) 评论(0) 推荐(0)

unity, 让主角头顶朝向等于地面法线(character align to surface normal)
摘要:计算过程如下:1,通过由主角中心raycast一条竖直射线获得主角所在处地面法线,用作主角的newUp。注:一定要从主角中心raycast,而不要从player.transform.position,因为如果player的模型原点在脚上,则player.transform.position可能就在地... 阅读全文

posted @ 2015-03-31 12:48 wantnon 阅读(2877) 评论(0) 推荐(1)

unity 在Game视图中显示Gizmos
摘要:自己画的Gizmos要想在Game视图中能看到,需要把Game视图窗口右上角的"Gizmos"按钮点下去。如图:比如,下面代码以角色的capsuleCollider中心为中心画一个半径为0.8f的球体线框。voidOnDrawGizmos(){Vector3capsuleColliderCenter... 阅读全文

posted @ 2015-03-30 22:57 wantnon 阅读(6945) 评论(0) 推荐(0)

unity Transform.TransformPoint
摘要:正如unity api文档所说:Transformspositionfrom local space to world space.即Transform.TransformPoint是将局部坐标点转化到世界空间(而不是父空间)。至于如何 高效 地将局部空间坐标转到父空间,还没找到。在论坛发了个帖子:... 阅读全文

posted @ 2015-03-30 22:09 wantnon 阅读(1119) 评论(0) 推荐(0)

unity Input.GetAxis和Input.GetAxisRaw
摘要:float h = Input.GetAxis("Horizontal") ;//h range from -1 to 1float v = Input.GetAxis("Vertical") ;//v range from -1 to 1float h = Input.GetAxisRaw("Ho... 阅读全文

posted @ 2015-03-29 20:21 wantnon 阅读(1845) 评论(0) 推荐(0)

unity update与fixedUpdate
摘要:update与渲染同步。fixedUpdate与物理同步。在update中,speed要乘以Time.deltaTime。在fixedUpdate中,speed要乘以Time.fixedDeltaTime。参考:http://blog.csdn.net/alexander_xfl/article/d... 阅读全文

posted @ 2015-03-29 20:00 wantnon 阅读(326) 评论(0) 推荐(0)

unity 获得父子节点
摘要:与常识不同,unity中获得父子节点需要通过transform。即先获得父/子节点的transform,然后再通过父/子节点的transform获得父/子节点。获得父节点gameObject:GameObject parentGameObject=transform.parent.gameObjec... 阅读全文

posted @ 2015-03-29 13:06 wantnon 阅读(1674) 评论(0) 推荐(0)

unity 在脚本B中调用脚本A的函数
摘要:一,在脚本B中调用脚本A的函数。脚本A://myFuncs.csusingUnityEngine;usingSystem.Collections;namespacemyFuncs{publicclassCmyFuncs{publicstaticvoidprintHi(){Debug.Log("Hi"... 阅读全文

posted @ 2015-03-25 19:52 wantnon 阅读(499) 评论(0) 推荐(0)

unity5 Orthographic模式相机视截体尺寸计算
摘要:一,通过编辑器中数值计算。如图,相机为Orthographic模式,其camera size为5.57,是什么含义呢,经过测量,发现视图中视截体的高度是5.57x2。那么视截体的宽度怎么决定呢?做下面试验,前面屏幕尺寸选的是Web(600x900),所以 视截体宽度=视截体长度/900*600=7.... 阅读全文

posted @ 2015-03-25 14:05 wantnon 阅读(5939) 评论(0) 推荐(1)

unity5 新建球体的默认半径是0.5
摘要:unity5 新建球体的默认半径是0.5 阅读全文

posted @ 2015-03-25 13:22 wantnon 阅读(707) 评论(0) 推荐(0)

unity5 Edit Collider
摘要:按下Edit Collider按钮,视图中Collider线框中出现控制点,可以通过拖动控制点对Collider进行调整。 阅读全文

posted @ 2015-03-24 00:03 wantnon 阅读(1091) 评论(0) 推荐(0)

unity 查看prefab层次
摘要:点那个箭头,可以展开: 阅读全文

posted @ 2015-03-23 23:16 wantnon 阅读(1041) 评论(0) 推荐(0)

unity c# script error CS0664: Literal of type double cannot be implicitly converted to type `float'. Add suffix `f' to create a literal of this type
摘要:例如在unity c# script中定义private float x=0.0;则会报error CS0664: Literal of type double cannot be implicitly converted to type `float'. Add suffix `f' to cre... 阅读全文

posted @ 2015-03-23 22:09 wantnon 阅读(605) 评论(0) 推荐(0)

unity hide/show text
摘要:usingUnityEngine;usingSystem.Collections;publicclassPlayerController:MonoBehaviour{publicUnityEngine.UI.TextwinText;voidStart(){winText.text="YouWin!"... 阅读全文

posted @ 2015-03-23 21:59 wantnon 阅读(481) 评论(0) 推荐(0)

unity5 创建material
摘要:在material文件夹下unity5中新创建的material默认如下开始我不知道贴图应该加在哪儿。于是跳过教程上这一步,直接去选shader:在这个shader下很明显看到加贴图的地方了:加完贴图如下:假如此时再回到默认的Standard shader下,可以看到:原来Albedo前面的方格是加... 阅读全文

posted @ 2015-03-23 17:03 wantnon 阅读(1589) 评论(0) 推荐(0)

上一页 1 ··· 8 9 10 11 12 13 下一页

导航