private void OnDrawGizmos() { #if UNITY_EDITOR if (!isEnabled) { return; } int itemCount = _items.Count; for (int i = 0; i < itemCount; i++) { GizmoLabelItem item = _items[i]; switch (item.type) { case GizmoLabelItem.Types.Label: Handles.color = Color.white; Handles.Label(item.labelPos, item.text); break; case GizmoLabelItem.Types.LabelLineTo: Handles.color = item.colour; Handles.Label(item.labelPos, item.text); Handles.DrawLine(item.pointA, item.pointB); break; case GizmoLabelItem.Types.LabelDirection: Handles.color = item.colour; float handleSize = HandleUtility.GetHandleSize(item.labelPos); Vector3 position = item.labelPos + item.pointA.normalized * handleSize; Handles.Label(position, item.text); UnityVersionWrapper.HandlesArrowCap(0, item.labelPos, Quaternion.LookRotation(item.pointA), handleSize); break; } } #endif }
public static void DrawMesh(Camera cam = null) { int layerCount = LAYERS.Count; GUIStyle gStyle = BuildingEditor.SceneLabel; for (int l = 0; l < layerCount; l++) { SceneMeshLayer layer = LAYERS[l]; int shapeCount = layer.shapes.Count; for (int s = 0; s < shapeCount; s++) { Handles.color = layer.shapes[s].col; Handles.DrawAAConvexPolygon(layer.shapes[s].points); } int lineCount = layer.lines.Count; for (int ln = 0; ln < lineCount; ln++) { Handles.color = layer.lines[ln].col; Handles.DrawLine(layer.lines[ln].a, layer.lines[ln].b); } int dotCount = layer.dots.Count; for (int d = 0; d < dotCount; d++) { Handles.color = layer.dots[d].col; float size = layer.dots[d].size * HandleUtility.GetHandleSize(layer.dots[d].position); UnityVersionWrapper.HandlesDotCap(0, layer.dots[d].position, Quaternion.identity, size); } int labelCount = layer.labels.Count; for (int lb = 0; lb < labelCount; lb++) { Vector3 position = layer.labels[lb].position; if (cam != null) { float dot = Vector3.Dot((position - cam.transform.position).normalized, cam.transform.forward); if (dot < 0) { continue; } } Handles.Label(position, layer.labels[lb].content, gStyle); } } }
private void Update() { HUtils.log(); #if UNITY_EDITOR if (building.regenerate) { UnityEditor.Undo.SetCurrentGroupName("Regenerate Building"); int group = UnityEditor.Undo.GetCurrentGroup(); building.MarkGenerated(); GenerateMesh.Generate(building); Renderer[] renders = transform.GetComponentsInChildren <Renderer>(); UnityVersionWrapper.SetSelectedWireframeHidden(renders, !building.showWireframes); UnityEditor.Undo.CollapseUndoOperations(group); } #endif }
/// <summary> /// /// </summary> /// <param name="volume"></param> /// <returns>The point index of the wall extension. No point will return -1</returns> public static int OnSelectWall(Volume volume) { Vector3 position = volume.transform.position; Quaternion rotation = volume.transform.rotation; int numberOfPoints = volume.numberOfPoints; for (int p = 0; p < numberOfPoints; p++) { Vector3 p0 = rotation * volume.BuildingPoint(p) + position; Vector3 p1 = rotation * volume.BuildingPoint((p + 1) % numberOfPoints) + position; Vector3 wC = Vector3.Lerp(p0, p1, 0.5f); float pointHandleSize = HandleUtility.GetHandleSize(wC); if (UnityVersionWrapper.HandlesDotButton(wC, Quaternion.identity, pointHandleSize * 0.1f, pointHandleSize * 0.1f)) { return(p); } } return(-1);//no point selected }