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 _= worldToLocal * Matrix4x4.TRS(position, rotation, Vector3.one); _
-
}* -
else if (i != sections.length - 1)* -
{ *
_ direction = sections*.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 = worldToLocal * Matrix4x4.TRS(sections*.point, rotation, Vector3.one);*
* }*
* else*
* {*
_ finalSections = finalSections[i-1];
* }
}
else*
* {
if (i == 0)
{
finalSections = Matrix4x4.identity;
}
else*
* {_
finalSections _= worldToLocal * sections.matrix;
}
}
}
// Rebuild the extrusion mesh
MeshExtrusion.ExtrudeMesh (srcMesh, (gameObject.GetComponent(MeshFilter) as MeshFilter).mesh, finalSections, precomputedEdges, invertFaces);
}
@script RequireComponent (MeshFilter)*_