反向翻转法线实现一个天空盒
using System.Collections;using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// made by u3dchina.com
/// </summary>
public class FlipNormals : MonoBehaviour
{
// Use this for initialization
void Start()
{
Mesh mesh = this.GetComponent<MeshFilter>().mesh;
Vector3[] normals = mesh.normals;
for (int i = 0, lenI = normals.Length; i < lenI; i++)
{
normals = -1 * normals;
}
mesh.normals = normals;
Debug.Log("subMeshCount:"+mesh.subMeshCount);
for (int i = 0, lenI = mesh.subMeshCount; i < lenI; i++)
{
int[] tris = mesh.GetTriangles(i);
for (int j = 0, lenJ = tris.Length; j < lenJ; j+=3)
{
int temp = tris;
tris = tris;
tris = temp;
}
mesh.SetTriangles(tris, i);
}
}
// Update is called once per frame
void Update()
{
}
}
创建一个character controller、plane、及一个sphere当天空盒,把该脚本拉到sphere就ok了。
很不错 好帖就是要顶 顶顶多好 说的非常好 LZ真是人才
页:
[1]