void GrassField() { m_Selected = UEditorTools.SelectionGrid(m_Selected, m_Editor.terrain.data.grassData.grasses.Select(grass => grass.texture).ToArray(), 0x40, "No Grass Added."); GUILayout.Space(2); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Edit Grasses...", EditorStyles.popup, GUILayout.Width(93))) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Add Grass"), false, () => { UGrassWizard.GetWizard("Add Grass", "Add").InitializeDefaults(m_Editor); m_Editor.Repaint(); }); if (m_Selected == -1) { menu.AddDisabledItem(new GUIContent("Edit Grass")); } else { menu.AddItem(new GUIContent("Edit Grass"), false, () => { UGrassWizard wizard = UGrassWizard.GetWizard("Edit Grass", "Apply"); wizard.InitializeDefaults(m_Editor); wizard.texture = grass.texture; wizard.grassIndex = m_Selected; wizard.OnWizardUpdate(); m_Editor.Repaint(); }); } if (m_Selected == -1) { menu.AddDisabledItem(new GUIContent("Remove Grass")); } else { menu.AddItem(new GUIContent("Remove Grass"), false, () => { m_Editor.terrain.data.grassData.RemoveAt(m_Selected); m_Selected = -1; m_Editor.Repaint(); }); } menu.ShowAsContext(); Event.current.Use(); } EditorGUILayout.EndHorizontal(); }
void SubMeshField() { int selected = m_SelectedSM; GUILayout.Label("SubMeshes", EditorStyles.boldLabel); Mesh[] subMeshes = m_Editor.terrain.GetAllSubMesh(); m_SelectedSM = UEditorTools.SelectionGrid(m_SelectedSM, subMeshes.Select(sm => { Texture2D tex = null; while (!CheckPreviewReady(sm, ref tex)) { } tex = AssetPreview.GetAssetPreview(sm); return(tex); }).ToArray(), 0x40, "No SubMesh."); if (selected != m_SelectedSM) { m_SelectedPass = 0; m_SelectedTex = -1; } }
public static Texture2D Field(Texture2D brush) { GUILayout.Label("Brushes", EditorStyles.boldLabel); int selectedBrush = -1; if (brush != null) { for (int i = 0, max = UIcon.brushes.Length; i < max; i++) { if (brush == UIcon.brushes[i]) { selectedBrush = i; break; } } } selectedBrush = UEditorTools.SelectionGrid(selectedBrush, UIcon.brushes, 0x20, "No brushes defined."); if (selectedBrush == -1) { return(null); } return(UIcon.brushes[selectedBrush]); }
public static int IntFiled(int index) { GUILayout.Label("Brushes", EditorStyles.boldLabel); index = UEditorTools.SelectionGrid(index, UIcon.brushes, 0x20, "No brushes defined."); return(index); }