private void OnPlaneGenerationGUI() { planeGenerationData = planeGenerationData ?? new PlaneGenerationData(); planeGenerationData.direction = (PlaneGenerationData.Direction)UG.EnumPopup("平面方向", planeGenerationData.direction); UG.BeginHorizontal(); planeGenerationData.length = UG.DelayedFloatField("长", planeGenerationData.length); planeGenerationData.width = UG.DelayedFloatField("宽", planeGenerationData.width); UG.EndHorizontal(); UG.BeginHorizontal(); planeGenerationData.verticesPerLength = UG.DelayedIntField("长顶点数", planeGenerationData.verticesPerLength); planeGenerationData.verticesPerWidth = UG.DelayedIntField("宽顶点数", planeGenerationData.verticesPerWidth); UG.EndHorizontal(); bool legal = true; string errorMessage = String.Empty; if (defaultMaterial == null) { legal = false; errorMessage += "默认材质不能为空"; } if (planeGenerationData.length <= 0) { legal = false; errorMessage += "平面长必须大于0\n"; } if (planeGenerationData.width <= 0) { legal = false; errorMessage += "平面宽必须大于0\n"; } if (planeGenerationData.verticesPerLength <= 0) { legal = false; errorMessage += "平面长顶点数必须大于0\n"; } if (planeGenerationData.verticesPerWidth <= 0) { legal = false; errorMessage += "平面宽顶点数必须大于0\n"; } if (legal) { if (GUILayout.Button("生成")) { MeshTool.InstantiatePlane(planeGenerationData, defaultMaterial); } } else { UG.HelpBox(errorMessage, MessageType.Error); } }