public void AddGizmoLength(Gizmo gizmo) { if (!(gizmo is GizmoLength)) { return; } GizmoLength gizmoLength = (GizmoLength)gizmo; GameObject gizmoObject = new GameObject("length"); gizmoObject.transform.SetParent(gizmoWrapper.transform); LengthBehaviour lengthBehaviour = gizmoObject.AddComponent <LengthBehaviour>(); lengthBehaviour.Init(geoCamera); EdgeRefer edge = gizmoLength.edge; Vector3 center = geometry.Center(); Vector3 vertex1 = geometry.UnitVector(edge.id1); Vector3 vertex2 = geometry.UnitVector(edge.id2); float length = geometry.EdgeLength(edge.id1, edge.id2); lengthBehaviour.SetData(center, vertex1, vertex2, length); gizmoMap.Add(gizmoLength, lengthBehaviour); }
public void UpdateGizmoLength(Gizmo gizmo) { if (!(gizmo is GizmoLength)) { return; } GizmoLength gizmoLength = (GizmoLength)gizmo; LengthBehaviour lengthBehaviour = (LengthBehaviour)gizmoMap[gizmoLength]; EdgeRefer edge = gizmoLength.edge; Vector3 center = geometry.Center(); Vector3 vertex1 = geometry.UnitVector(edge.id1); Vector3 vertex2 = geometry.UnitVector(edge.id2); float length = geometry.EdgeLength(edge.id1, edge.id2); lengthBehaviour.SetData(center, vertex1, vertex2, length); }