您的位置:首页 > 移动开发 > Unity3D

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");
}


搞定。。。。。。。。。。。。。。。。。。。。。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: