public override void OnInspectorGUI() { GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label(icon, LODGUI.Styles.LODRendererButton, GUILayout.MaxWidth(32), GUILayout.MaxHeight(32)); GUILayout.Label("Lod Data", LODGUI.titleLableStyle); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); LodNode action = null; search = GuiSearch(search); if (Data.nodes != null) { for (int i = 0; i < Data.nodes.Length; i++) { var node = Data.nodes[i]; if (node.Match(search)) { var op = node.GUI(); if (op == LodOP.DELETE) { Data.nodes = LodUtil.Remv <LodNode>(Data.nodes, i); break; } else if (op == LodOP.DETAIL) { action = node; } } } } GuiButtons(); GUILayout.EndVertical(); if (action != null) { OpenLodWin(action); } }
public LodOP GUI() { LodOP lodOP = LodOP.NONE; EditorGUILayout.BeginHorizontal(); folder = EditorGUILayout.Foldout(folder, desc); if (GUILayout.Button("X", GUILayout.MaxWidth(36))) { lodOP = LodOP.DELETE; } EditorGUILayout.EndHorizontal(); if (folder) { obj = EditorGUILayout.ObjectField("fbx", obj, typeof(GameObject), false); if (obj == null) { var path = dir + "/" + prefab + "_LOD0.fbx"; obj = AssetDatabase.LoadAssetAtPath <GameObject>(path); } else { var path = AssetDatabase.GetAssetPath(obj); int idx = path.LastIndexOf("/"); dir = path.Substring(0, idx); int idx2 = path.LastIndexOf("_LOD"); if (idx2 > 0) { prefab = path.Substring(idx + 1, idx2 - idx - 1); } else { EditorGUILayout.HelpBox("fbx's name is not match lod rule", MessageType.Error); } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(prefab); if (GUILayout.Button("Add", GUILayout.MaxWidth(80))) { LodUtil.Add <float>(ref levels, levels[levels.Length - 1] / 2.0f); LodUtil.Add <ExMesh>(ref format, ExMesh.UV1); } if (GUILayout.Button("Detail", GUILayout.MaxWidth(80))) { lodOP = LodOP.DETAIL; } EditorGUILayout.EndHorizontal(); comment = EditorGUILayout.TextField("备注: ", comment); bool sort = true; for (int i = 0; i < levels.Length; i++) { bool del = false; EditorGUILayout.BeginHorizontal(); levels[i] = EditorGUILayout.FloatField(" - lod" + i, levels[i]); if (format == null || format.Length <= i) { format = defaultFmt; } format[i] = (ExMesh)EditorGUILayout.EnumFlagsField(format[i], GUILayout.MaxWidth(80)); if (GUILayout.Button("X", GUILayout.MaxWidth(36))) { del = true; } EditorGUILayout.EndHorizontal(); if (levels[i] <= 0 || levels[i] >= 1) { EditorGUILayout.HelpBox("lod range [0-1]", MessageType.Error); } if (del) { levels = LodUtil.Remv <float>(levels, i); format = LodUtil.Remv <ExMesh>(format, i); break; } if (i > 0 && levels[i] >= levels[i - 1]) { sort = false; } } if (!sort) { EditorGUILayout.HelpBox("lod sort invalid", MessageType.Error); } } return(lodOP); }