unity3D LineRender的使用
2015-06-06 18:21
453 查看
首先做一个预设,添加LineRender组件,变价材质,然后放到资源文件夹中
搞定。。。。。。。。。。。。。。。。。。。。。。。
private LineRenderer m_lineRander; private Vector3 m_curPos; public Vector3 CurPos { get { return m_curPos; } set { m_curPos = value; if (m_lineRander != null) { m_lineRander.SetPosition(1, m_curPos); } } } void Start() { GameObject lineObjPrefab = Resources.Load("line",typeof(GameObject)) as GameObject; if (lineObjPrefab == null) { Debug.LogError("lineObjPrefab == null"); } GameObject lineObj = GameObject.Instantiate(lineObjPrefab) as GameObject; m_lineRander = lineObj.GetComponent<LineRenderer>(); if (m_lineRander != null) { m_lineRander.transform.localPosition = Vector3.zero; m_lineRander.SetVertexCount(2); m_lineRander.SetPosition(0, new Vector3(0, 0, 0)); m_lineRander.SetPosition(1, new Vector3(0, 0, 0)); startMove(); } } private void startMove() { TweenParms tp = new TweenParms(); tp.Prop("CurPos", new Vector3(50, 100, 100)); tp.Ease(EaseType.Linear); tp.SpeedBased(true); tp.OnComplete(moveEnd); HOTween.To(this, 100f, tp); } private void moveEnd() { Debug.Log("moveEnd"); }
搞定。。。。。。。。。。。。。。。。。。。。。。。
相关文章推荐
- Unity shader随笔记(一)SurfaceShader
- Unity3D优化总结(一)
- C#泛型在unity3D中的运用.
- Unity 飞机大战增强版
- 【经验】Unity读取Excel数据并绑定到Prefab上
- Unity3D帮助文档跳转缓慢----Vim编辑器批量替换文件内容
- 【Unity3D】自动寻路(Nav Mesh Agent组件)
- [Unity实战]框选效果
- unity3D 旋转3D物体
- Unity3D添加天空盒
- [Unity基础]GL图像库
- [UnityShader]使用Unity Render Textures实现画面特效——建立画面特效脚本系统
- Unity3D教程:动画融合、动画层、动画混合、附加动画、程序动画、动画重放和取样
- unity手游开发--如何得到当前物体播放的动画
- Unity3D 项目用 git 做版本控制
- Unity5 如何做资源管理和增量更新
- InvokeRepeating("PlaySound",2.0f,0.5f) 2秒后每隔0.5秒调用
- [Unity3D]自己动手重制坦克舰队ArmadaTank
- Unity3d读取CSV中的文本到Rich Text中换行符不识别的问题
- 如何将Unity工程打包成apk