public void setAverageVerticeLength()
{
// Set to low value
float totalDistance = 0;
float verticesExplored = 0;
// Search through each vertex
for(int i = 0; i < this.vertices.Length; ++i)
{
// Check if vertice is null or not
if(this.vertices[i] != Vector3.zero)
{
// Get connecting verts
foreach(int vert in this.getMovesVertex(i))
{
++verticesExplored;
totalDistance += DistanceCalculator.squareEuclidianDistance(this.vertices[i], this.vertices[vert]);
}
}
}
// Calculate average and set square vertex length
this.avgVertexlength = totalDistance / verticesExplored;
}
public override void OnInspectorGUI() { DrawDefaultInspector(); if (GUILayout.Button("Bake")) { Debug.Log("beggining baking"); foreach (Object targ in targets) { VertexNavigation vertNav = targ as VertexNavigation; vertNav.buildTable(); } Debug.Log("done baking"); } if (GUILayout.Button("Kill Bake")) { foreach (Object targ in targets) { VertexNavigation vertNav = targ as VertexNavigation; vertNav.killTable(); } Debug.Log("Killed table"); } if (GUILayout.Button("Modify Vertice Height")) { Debug.Log("Modifying height of vertices"); foreach (Object targ in targets) { VertexNavigation vertNav = targ as VertexNavigation; vertNav.modifyVerticeHeights(); } Debug.Log("finished modifying height of vertices"); } if (GUILayout.Button("Set Average Vertex Length")) { foreach (Object targ in targets) { VertexNavigation vertNav = targ as VertexNavigation; vertNav.setAverageVerticeLength(); Debug.Log("average vertex length: " + vertNav.avgVertexlength); } } }