- Home /
Unity 3.4 and mesh extrusion script
Hi
Since I installed 3.4 I've been rewritting my scripts. As you know, even the Unity default scripts dont work because the new stricter compiler.
My problem is that for one variable (I think so) I can't compile my game. I use the script and the plugins of the mesh extrusion example of Unity, and there is a script called ExtrudedMeshTrail.js or something similar. In this script, there is one variable that I can't define
private var sections = new Array();
Then I get something like "time is not member of "object"" and point too
How can I solve this?
Thanks
var time : float = 2.0;
var autoCalculateOrientation = true;
var minDistance = 0.1;
var invertFaces = false;
private var srcMesh : Mesh;
private var precomputedEdges : MeshExtrusion.Edge[];
private var sections : Array = new Array();
class ExtrudedTrailSection
{
var point : Vector3;
var matrix : Matrix4x4;
var time : float;
}
function Start ()
{
srcMesh = (gameObject.GetComponent(MeshFilter) as MeshFilter).sharedMesh;
precomputedEdges = MeshExtrusion.BuildManifoldEdges(srcMesh);
}
function Update () {
var position : Vector3 = transform.position;
var now : float = Time.time;
while (sections.length > 0 && now > sections[sections.length - 1].time + time) {
sections.Pop();
}
if (sections.length == 0 || (sections[0].point - position).sqrMagnitude > minDistance * minDistance)
{
var section = ExtrudedTrailSection ();
section.point = position;
section.matrix = transform.localToWorldMatrix;
section.time = now;
sections.Unshift(section);
}
if (sections.length < 2)
return;
var worldToLocal = transform.worldToLocalMatrix;
var finalSections = new Matrix4x4[sections.length];
var previousRotation : Quaternion;
for (var i=0;i<sections.length;i++)
{
if (autoCalculateOrientation)
{
if (i == 0)
{
var direction = sections[0].point - sections[1].point;
var rotation = Quaternion.LookRotation(direction, Vector3.up);
previousRotation = rotation;
finalSections[i] = worldToLocal * Matrix4x4.TRS(position, rotation, Vector3.one);
}
else if (i != sections.length - 1)
{
direction = sections[i].point - sections[i+1].point;
rotation = Quaternion.LookRotation(direction, Vector3.up);
if (Quaternion.Angle (previousRotation, rotation) > 20)
rotation = Quaternion.Slerp(previousRotation, rotation, 0.5);
previousRotation = rotation;
finalSections[i] = worldToLocal * Matrix4x4.TRS(sections[i].point, rotation, Vector3.one);
}
else
{
finalSections[i] = finalSections[i-1];
}
}
else
{
if (i == 0)
{
finalSections[i] = Matrix4x4.identity;
}
else
{
finalSections[i] = worldToLocal * sections[i].matrix;
}
}
}
// Rebuild the extrusion mesh
MeshExtrusion.ExtrudeMesh (srcMesh, (gameObject.GetComponent(MeshFilter) as MeshFilter).mesh, finalSections, precomputedEdges, invertFaces);
}
@script RequireComponent (MeshFilter)
You'll need to post more code, this isn't enough to tell. Please include line number and indicate that line if you can.
There is. About the line there are too many, the var is at 7 line and is used for example at 23 more or less.
Hi, were you able to fix this? I'm getting the same error when trying to import the Procedural project (gotten from the assets store) into an existing project. But if I import the Procedural into an empty project everything works fine.
Answer by msknapp · Sep 07, 2011 at 06:13 PM
Have you tried using the fully qualified name of the Array class? Remember that the .net framework includes an "Array" class but it does not have a "time" field. Try using "UnityEngine.Array();"
Tried, seems that is not working, the same error. It is an array, but I don't know what contain that array so I can define the var as an array of this kind of "object".
Your answer
Follow this Question
Related Questions
how to Stack + Deform mesh along a path? 1 Answer
Extrude building mesh like Showdrop 1 Answer
Generate and extrude a mesh 2 Answers
Generating mesh - performance issues? 5 Answers
Getting errors with extrusion script. 0 Answers