Foreward : While I appreciate all input, for this one question I am looking for decisive, precise answers rather than vague suggestions or open-ended comments. I also understand people may not want to answer my question, as it holds some elements to unlocking the keys of the Unity universe, and that’s where some people make their bread and butter. I am not trying to ruin anyones livelyhood, merely want to make these things myself to use myself to expand my knowledge and save money I don’t actually have =]
This stems from what I thought was a simple question. Basically I had a mesh script that worked with Unity 3.5.1, but when I went to 3.5.6 I started getting an error. Simple question. The details are I have a text mesh (meaning a quad is created per character in the string), when the length of that string changed, and on the first time that text mesh array length was changed, I would get an out of bounds error. However on the next construction of the mesh there was no error and the mesh worked as expected.
This is a simple problem I thought, and went through finding where the lengths of the arrays were assigned, made sure they were not being fed too much or too little information, and even doubly assigned the length of the mesh vertex info before assigning their values.
Here is the question I am speaking of, it has turned into a long mess, and totally irrelevant to the question I asked, only to receive “you are doing it wrong” : array out of range while updating mesh variables - Questions & Answers - Unity Discussions
I know Kryptos is correct (he usually is!) but I just cannot see it when I have working meshes with verts animated every frame (reading curves) and they work perfectly without errors or clearing. phodges also seems very knowledgeable, but as in my comment I believe he contradicted his initial statement leaving me confused.
I don’t believe so, and if I am wrong please leave a concise answer in a format I can follow and absorb, for example my method I have evolved into for creating my meshes is as follows :
// Variables
var verts : Vector3[];
var uvs : same for uvs, tris, normals
// Initialization
if(!mesh) { GetComponent(MeshFilter).mesh = mesh = new Mesh();}
verts = new Vector3[4];
verts[0] = new Vector3( 0, 0, 0);
verts[1] = same for all verts, uvs, tris, normals
mesh.vertices = new Vector3[verts.length];
mesh.uv = same for uvs, tris, normals
mesh.vertices = verts;
mesh.uv = same for uvs, tris, normals
mesh.RecalculateBounds();
mesh.RecalculateNormals();
// Update
mesh = this.transform.GetComponent(MeshFilter).mesh as Mesh;
verts[0] = new Vector3( 0, 0, 0);
verts[1] = same for all verts
mesh.vertices = verts;
The pattern I have made for myself can be seen in my questions (all of these have been answered, thanks. The asteroid script has moved on quite alot infact!)
Here : simply assign tangents to single quad - Questions & Answers - Unity Discussions
Here : irregularities with procedurally generated sphere - Questions & Answers - Unity Discussions
I can provide the script for my animated ‘sock’ if required for reference also.
and on the script in my last comment Here : Calculate Spline points on Complex Geometry Mesh - Questions & Answers - Unity Discussions
my forum box is the same as my handle on UA., I am happy to share my full sprite and text classes with those here who are easily able to create better (to preserve their income by not displaying those type of ready to use scripts here). I know that doesn’t sound cool, but I do help alot of people out with scripts anyway, and what have I done attemting to quash all the ‘noob’ Slender questions with my guide?! But seriously I just want to get my text mesh and sprite class working for my own personal and commercial use, your constructive informative comments are much appreciated as always, thanks.