卜若的代码笔记-unity系列-unity功能篇-划线

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LineManager : MonoBehaviour {


    LineRenderer line;
    Camera camera;


    private void Awake()
    {
        camera = GameObject.Find("Main Camera").GetComponent();
        line = this.GetComponent();


    }
    int index = 0;
    void Update () {

        if (Input.GetMouseButtonDown(0))
        {            
            line.SetVertexCount(index+1);
            line.SetPosition(index, camera.ScreenToWorldPoint(Input.mousePosition)+new Vector3(0,0,100));
            index++;
        }
	}
}

 

你可能感兴趣的:(unity功能篇,unity,unity)