private void OnEnable() { intersection = (DiamondIntersection)target; if (intersection.globalSettings == null) { intersection.globalSettings = GameObject.FindObjectOfType <GlobalSettings>(); } if (intersection.transform.childCount == 0) { GameObject sides = new GameObject("Sides"); sides.transform.SetParent(intersection.transform); sides.transform.localPosition = Vector3.zero; sides.transform.localRotation = Quaternion.Euler(Vector3.zero); sides.hideFlags = HideFlags.NotEditable; Misc.AddIntersectionSide(intersection.transform.GetChild(0), intersection.globalSettings, "Upper Left"); Misc.AddIntersectionSide(intersection.transform.GetChild(0), intersection.globalSettings, "Upper Right"); Misc.AddIntersectionSide(intersection.transform.GetChild(0), intersection.globalSettings, "Lower Left"); Misc.AddIntersectionSide(intersection.transform.GetChild(0), intersection.globalSettings, "Lower Right"); GameObject mainMesh = new GameObject("Main Mesh"); mainMesh.transform.SetParent(intersection.transform); mainMesh.transform.localPosition = Vector3.zero; mainMesh.transform.localRotation = Quaternion.Euler(Vector3.zero); mainMesh.hideFlags = HideFlags.NotEditable; mainMesh.AddComponent <MeshFilter>(); mainMesh.AddComponent <MeshRenderer>(); mainMesh.AddComponent <MeshCollider>(); } lastTool = Tools.current; Tools.current = Tool.None; intersection.GenerateMeshes(); }