This is the 27th day of my participation in the August Genwen Challenge.More challenges in August

Recommended reading

  • CSDN home page
  • GitHub open source address
  • Unity3D plugin sharing
  • Jane’s address book
  • My personal blog
  • QQ group: 1040082875

Hello everyone, I am a Buddhist engineer ☆ quiet small magic dragon ☆, update Unity development skills from time to time, think useful remember one key three link oh.

Refer to the article

Detailed explanation of access Drawing Line and Drawing Surface of Game Object by Unity3D Research Institute (17)

preface

There are many online tutorials on how to draw lines with LineRender components, but there are many other features of LineRender components that are also interesting to see

use

The main purpose of LineRender is to draw lines. Load this component onto the object, and then set the path and material of the line to display line segments in the Game view.

Line drawing

Way to understand the Unity of the painting line, you can refer to my another article blog.csdn.net/q764424567/…

Use LineRender to draw lines

  • Add the LineRender component to an object

  • Attached material Materials

  • Set up path Positions

  • That’s what it looks like

Properties of the LineRender component

  • Cast Shadows

Drop shadow, can select On On Off On Sided Shadows Only show Shadows

  • Recevice Shadows

Receive shadow effect

  • Motion Vectors

Every movement of an Object will also be followed by the movement Force No Motion

  • Materials

You can set the material of the line segment, you can set it to a solid color material, something like thisYou can also make a transparent arrow Upload this picture as wellThis one is not watermarkedPan.baidu.com/s/165kbJjzo…Note that the format of the imported image is set as followsOtherwise it might not work

  • Lightmap Parameters

In this case, you can use your own lighting parameters

  • Positions

Path Settings, which can be controlled in code

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; public class nav : MonoBehaviour { private NavMeshAgent m_Agent; public GameObject m_Target; private LineRenderer m_LineRender; // Use this for initialization void Start() { m_Agent = GetComponent<NavMeshAgent>(); m_LineRender = GetComponent<LineRenderer>(); //m_Agent.SetDestination(m_Target.transform.position); } / / Update is called once per frame void the Update () {/ / set the target point m_Agent. SetDestination (m_Target. The transform. The position). // Save Vector3[] path = m_agent.path.corners; // Save Vector3[] path = m_agent.path.corners; // Set the number of vertices m_linerender. positionCount = path.length; // set line segment for (int I = 0; i < path.Length; i++) { m_LineRender.SetPositions(path); }}}Copy the code
  • Use World Space

I’m going to use world coordinates or I’m going to use self coordinates

  • Loop

repeat

  • Width

Set the width of the line segment

  • Color

Set the color of the line segment to affect the material

  • Corner Vertices

Angle vertices, that’s how many points you turn, you don’t have to set that

  • End Cap Vertices

Back cover the vertices

  • Alignment

Alignment, Local, means alignment according to your own coordinate system, View View alignment

  • Texture Mode

Material model

  • Light Probes

The light probe

  • Reflection Probes

Reflection probe