Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tryadelion/a8065ade4c1205cc6f5abc3fba5de5f4 to your computer and use it in GitHub Desktop.
Save tryadelion/a8065ade4c1205cc6f5abc3fba5de5f4 to your computer and use it in GitHub Desktop.
step 1 : setup the model and export as FBX.
step 2 : import in unity. the vertex and the normals will be flipped.
step 3 : attach this c# script, and run ONLY ONCE.
using UnityEngine;
using System.Collections;
using System.Linq;
public class THISISVERYGUARRO : MonoBehaviour {
// Use this for initialization
void Start () {
Mesh mesh = GetComponent<SkinnedMeshRenderer>().sharedMesh;
mesh.triangles = mesh.triangles.Reverse().ToArray();
}
// Update is called once per frame
void Update () {
}
}
step 4: remove last script, attach this JS script, and run ONLY ONCE:
#pragma strict
import System.Linq;
function Start () {
var mesh = (transform.GetComponent("SkinnedMeshRenderer") as SkinnedMeshRenderer).sharedMesh;
var normals : Vector3[] = mesh.normals;
for (var i=0;i<normals.Length;i++){
normals[i] = -normals[i];
}
mesh.normals = normals;
}
function Update () {
}
step 5: remove last script, and now that the model is fixed, make it a prefab and worry no more.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment