1.第一种射线:源自物体本身的射线(该方法需要在物体上添加射线组件Line Renderer)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeLine : MonoBehaviour {
LineRenderer line;
// Use this for initialization
void Start () {
line=GetComponent<LineRenderer>();
line.widthMultiplier = 0.08f;//设置射线的宽度
}
// Update is called once per frame
void Update () {
line.SetPosition(0, transform.position);//设置射线的起点
line.SetPosition(1, transform.forward*10.0f);//设置射线的终点
}
}