OnRenderObject: 在完成所有常规场景渲染后调用此函数。此时,可使用 GL 类或 Graphics.DrawMeshNow 绘制自定义几何图形。
C# 代码部分:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class huafu : MonoBehaviour
{
List<Vector3> PointList;
public Image image;
Texture2D texture;
// Start is called before the first frame update
void Start()
{
PointList = new List<Vector3>();
texture = new Texture2D(300, 400);// image.sprite.texture;
image.GetComponent<Image>().material.mainTexture = texture;
}
static Material lineMaterial;
static void CreateLineMateria