Quantcast
Viewing all articles
Browse latest Browse all 108

Parsing Error with {s Ok.

Hi, I recently downloaded an open source old proyect from internet, just to discover it was created with unity 4, so many of the scripts were outdated, I managed to fix most of the errors, except one. When I fixed the GetTriangles problem, in wich you need to just change the name, four errors appeared. Two "Unexpected Symbol "else" " One "Unexpected Symbol "If" " And one parsing error at line 53, 1. The problem? I started to review the code and found that one colon at the starting was missing, i thought the problem was solved, and all the problems dissapeared, except one, a parser error at line three that, if the { is removed, the other four errors appear.` Code Without the colon using UnityEngine; using System.Collections; public class MeshCombineUtility { public struct MeshInstance { public Mesh mesh; public int subMeshIndex; public Matrix4x4 transform; } public static Mesh Combine (MeshInstance[] combines, bool generateStrips) { int vertexCount = 0; int triangleCount = 0; int stripCount = 0; foreach( MeshInstance combine in combines ) { if (combine.mesh) { vertexCount += combine.mesh.vertexCount; if (generateStrips) { // SUBOPTIMAL FOR PERFORMANCE int curStripCount = combine.mesh.SetTriangles(combine.subMeshIndex) if (curStripCount != 0) { if( stripCount != 0 ) { if ((stripCount & 1) == 1 ) stripCount += 3; else stripCount += 2; } stripCount += curStripCount; } { else generateStrips = false; } } } } // Precomputed how many triangles we need instead { if (!generateStrips) { foreach( MeshInstance combine in combines ) { if (combine.mesh) { triangleCount += combine.mesh.GetTriangles(combine.subMeshIndex).Length; } } } } Vector3[] vertices = new Vector3[vertexCount] ; Vector3[] normals = new Vector3[vertexCount] ; Vector4[] tangents = new Vector4[vertexCount] ; Vector2[] uv = new Vector2[vertexCount]; Vector2[] uv1 = new Vector2[vertexCount]; Color[] colors = new Color[vertexCount]; int[] triangles = new int[triangleCount]; int[] strip = new int[stripCount]; int offset; offset=0; foreach( MeshInstance combine in combines ) { if (combine.mesh) Copy(combine.mesh.vertexCount, combine.mesh.vertices, vertices, ref offset, combine.transform); } offset=0; foreach( MeshInstance combine in combines ) { if (combine.mesh) { Matrix4x4 invTranspose = combine.transform; invTranspose = invTranspose.inverse.transpose; CopyNormal(combine.mesh.vertexCount, combine.mesh.normals, normals, ref offset, invTranspose); } } offset=0; foreach( MeshInstance combine in combines ) { if (combine.mesh) { Matrix4x4 invTranspose = combine.transform; invTranspose = invTranspose.inverse.transpose; CopyTangents(combine.mesh.vertexCount, combine.mesh.tangents, tangents, ref offset, invTranspose); } } offset=0; foreach( MeshInstance combine in combines ) { if (combine.mesh) Copy(combine.mesh.vertexCount, combine.mesh.uv, uv, ref offset); } offset=0; foreach( MeshInstance combine in combines ) { if (combine.mesh) Copy(combine.mesh.vertexCount, combine.mesh.uv2, uv1, ref offset); } offset=0; foreach( MeshInstance combine in combines ) { if (combine.mesh) CopyColors(combine.mesh.vertexCount, combine.mesh.colors, colors, ref offset); } int triangleOffset=0; int stripOffset=0; int vertexOffset=0; foreach( MeshInstance combine in combines ) { if (combine.mesh) { if (generateStrips) { int[] inputstrip = combine.mesh.SetTriangles(combine.subMeshIndex); if (stripOffset != 0) { if ((stripOffset & 1) == 1) { strip[stripOffset+0] = strip[stripOffset-1]; strip[stripOffset+1] = inputstrip[0] + vertexOffset; strip[stripOffset+2] = inputstrip[0] + vertexOffset; stripOffset+=3; } else { strip[stripOffset+0] = strip[stripOffset-1]; strip[stripOffset+1] = inputstrip[0] + vertexOffset; stripOffset+=2; } } for (int i=0;i

Viewing all articles
Browse latest Browse all 108

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>