当前位置:网站首页>Unity grid programming 06
Unity grid programming 06
2022-06-23 08:48:00 【LittleU】
Now that we have completed a triangle, let's refer to the previous , Write another triangle , And put this patch together into a quadrilateral , Just refer to the previous code directly , And to make it easy to see , Slightly adjust the position of the second triangle .
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Script dependencies on components
[RequireComponent(typeof(MeshFilter),typeof(MeshRenderer))]
public class SimpleProceduralMesh : MonoBehaviour
{
private void OnEnable()
{
Mesh mesh = new Mesh()
{
name = "Procedural Mesh"
};
//3 vertices
mesh.vertices = new Vector3[] {
Vector3.zero ,
Vector3 .right ,
Vector3 .up ,
new Vector3 (1.1f,0),
new Vector3 (1.1f,1.1f),
new Vector3 (0,1.1f)
};
// Render order of vertices
mesh.triangles = new int[] {
0,2,1,
5,4,3
};
// Model Discovery orientation
mesh.normals = new Vector3[] {
Vector3 .back,
Vector3 .back,
Vector3 .back,
Vector3 .back,
Vector3 .back,
Vector3 .back
};
// Model UV
mesh.uv = new Vector2[] {
Vector2 .zero,
Vector2.right,
Vector2.up ,
new Vector3 (1.1f,0),
new Vector3 (1.1f,1.1f),
new Vector3 (0,1.1f)
};
mesh.tangents = new Vector4[] {
new Vector4(1f,0f,0f,-1f),
new Vector4(1f,0f,0f,-1f),
new Vector4(1f,0f,0f,-1f),
new Vector4(1f,0f,0f,-1f),
new Vector4(1f,0f,0f,-1f),
new Vector4(1f,0f,0f,-1f)
};
GetComponent<MeshFilter>().mesh = mesh;
}
}
So run again unity Program :
边栏推荐
- 如何评价代码质量
- “教练,我想打篮球“ —— 给做系统的同学们准备的 AI 学习系列小册
- Which one is better for rendering renderings? 2022 latest measured data (IV)
- 3. Caller 服务调用 - dapr
- List interface three sub implementation classes
- Top 25 most popular articles on vivo Internet technology in 2021
- When easynvr service is started, video cannot be played due to anti-virus software interception. How to deal with it?
- 高通9x07两种启动模式
- 3、 System analysis and design
- Testing -- automated testing selenium (about API)
猜你喜欢

【活动报名】SOFAStack × CSDN 联合举办开源系列 Meetup ,6 月 24 日火热开启

In June, China database industry analysis report was released! Smart wind, train storage and regeneration

The most commonly used 5-stream ETL mode

【云计算】GFS思想优势以及架构

Talk about the implementation principle of @autowired

鸿蒙读取资源文件

Why use growth neural gas network (GNG)?

坑爹的“敬业福”:支付宝春晚红包技术大爆发

Install a WGet for your win10

Linux Mysql安装
随机推荐
Restore the default routing settings of the primary network card
Lighthouse cloud desktop experience
Set interface and set sub implementation classes
3-ProgressBar和二次裁剪
Android kotlin coroutines KTX extension
Leetcode topic analysis sort colors
【云计算】GFS思想优势以及架构
2022.6.22-----leetcode.513
4- draw ellipse, use timer
给你的win10装一个wget
通信方式总结及I2C驱动详解
TDesign update weekly report (the first week of January 2022)
Intelligent operation and maintenance exploration | anomaly detection method in cloud system
636. Exclusive Time of Functions
usb peripheral 驱动 - configfs
1-渐变、阴影和文本
“方脸老师”董宇辉再回应热度下降:把农产品直播做好让农民受益 考虑去支教
In June, China database industry analysis report was released! Smart wind, train storage and regeneration
Hongmeng reads the resource file
Comprehensive analysis of news capture