Linerendererで2つのUI GameObjectの間に線を描こうとしています。シーンモードではすべて正常に動作しますが、ゲームモードではラインは見えません。オブジェクトのZ位置を変更しようとしましたが、線はまだ見えません。誰でも助けてくれますか?事前に感謝しますUnity3d Linerendererが表示されない
private LineRenderer lineRenderer;
private float counter;
private float dist;
private Vector3 aPos;
private Vector3 bPos;
public Transform origin;
public Transform destination;
public float lineDrawSpeed = 6f;
// Use this for initialization
void Start()
{
lineRenderer = GetComponent<LineRenderer>();
aPos = new Vector3(origin.position.x, origin.position.y, origin.position.z); // Using these to move the lines back
bPos = new Vector3(destination.position.x, destination.position.y, destination.position.z);
lineRenderer.SetPosition(0, aPos);
lineRenderer.SetWidth(3f, 3f);
dist = Vector3.Distance(origin.position, destination.position);
}
// Update is called once per frame
void Update()
{
if (counter < dist)
{
counter += .1f/lineDrawSpeed;
float x = Mathf.Lerp(0, dist, counter);
Vector3 pointA = aPos;
Vector3 pointB = bPos;
Vector3 pointAloneLine = x * Vector3.Normalize(pointB - pointA) + pointA;
lineRenderer.SetPosition(1, pointAloneLine);
}
}
ダム質問ですが、あなたの背景はどのような色ですか?私はかつてlineRendererを同じ色にしましたが、私はそれも見えませんでした。 – code11
私の背景は緑色、線は白いです。 –