画线,如何计算坐标
public void DrawAttackLineByPos(Vector2 from, Vector2 to)大佬好:
{
Debug.Log("DrawLine from " + from + " to " + to);
var graph = new GGraph
{
name = "AttackLine",
};
graph.SetXY(from.x, from.y);
graph.DrawRect(1, 1, 1, Color.red, Color.red);
var shape = graph.shape;
var line = shape.graphics.GetMeshFactory<LineMesh>();
line.lineWidthCurve = AnimationCurve.Linear(0, 1, 1, 1);
line.roundEdge = true;
//line.gradient = lineGradient;
line.path.Create(new GPathPoint {
new GPathPoint(new Vector3(from.x, from.y, 0)),
new GPathPoint(new Vector3(to.x, to.y, 0))
});
shape.graphics.SetMeshDirty();
GTween.To(0, 1, 3).SetEase(EaseType.Linear).SetTarget(shape.graphics).OnUpdate((GTweener t) =>
{
((NGraphics)t.target).GetMeshFactory<LineMesh>().fillEnd = t.value.x;
((NGraphics)t.target).SetMeshDirty();
});
GTween.To(0, 1, 3).SetEase(EaseType.Linear).SetTarget(shape.graphics).OnComplete((GTweener t) =>
{
//GRoot.inst.RemoveChild(graph);
});
GRoot.inst.AddChild(graph);
}
我现在想从界面的一个组件A向组件B画线,这个坐标要如何计算呢?
现在传入的是2个组件的坐标给Vector2 from, Vector2 to
,但是画线后有明显的偏移,请问这个真正计算的时候包含unity坐标转换吗?
谢谢。
没有找到相关结果
已邀请:
5 个回复
谷主
赞同来自:
lazy
赞同来自:
要怎么改呢?
谷主
赞同来自:
lazy
赞同来自:
实际显示:
谷主
赞同来自: