Close a group started with BeginVertical.
private void EndGUI() { GL.Space(5); EGL.EndHorizontal(); GL.Space(2); EGL.EndVertical(); }
/* TODO: Show the below struct editors using standard inspector drawing tools */ bool ShowSplatPrototype(SplatPrototype splatPrototype, int id) { bool removeThis = false; EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label(id.ToString() + ". " + (splatPrototype.texture != null ? splatPrototype.texture.name : "")); EGL.BeginHorizontal(); { splatPrototype.texture = EGL.ObjectField(splatPrototype.texture, typeof(Texture2D), false, GUILayout.Width(64f), GUILayout.Height(64f)) as Texture2D; EGL.BeginVertical(); { splatPrototype.tileOffset = EGL.Vector2Field("Tile Offset", splatPrototype.tileOffset); splatPrototype.tileSize = EGL.Vector2Field("Tile Size", splatPrototype.tileSize); } EGL.EndVertical(); if (GUILayout.Button("Remove", GUILayout.Width(64f), GUILayout.Height(64f))) { removeThis = true; } } EGL.EndHorizontal(); } EGL.EndVertical(); return(removeThis); }
void ShowHeightmaps() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; EGL.BeginVertical(); { GUILayout.Label("The settings for processing heightmaps."); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Postfix for heightmap files."); importCfg.HeightmapTag = EGL.TextField("Name postfix", importCfg.HeightmapTag); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Heightmap file specifications. Please use raw file\nwith x^2+1 dimensions."); importCfg.HeightmapExtention = EGL.TextField("File extention", importCfg.HeightmapExtention); importCfg.HeightmapFlipX = EGL.Toggle("Mirror X", importCfg.HeightmapFlipX); importCfg.HeightmapFlipY = EGL.Toggle("Mirror Y", importCfg.HeightmapFlipY); importCfg.HeightFormat = (HeightfileFormat)EditorGUILayout.EnumPopup("Byte Format", importCfg.HeightFormat); } EGL.EndVertical(); } EGL.EndVertical(); }
void OnGUI() { EGL.LabelField("Generated texture", EditorStyles.boldLabel); EGL.LabelField("Show channels:"); EGL.BeginHorizontal(); _c[3] = GUILayout.Toggle(_c[3], "A"); EG.BeginDisabledGroup(_c[3]); _c[0] = GUILayout.Toggle(_c[0], "R"); _c[1] = GUILayout.Toggle(_c[1], "G"); _c[2] = GUILayout.Toggle(_c[2], "B"); EG.EndDisabledGroup(); EGL.EndHorizontal(); EGL.LabelField("Zoom"); zoom = EGL.Slider(zoom, 0.2f, 3f); EGL.LabelField("Slice"); slice = EGL.Slider(slice, 0f, 1f); Rect r_tex = EGL.BeginVertical(GUILayout.ExpandHeight(true)); r_tex.height = r_tex.width = Mathf.Min(r_tex.height, r_tex.width); if (texture) { previewMaterial.SetFloat("_Zoom", zoom); previewMaterial.SetFloat("_Slice", slice); previewMaterial.SetVector("_Channels", ChannelVector()); EG.DrawPreviewTexture(r_tex, texture, previewMaterial); } EGL.EndVertical(); }
bool ShowTreePrototype(TreePrototype treePrototype, int id) { bool removeThis = false; EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label(id.ToString() + ". " + (treePrototype.prefab != null ? treePrototype.prefab.name : "")); EGL.BeginHorizontal(); { treePrototype.prefab = EGL.ObjectField(treePrototype.prefab, typeof(GameObject), false) as GameObject; EGL.BeginVertical(); { treePrototype.bendFactor = EGL.FloatField("Bend Factor", treePrototype.bendFactor); } EGL.EndVertical(); if (GUILayout.Button("Remove", GUILayout.Width(64f), GUILayout.Height(64f))) { removeThis = true; } } EGL.EndHorizontal(); } EGL.EndVertical(); return(removeThis); }
void DrawHyperLinkInputSection(SP dialog) { if (!isHyperlinkButtonClicked) { return; } if (string.IsNullOrEmpty(hyperlinkSavedText) || hyperLinkSavedStartIndex < 0 || hyperlinkSavedEndIndex < 0) { return; } EGL.BeginVertical(ES.helpBox); EGL.LabelField("Selected Text:", ES.miniBoldLabel); EGL.LabelField(hyperlinkSavedText, ES.helpBox); EGL.LabelField("Link:", ES.miniBoldLabel); savedLink = EGL.TextField(string.IsNullOrEmpty(savedLink) ? HyperlinkPrefix : savedLink); if (GUILayout.Button("Insert hyperlink")) { string newText = string.Format("<a href=\"{0}\">{1}</a>", savedLink, hyperlinkSavedText); ReplaceTextInProperty(dialog, hyperLinkSavedStartIndex, hyperlinkSavedEndIndex, newText); isHyperlinkButtonClicked = false; } EGL.EndVertical(); EGL.Space(); }
void ShowSettings() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; EGL.BeginVertical(); { EGL.Separator(); GUILayout.Label("LOD Levels"); EGL.BeginVertical(GuiUtils.Skin.box); { if (importCfg.LodLevels.Count >= 4) { GUI.enabled = false; } if (GUILayout.Button("Add LOD Level")) { importCfg.LodLevels.Add(new LodLevel()); importCfg.IsDirty = true; // Todo: Nasty } GUI.enabled = true; // Show the list of LODS EGL.BeginVertical(); { _lodScrollPos = EGL.BeginScrollView(_lodScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height)); { var removeThese = new List <LodLevel>(); int i = 0; foreach (LodLevel lod in importCfg.LodLevels) { if (ShowLodLevel(lod, i)) { removeThese.Add(lod); importCfg.IsDirty = true; // Nasty } i++; } foreach (LodLevel lod in removeThese) { importCfg.LodLevels.Remove(lod); } } EGL.EndScrollView(); } EGL.EndVertical(); EGL.Space(); GUILayout.Label("Control how many assets are processed in one go."); importCfg.BatchLimit = EGL.IntField("Batch limit", importCfg.BatchLimit); GUILayout.Label("Larger batches mean faster processing but require\nmore memory. Change this with care, or Unity's\nmemory might run out!"); } EGL.EndVertical(); } EGL.EndVertical(); }
bool ShowLodLevel(LodLevel lod, int index) { bool removeThis = false; EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("[" + index + "]"); lod.Level = EGL.IntField("Lod Level", lod.Level); GUILayout.BeginHorizontal(); { lod.FolderPath = EGL.TextField("Folder Path", lod.FolderPath); if (GUILayout.Button("Browse", GUILayout.Width(50f))) { lod.FolderPath = UPath.GetProjectPath(EditorUtility.OpenFolderPanel("Browse", lod.FolderPath, Application.dataPath)); } } GUILayout.EndHorizontal(); lod.GridSize = EGL.IntField("Grid Size", lod.GridSize); lod.HeightmapResolution = EGL.IntField("Heightmap Resolution (px)", lod.HeightmapResolution); lod.SplatmapResolution = EGL.IntField("Splatmap Resolution (px)", lod.SplatmapResolution); lod.HasDetailMap = EGL.Toggle("Use Detail Map?", lod.HasDetailMap); lod.HasTreeMap = EGL.Toggle("Use Tree Map?", lod.HasTreeMap); if (lod.HasDetailMap) { lod.DetailmapResolution = EGL.IntField("Detailmap Resolution (px)", lod.DetailmapResolution); lod.DetailResolutionPerPatch = EGL.IntField("Detailmap Patch Size (px)", lod.DetailResolutionPerPatch); } EGL.Space(); GUILayout.Label("In-game terrain dimensions."); lod.TerrainWidth = EGL.FloatField("Width & Length (m)", lod.TerrainWidth); lod.TerrainHeight = EGL.FloatField("Height (m)", lod.TerrainHeight); EGL.Space(); GUILayout.Label("Relief Terrain Configuration"); lod.ColormapResolution = EGL.IntField("Colormap Resolution", lod.ColormapResolution); lod.NormalmapResolution = EGL.IntField("Normalmap Resolution", lod.NormalmapResolution); EGL.Space(); if (GUILayout.Button("Remove", GUILayout.Width(64f), GUILayout.Height(64f))) { removeThis = true; } } EGL.EndVertical(); return(removeThis); }
private void TextureGUI() { data.curve = UGL.CurveField(data.curve); int?toRemove = null; for (int i = 0; i < data.textureNames.Count; i++) { UGL.BeginHorizontal(); data.textureNames[i] = UGL.DelayedTextField(data.textureNames[i], GUILayout.MaxWidth(Screen.width)); GUILayout.FlexibleSpace(); Texture2D oldVal = i < data.textures.Count ? data.textures[i]: null; Texture2D newVal = (Texture2D)UGL.ObjectField("", oldVal, typeof(Texture2D), true, GUILayout.Width(100)); UGL.BeginVertical(); if (GUILayout.Button("Set As Curve", GUILayout.Width(100))) { Texture2D text = new Texture2D(100, 1); for (int j = 0; j < text.width; j++) { float sample = data.curve.Evaluate((float)j / text.width); text.SetPixel(j, 0, new Color(sample, sample, sample)); } text.Apply(); if (text != oldVal) { string path = AssetDatabase.GetAssetPath(data); AssetDatabase.AddObjectToAsset(text, path); newVal = text; } } GUI.color = Color.red; if (GUILayout.Button("-", GUILayout.Width(100))) { toRemove = i; } UGL.EndVertical(); GUI.color = Color.white; if (oldVal != newVal) { if (!data.textures.Contains(oldVal)) { data.textures.Add(newVal); } else { data.textures[data.textures.IndexOf(oldVal)] = newVal; } } UGL.EndHorizontal(); } if (toRemove != null) { data.textureNames.RemoveAt((int)toRemove); } }
void OnGUI() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; if (editorUtilities == null) { GUILayout.Label("No running instance of LandmassImporter found"); return; } if (editorUtilities.IsProcessing) { ShowProgressBar(); } GUI.enabled = !editorUtilities.IsProcessing; EGL.BeginVertical(); { EGL.Separator(); _currentState = (MenuState)GUILayout.Toolbar((int)_currentState, menuTitles); EGL.BeginHorizontal(); { _globalScrollPos = EGL.BeginScrollView(_globalScrollPos, GuiUtils.Skin.box); { EGL.BeginVertical(); { EGL.Separator(); _menus[_currentState](); GUILayout.FlexibleSpace(); EGL.Separator(); } EGL.EndVertical(); } EGL.EndScrollView(); } EGL.EndHorizontal(); EGL.Separator(); ShowSaveButtons(); GUILayout.Space(16); } EGL.EndVertical(); GUI.enabled = true; }
/// <summary> /// Draw an element inside the target array property. /// </summary> /// <param name="arrayProperty">Array property.</param> /// <param name="elementIndex">Element index to get the element out of the array property.</param> /// <param name="getSelectedIndex">Get selected index.</param> /// <param name="setSelectedIndex">Set selected index.</param> /// <param name="drawInnerProperties">Action to draw inner properties of the element property.</param> void DrawArrayElement(SP arrayProperty, int elementIndex, string minSizeWarning, int minSize, Func <int> getSelectedIndex, Action <int> setSelectedIndex, Action <SP> drawInnerProperties) { var elementProperty = arrayProperty.GetArrayElementAtIndex(elementIndex); EGL.BeginHorizontal(); EGL.BeginVertical(E_SM.GetCustomStyle("Item Box")); if (drawInnerProperties != null) { drawInnerProperties(elementProperty); } EGL.EndVertical(); var deleteIcon = EditorGUIUtility.IconContent("Toolbar Minus"); var deleteButtonStyle = GUIStyle.none; var deleteButtonMinWidth = GUILayout.MaxWidth(E_SM.smallButtonWidth); /// Draw a button to remove element property from array property. bool canDelete = arrayProperty.arraySize > minSize; EditorGUI.BeginDisabledGroup(!canDelete); // Disable the "-" button if (GUILayout.Button(deleteIcon, deleteButtonStyle, deleteButtonMinWidth)) { if (arrayProperty.arraySize > minSize) { if (getSelectedIndex() > elementIndex) { setSelectedIndex(getSelectedIndex() - 1); } arrayProperty.DeleteArrayElementAtIndex(elementIndex); /// We need to return here so the deleted element won't be displayed in the codes below, /// causing unexpected error. return; } if (!string.IsNullOrEmpty(minSizeWarning)) { Debug.Log(minSizeWarning); } } EditorGUI.EndDisabledGroup(); EGL.EndHorizontal(); }
void ShowHelp() { EGL.BeginVertical(); { GUILayout.Label("Landmass version: " + version); // Todo: Version number from xml? EGL.Separator(); GUILayout.Label("Made by Martijn Zandvliet"); EGL.Separator(); if (GUILayout.Button("Show Documentation")) { Application.OpenURL(readmeUrl); } } EGL.EndVertical(); }
void ShowTerrainSettings() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; TerrainConfiguration terrainStreamingConfiguration = importCfg.TerrainConfiguration; EGL.BeginVertical(); { EGL.BeginVertical(GuiUtils.Skin.box); { if (GUILayout.Button("Apply to selected TerrainData assets")) { QueueCall(editorUtilities.ApplyDimensionsToSelection); } } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("In-game terrain LOD settings."); terrainStreamingConfiguration.HeightmapPixelError = EGL.Slider("Pixel Error", terrainStreamingConfiguration.HeightmapPixelError, 1f, 200f); terrainStreamingConfiguration.BasemapDistance = EGL.FloatField("Basemap Dist.", terrainStreamingConfiguration.BasemapDistance); terrainStreamingConfiguration.CastShadows = EGL.Toggle("Cast Shadows", terrainStreamingConfiguration.CastShadows); EGL.Separator(); terrainStreamingConfiguration.DetailObjectDistance = EGL.Slider("Detail Distance", terrainStreamingConfiguration.DetailObjectDistance, 0f, 250f); terrainStreamingConfiguration.DetailObjectDensity = EGL.Slider("Detail Density", terrainStreamingConfiguration.DetailObjectDensity, 0f, 1f); terrainStreamingConfiguration.TreeDistance = EGL.Slider("Tree Distance", terrainStreamingConfiguration.TreeDistance, 0f, 2000f); terrainStreamingConfiguration.TreeBillboardDistance = EGL.Slider("Billboard Start", terrainStreamingConfiguration.TreeBillboardDistance, 50f, 2000f); terrainStreamingConfiguration.TreeCrossFadeLength = EGL.Slider("Fade Length", terrainStreamingConfiguration.TreeCrossFadeLength, 0f, 200f); terrainStreamingConfiguration.TreeMaximumFullLODCount = EGL.IntSlider("Max Mesh Trees", terrainStreamingConfiguration.TreeMaximumFullLODCount, 0, 500); EGL.Separator(); if (GUILayout.Button("Apply to selected Scene assets")) { QueueCall(editorUtilities.ApplyTerrainLODSettingsToSelection); } } EGL.EndVertical(); } EGL.EndVertical(); }
bool ShowDetailPrototype(DetailPrototype prototype, int id) { bool removeThis = false; EGL.BeginVertical(GuiUtils.Skin.box); { EGL.BeginHorizontal(); { EGL.BeginVertical(); { prototype.usePrototypeMesh = EGL.Toggle("Use Mesh", prototype.usePrototypeMesh); prototype.prototype = EGL.ObjectField(prototype.prototype, typeof(GameObject), false) as GameObject; prototype.prototypeTexture = EGL.ObjectField(prototype.prototypeTexture, typeof(Texture2D), false, GUILayout.Width(64f), GUILayout.Height(64f)) as Texture2D; } EGL.EndVertical(); EGL.BeginVertical(); { prototype.bendFactor = EGL.FloatField("Bend Factor", prototype.bendFactor); prototype.dryColor = EGL.ColorField("Dry Color", prototype.dryColor); prototype.healthyColor = EGL.ColorField("Healthy Color", prototype.healthyColor); prototype.maxHeight = EGL.FloatField("Max Height", prototype.maxHeight); prototype.minHeight = EGL.FloatField("Min Height", prototype.minHeight); prototype.maxWidth = EGL.FloatField("Max Width", prototype.maxWidth); prototype.minWidth = EGL.FloatField("Min Width", prototype.minWidth); prototype.noiseSpread = EGL.FloatField("Noise Spread", prototype.noiseSpread); prototype.renderMode = (DetailRenderMode)EGL.EnumPopup("Noise Spread", prototype.renderMode); } EGL.EndVertical(); if (GUILayout.Button("Remove", GUILayout.Width(64f), GUILayout.Height(64f))) { removeThis = true; } } EGL.EndHorizontal(); } EGL.EndVertical(); return(removeThis); }
void ShowTiledImport() { EGL.BeginVertical(); { EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Terrain input folder"); _tiledInputLodLevel = EGL.IntField("Lod Level", _tiledInputLodLevel); if (GUILayout.Button("Load into scene")) { _doTiledImport = true; } EGL.Separator(); } EGL.EndVertical(); } EGL.EndVertical(); }
private void OnGUI() { UG.BeginVertical(); chosenMeshGenerationType = (MeshGenerationType)UG.EnumPopup("网格生成类型", chosenMeshGenerationType); defaultMaterial = UG.ObjectField("默认材质", defaultMaterial, typeof(Material), false) as Material; switch (chosenMeshGenerationType) { case MeshGenerationType.Plane: OnPlaneGenerationGUI(); break; case MeshGenerationType.Box: OnBoxGenerationGUI(); break; case MeshGenerationType.Slope: OnSlopeGenerationGUI(); break; case MeshGenerationType.VolumetricFluid: OnVolumetricFluidGenerationGUI(); break; default: UG.HelpBox("需要选择一种网格生成类别进行编辑!", MessageType.Warning); break; } UG.EndVertical(); }
void ShowSaveButtons() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; EGL.BeginVertical(); { EGL.BeginHorizontal(); { EGL.Separator(); if (GUILayout.Button("Save Settings")) { editorUtilities.SaveSettings(); } if (GUILayout.Button("Load Settings")) { editorUtilities.LoadSettings(); } GUI.enabled = true; EGL.Separator(); } EGL.EndHorizontal(); EGL.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (importCfg.IsDirty) { GUILayout.Label("You have unsaved settings."); } GUILayout.FlexibleSpace(); } EGL.EndHorizontal(); } EGL.EndVertical(); }
internal bool DrawInspector() { serializedObject.Update(); GameObject go = target as GameObject; // Don't let icon be null as it will create null reference exceptions. Texture2D icon = (Texture2D)(Styles.typelessIcon.image); // Leave iconContent to be default if multiple objects not the same type. if (m_AllOfSamePrefabType) { icon = PrefabUtility.GetIconForGameObject(go); } // Can't do this in OnEnable since it will cause Styles static initializer to be called and // access properties on EditorStyles static class before that one has been initialized. if (m_OpenPrefabContent == null) { if (targets.Length == 1) { GameObject originalSourceOrVariant = PrefabUtility.GetOriginalSourceOrVariantRoot((GameObject)target); if (originalSourceOrVariant != null) { m_OpenPrefabContent = new GUIContent( Styles.openPrefab.text, string.Format(Styles.openPrefab.tooltip, originalSourceOrVariant.name)); } } if (m_OpenPrefabContent == null) { m_OpenPrefabContent = new GUIContent(Styles.openPrefab.text); } } EditorGUILayout.BeginHorizontal(); Vector2 dropDownSize = EditorGUI.GetObjectIconDropDownSize(kIconSize, kIconSize); EditorGUI.ObjectIconDropDown(GUILayoutUtility.GetRect(dropDownSize.x, dropDownSize.y, GUILayout.ExpandWidth(false)), targets, true, icon, m_Icon); DrawPostIconContent(); using (new EditorGUI.DisabledScope(m_ImmutableSelf)) { EditorGUILayout.BeginVertical(); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginHorizontal(GUILayout.Width(Styles.tagFieldWidth)); { GUILayout.FlexibleSpace(); // IsActive EditorGUI.PropertyField( GUILayoutUtility.GetRect(EditorStyles.toggle.padding.left, EditorGUIUtility.singleLineHeight, EditorStyles.toggle, GUILayout.ExpandWidth(false)), m_IsActive, GUIContent.none); } EditorGUILayout.EndHorizontal(); // Disable the name field of root GO in prefab asset using (new EditorGUI.DisabledScope(m_IsAsset && m_IsAssetRoot)) { // Name EditorGUILayout.DelayedTextField(m_Name, GUIContent.none, EditorStyles.boldTextField); } // Static flags toggle DoStaticToggleField(go); // Static flags dropdown DoStaticFlagsDropDown(go); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(EditorGUI.kControlVerticalSpacing); EditorGUILayout.BeginHorizontal(); { // Tag DoTagsField(go); EditorGUILayout.Space(EditorGUI.kDefaultSpacing, false); // Layer DoLayerField(go); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); // Prefab Toolbar if (EditorGUIUtility.comparisonViewMode == EditorGUIUtility.ComparisonViewMode.None) { EditorGUILayout.Space(EditorGUI.kControlVerticalSpacing); DoPrefabButtons(); } serializedObject.ApplyModifiedProperties(); return(true); }
public void Dispose() { EGL.EndVertical(); }
private void OnGUI() { UG.BeginVertical(); UG.BeginHorizontal(); UG.LabelField("当前数据源:" + (_dataPath.IsNullPath() ? "未在本地保存,已编辑内容随时可能丢失!" : _dataPath)); if (GUILayout.Button("选择")) { string path = EditorUtility.OpenFilePanelWithFilters("选择数据源文件", Application.dataPath + "/Hotassets/Data", new [] { "text", "txt" }); if (!string.IsNullOrEmpty(path)) { Dictionary <string, List <InterlocutionData> > temperData = null; try { temperData = JsonConvert.DeserializeObject <Dictionary <string, List <InterlocutionData> > >(File.ReadAllText(path)); } catch (JsonException) { temperData = _data; path = _dataPath; EditorApplication.Beep(); EditorUtility.DisplayDialog("异常捕获!", "数据源文件不能被正确加载,请确定.json文件的有效性", "知道了"); } finally { _data = temperData; _dataPath = path; } } } UG.EndHorizontal(); UG.BeginHorizontal(); int subject = UG.Popup("所属学科", _editingSubject, InterlocutionData.Keys); if (subject != _editingSubject) { _editingInterlocution = -1; } _editingSubject = subject; string key = InterlocutionData.Keys[_editingSubject]; UG.LabelField("分组", _editingSubject != InterlocutionData.Keys.Length - 1 ? Subject.ToSubject(InterlocutionData.Keys[_editingSubject]).group.ToString() : "无"); UG.EndHorizontal(); _scrollPostion = UG.BeginScrollView(_scrollPostion); if (!_data.ContainsKey(key)) { _data[key] = new List <InterlocutionData>(); } List <InterlocutionData> interlocutions = _data[key]; int _deletedInterlocution = -1; UG.LabelField("[已有 " + interlocutions.Count + " 道问答]"); for (int i = 0, l = interlocutions.Count; i < l; i++) { UG.BeginHorizontal(); UG.LabelField("[Q " + i + "] " + interlocutions[i].question); if (GUILayout.Button("编辑")) { _editingInterlocution = i; } if (GUILayout.Button("删除")) { EditorApplication.Beep(); if (EditorUtility.DisplayDialog("危险操作警告⚠️", "即将删除问答 [Q" + i + "] (该操作不可逆)", "确认", "取消")) { _deletedInterlocution = i; if (_editingInterlocution == _deletedInterlocution) { _editingInterlocution = -1; } } } UG.EndHorizontal(); } if (_deletedInterlocution != -1) { interlocutions.RemoveAt(_deletedInterlocution); } UG.EndScrollView(); if (GUILayout.Button("添加问答")) { _editingInterlocution = interlocutions.Count; interlocutions.Add(new InterlocutionData()); } UG.LabelField("问答编辑区"); if (_editingInterlocution != -1) { UG.LabelField("Q " + _editingInterlocution); InterlocutionData interlocution = interlocutions[_editingInterlocution]; interlocution.question = UG.TextArea(interlocution.question); interlocution.answer = (Option)UG.EnumPopup("正确选项", interlocution.answer); UG.LabelField("选项A"); interlocution.optionA = UG.TextArea(interlocution.optionA); UG.LabelField("选项B"); interlocution.optionB = UG.TextArea(interlocution.optionB); UG.LabelField("选项C"); interlocution.optionC = UG.TextArea(interlocution.optionC); UG.LabelField("选项D"); interlocution.optionD = UG.TextArea(interlocution.optionD); } else { UG.HelpBox("需要选择一个问答进行编辑!", MessageType.Warning); } if (GUILayout.Button("保存")) { bool toSave = true; bool toImport = false; if (_dataPath.IsNullPath()) { string path = EditorUtility.SaveFilePanel("保存问答数据", Application.dataPath + "/Hotassets/Data", "InterlocutionData", "txt"); if (string.IsNullOrEmpty(path)) { toSave = false; } else { _dataPath = path; toImport = true; } } if (toSave) { File.WriteAllText(_dataPath, JsonConvert.SerializeObject(_data)); EditorPrefs.SetString(DATA_SAVE_PATH, _dataPath); } if (toImport) { AssetDatabase.ImportAsset(_dataPath.Substring(_dataPath.IndexOf("Assets"))); } } UG.EndVertical(); }
void ShowSingleImport() { ImporterConfiguration config = LandmassEditorUtilities.Instance.ImportCfg; EGL.BeginVertical(); { EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Target Terrain"); _singleTargetTerrain = EGL.ObjectField(_singleTargetTerrain, typeof(Terrain), true, GUILayout.Width(240f)) as Terrain; } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { /* ----- Heightmap ----- */ GUILayout.Label("Heightmap"); GUILayout.BeginHorizontal(); { EGL.LabelField("Path", _singleHeightmapPath); if (GUILayout.Button("Browse", GUILayout.Width(60f))) { _singleHeightmapPath = EditorUtility.OpenFilePanel("Browse to Heightmap file", _singleHeightmapPath, "r16"); } } GUILayout.EndHorizontal(); GUI.enabled = _singleHeightmapPath != ""; { if (GUILayout.Button("Apply")) { LandmasImporter.ParseHeightmapFileToTerrain( _singleHeightmapPath, _singleTargetTerrain.terrainData, config.HeightFormat, config.HeightmapFlipX, config.HeightmapFlipY ); } } GUI.enabled = true; } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { /* ----- Splatmaps ------ */ GUILayout.Label("Splatmap"); _singleSplatmap = EGL.ObjectField(_singleSplatmap, typeof(Texture2D), false, GUILayout.Width(100f), GUILayout.Height(100f)) as Texture2D; EGL.Separator(); GUI.enabled = _singleSplatmap != null && _singleTargetTerrain != null; { if (GUILayout.Button("Apply")) { var splatmap = new float[_singleSplatmap.width, _singleSplatmap.height, 4]; LandmasImporter.TextureToSplatMap( _singleSplatmap, ref splatmap, false, true); LandmasImporter.Instance.NormalizeSplatmap(ref splatmap, config.NormalizationMode); LandmasImporter.Instance.ParseSplatmapToTerrain(splatmap, _singleTargetTerrain.terrainData); } } GUI.enabled = true; } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { /* ------ Treemaps ----- */ GUILayout.Label("Treemap"); _singleTreemap = EGL.ObjectField(_singleTreemap, typeof(Texture2D), false, GUILayout.Width(100f), GUILayout.Height(100f)) as Texture2D; GUI.enabled = _singleTreemap != null; { if (GUILayout.Button("Apply")) { LandmasImporter.ParseTreemapTexturesToTerrain(_singleTreemap, _singleTargetTerrain.terrainData); } } GUI.enabled = true; EGL.Separator(); if (GUILayout.Button("Flush Terrain")) { Terrain terrain = Selection.activeGameObject.GetComponent <Terrain>(); if (terrain) { Debug.Log("Flushing Terrain"); terrain.Flush(); } } } EGL.EndVertical(); } EGL.EndVertical(); }
void ShowDetailMaps() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; EGL.BeginVertical(); { GUILayout.Label("The settings for processing detail maps."); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Postfix for detailmap files."); importCfg.SplatmapTag = EGL.TextField("Name postfix", importCfg.SplatmapTag); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Splatmap file specifications. Please use x^2."); importCfg.SplatmapExtention = EGL.TextField("File extention", importCfg.SplatmapExtention); importCfg.SplatmapFlipX = EGL.Toggle("Mirror X", importCfg.SplatmapFlipX); importCfg.SplatmapFlipY = EGL.Toggle("Mirror Y", importCfg.SplatmapFlipY); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("The textures to assign. (Current count: " + editorUtilities.DetailPrototypes.Count + ")"); EGL.Separator(); EGL.BeginHorizontal(); { if (editorUtilities.DetailPrototypes.Count >= 8) { GUI.enabled = false; } if (GUILayout.Button("Add Prototype")) { editorUtilities.DetailPrototypes.Add(new DetailPrototype()); importCfg.IsDirty = true; // Todo: Nasty, because the above prototypes still need to be converted to a serializable format, which is not directly done here } GUI.enabled = true; } EGL.EndHorizontal(); // Show the list EGL.BeginVertical(); { _prototypeScrollPos = EGL.BeginScrollView(_prototypeScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height)); { List <DetailPrototype> removeThese = new List <DetailPrototype>(); int i = 0; foreach (DetailPrototype prototype in editorUtilities.DetailPrototypes) { if (ShowDetailPrototype(prototype, i)) { removeThese.Add(prototype); importCfg.IsDirty = true; // Nasty } i++; } foreach (DetailPrototype prototype in removeThese) { editorUtilities.DetailPrototypes.Remove(prototype); } } EGL.EndScrollView(); } EGL.EndVertical(); } EGL.EndVertical(); } EGL.EndVertical(); }
void ShowSplatmaps() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; EGL.BeginVertical(); { GUILayout.Label("The settings for processing splatmaps."); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Postfix for splatmap files."); importCfg.SplatmapTag = EGL.TextField("Name postfix", importCfg.SplatmapTag); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Splatmap file specifications. Please use x^2."); importCfg.SplatmapExtention = EGL.TextField("File extention", importCfg.SplatmapExtention); importCfg.SplatmapFlipX = EGL.Toggle("Mirror X", importCfg.SplatmapFlipX); importCfg.SplatmapFlipY = EGL.Toggle("Mirror Y", importCfg.SplatmapFlipY); importCfg.TrimEmptyChannels = EGL.Toggle("Trim empty", importCfg.TrimEmptyChannels); importCfg.NormalizationMode = (NormalizationMode)EditorGUILayout.EnumPopup("Normalize mode", importCfg.NormalizationMode); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("The textures to assign. (Current count: " + editorUtilities.SplatPrototypes.Count + ")"); EGL.Separator(); EGL.BeginHorizontal(); { if (editorUtilities.SplatPrototypes.Count >= 8) { GUI.enabled = false; } if (GUILayout.Button("Add Prototype")) { editorUtilities.SplatPrototypes.Add(new SplatPrototype()); importCfg.IsDirty = true; // Todo: Nasty } GUI.enabled = true; if (GUILayout.Button("Grab from Selected Terrain Object or Asset")) { GetPrototypesFromSelectedTerrain(); importCfg.IsDirty = true; // Todo: Nasty } } EGL.EndHorizontal(); // Show the list EGL.BeginVertical(); { _prototypeScrollPos = EGL.BeginScrollView(_prototypeScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height)); { List <SplatPrototype> removeThese = new List <SplatPrototype>(); int i = 0; foreach (SplatPrototype splatPrototype in editorUtilities.SplatPrototypes) { if (ShowSplatPrototype(splatPrototype, i)) { removeThese.Add(splatPrototype); importCfg.IsDirty = true; // Nasty } i++; } foreach (SplatPrototype splatPrototype in removeThese) { editorUtilities.SplatPrototypes.Remove(splatPrototype); } } EGL.EndScrollView(); } EGL.EndVertical(); } EGL.EndVertical(); } EGL.EndVertical(); }
private void OnGUI() { if (settings == null) { settings = ConstantGenerator.GetSettingsFile(); } if (logo == null) { logo = ConstantGenerator.GetLogo(); } if (border == null) { border = ConstantGenerator.GetBorder(); } EditorGUI.BeginChangeCheck(); StartGUI("Layers"); if (DrawGenButton()) { LayersGen.Generate(); window.Close(); } if (DrawForceGenButton()) { LayersGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Tags"); if (DrawGenButton()) { TagsGen.Generate(); window.Close(); } if (DrawForceGenButton()) { TagsGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Sort Layers"); if (DrawGenButton()) { SortingLayersGen.Generate(); window.Close(); } if (DrawForceGenButton()) { SortingLayersGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Scenes"); if (DrawGenButton()) { ScenesGen.Generate(); window.Close(); } if (DrawForceGenButton()) { ScenesGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Shader Props"); if (DrawGenButton()) { ShaderPropsGen.Generate(false); window.Close(); } if (DrawForceGenButton()) { ShaderPropsGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Anim Params"); if (DrawGenButton()) { AnimParamsGen.Generate(); window.Close(); } if (DrawForceGenButton()) { AnimParamsGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Anim Layers"); if (DrawGenButton()) { AnimLayersGen.Generate(); window.Close(); } if (DrawForceGenButton()) { AnimLayersGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Anim States"); if (DrawGenButton()) { AnimStatesGen.Generate(); window.Close(); } if (DrawForceGenButton()) { AnimStatesGen.ForceGenerate(); window.Close(); } EndGUI(); // ------------------------------------------------------------------------------------- StartGUI("Nav Areas"); if (DrawGenButton()) { NavAreasGen.Generate(); window.Close(); } if (DrawForceGenButton()) { NavAreasGen.ForceGenerate(); window.Close(); } EndGUI(); // ========================================================================================= DrawLine(Color.white, 2, 5); GUIStyle style = new GUIStyle(GUI.skin.button); style.alignment = TextAnchor.MiddleCenter; style.fontStyle = FontStyle.Bold; EGL.BeginHorizontal(); EGL.BeginVertical(); EGL.BeginHorizontal(); if (GL.Button("GENERATE ALL", style)) { LayersGen.Generate(); TagsGen.Generate(); SortingLayersGen.Generate(); ScenesGen.Generate(); ShaderPropsGen.Generate(false); AnimParamsGen.Generate(); AnimLayersGen.Generate(); AnimStatesGen.Generate(); window.Close(); } GL.FlexibleSpace(); EGL.EndHorizontal(); EGL.BeginHorizontal(); if (GL.Button("FORCE GENERATE ALL", style)) { LayersGen.ForceGenerate(); TagsGen.ForceGenerate(); SortingLayersGen.ForceGenerate(); ScenesGen.ForceGenerate(); ShaderPropsGen.ForceGenerate(); AnimParamsGen.ForceGenerate(); AnimLayersGen.ForceGenerate(); AnimStatesGen.ForceGenerate(); window.Close(); } GL.FlexibleSpace(); EGL.EndHorizontal(); EGL.EndVertical(); EGL.BeginVertical(); // --------------------------------------------------------------------------------------- Color genOnReloadColor; Color updateOnReloadColor; if (settings.regenerateOnMissing) { genOnReloadColor = Color.green * 2; } else { genOnReloadColor = Color.white * 1.5f; } if (settings.updateOnReload) { updateOnReloadColor = Color.green * 2; } else { updateOnReloadColor = Color.white * 1.5f; } EGL.BeginHorizontal(); GUI.backgroundColor = genOnReloadColor; if (GL.Button(new GUIContent("ReGen On Missing", "Automatically re-generates the constants file is none is present."), style)) { settings.regenerateOnMissing = !settings.regenerateOnMissing; EditorUtility.SetDirty(settings); } EGL.EndHorizontal(); EGL.BeginHorizontal(); GUI.backgroundColor = updateOnReloadColor; if (GL.Button(new GUIContent("Update On Reload", "Automatically re-generates the constants on editor recompile if any changes are detected."), style)) { settings.updateOnReload = !settings.updateOnReload; EditorUtility.SetDirty(settings); } EGL.EndHorizontal(); EGL.EndVertical(); EGL.EndHorizontal(); // ========================================================================================= DrawLine(Color.white, 2, 5); GUI.backgroundColor = Color.gray; GUI.contentColor = Color.white * 10; // check for unity versions using conditional directives // NOTE: there is no "BeginFoldoutHeaderGroup" in below 2019.1 #if UNITY_2019_OR_NEWER showFoldOut = EGL.BeginFoldoutHeaderGroup(showFoldOut, "Create Generator Script"); #else showFoldOut = EGL.Foldout(showFoldOut, "Create Generator Script"); #endif if (showFoldOut) { GL.Space(5); GUI.contentColor = Color.white * 10; generatorName = EGL.TextField("Generator Name", generatorName); outputFileName = EGL.TextField("Output File Name", outputFileName); GL.Space(5); EGL.BeginHorizontal(); if (!settings.regenerateOnMissing) { EGL.BeginVertical(); GL.FlexibleSpace(); EGL.HelpBox("NOTE: Force Generate will only delete the file but will NOT generate a new one if the [ReGen On Missing] is turned off", MessageType.Warning); EGL.EndVertical(); } else { // ============================================================================ // Draw Ma Awesome Logo EGL.BeginVertical(); GL.FlexibleSpace(); Rect horiRect = EGL.BeginHorizontal(); Rect boxRect = new Rect(horiRect.x + 3, horiRect.y - 54, 125, 52); Rect backgroundRect = boxRect; backgroundRect.width = border.width; backgroundRect.height = border.height; GUI.DrawTexture(backgroundRect, border); // GUI.Box( boxRect, iconBackground, ); GUI.Label(new Rect(boxRect.x + 3, boxRect.y + 16, 100, 20), "Created BY: "); Rect logoRect = new Rect(boxRect.x + 76, boxRect.y + 2, logo.width, logo.height); GUI.DrawTexture(logoRect, logo); EGL.EndHorizontal(); EGL.EndVertical(); // ============================================================================ } GL.FlexibleSpace(); GUI.contentColor = Color.white * 5; EGL.BeginVertical(); GL.FlexibleSpace(); GUI.backgroundColor = Color.white * 2.5f; GUI.contentColor = Color.black * 5; if (GL.Button("Create", new GUIStyle(GUI.skin.button) { fontStyle = FontStyle.Bold, fontSize = 12 }, GL.Width(75), GL.Height(30))) { if (generatorName == string.Empty || outputFileName == string.Empty || generatorName == null || outputFileName == null) { Debug.LogWarning("Fill out all the fields"); } else { TemplateGen.GenerateTemplate(generatorName, outputFileName); window.Close(); } } EGL.EndVertical(); GL.Space(1); EGL.EndHorizontal(); } #if UNITY_2019_OR_NEWER EGL.EndFoldoutHeaderGroup(); #endif if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(settings); } }
public override void OnInspectorGUI() { bool GUIEnabledValue = GUI.enabled; if (Provider.enabled && !Provider.isActive && !EditorUserSettings.WorkOffline) { GUI.enabled = false; } if (m_Edited) { UpdateOrder(m_Edited); m_Edited = null; } EditorGUILayout.BeginVertical(EditorStyles.inspectorFullWidthMargins); { GUILayout.Label(Content.helpText, EditorStyles.helpBox); EditorGUILayout.Space(); // Vertical that contains box and the toolbar below it Rect listRect = EditorGUILayout.BeginVertical(); { int dropFieldId = EditorGUIUtility.GetControlID(s_DropFieldHash, FocusType.Passive, listRect); MonoScript dropped = EditorGUI.DoDropField(listRect, dropFieldId, typeof(MonoScript), MonoScriptValidatorCallback, false, Styles.dropField) as MonoScript; if (dropped) { AddScriptToCustomOrder(dropped); } // Vertical that is used as a border around the scrollview EditorGUILayout.BeginVertical(Styles.boxBackground); { // The scrollview itself m_Scroll = EditorGUILayout.BeginVerticalScrollView(m_Scroll); { // List Rect r = GUILayoutUtility.GetRect(10, kListElementHeight * m_CustomTimeScripts.Count, GUILayout.ExpandWidth(true)); int changed = DragReorderGUI.DragReorder(r, kListElementHeight, m_CustomTimeScripts, DrawElement); if (changed >= 0) { // Give dragged item value in between neighbors SetExecutionOrderAtIndexAccordingToNeighbors(changed, 0); // Update neighbors if needed UpdateOrder(m_CustomTimeScripts[changed]); // Neighbors may have been moved so there's more space around dragged item, // so set order again to get possible rounding benefits SetExecutionOrderAtIndexAccordingToNeighbors(changed, 0); } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); // The toolbar below the box GUILayout.BeginHorizontal(Styles.toolbar); { GUILayout.FlexibleSpace(); Rect r2; GUIContent content = Content.iconToolbarPlus; r2 = GUILayoutUtility.GetRect(content, Styles.toolbarDropDown); if (EditorGUI.DropdownButton(r2, content, FocusType.Passive, Styles.toolbarDropDown)) { ShowScriptPopup(r2); } } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); ApplyRevertGUI(); } GUILayout.EndVertical(); GUI.enabled = GUIEnabledValue; if (Provider.enabled && !Provider.isActive && !EditorUserSettings.WorkOffline) { EditorGUILayout.HelpBox("Version control is disconnected", MessageType.Warning); } GUILayout.FlexibleSpace(); }
public override void OnInspectorGUI() { // Tabs. { // Select tabs. EditorGUI.BeginChangeCheck(); var rect = EditorGUILayout.BeginVertical(Styles.kSettingsFramebox); // Draw General Settings Tab. GUIStyle buttonStyle = null; var buttonRect = GetTabSelection(rect, 0, out buttonStyle); if (GUI.Toggle(buttonRect, generalSettingsSelected, Content.kGeneralLabel, buttonStyle)) { generalSettingsSelected = true; } // Draw Collision Settings Tab. buttonRect = GetTabSelection(rect, 1, out buttonStyle); if (GUI.Toggle(buttonRect, !generalSettingsSelected, Content.kCollisionLabel, buttonStyle)) { generalSettingsSelected = false; } GUILayoutUtility.GetRect(10, EditorGUI.kTabButtonHeight); EditorGUI.EndChangeCheck(); } // Draw tab selection. if (generalSettingsSelected) { // Update object. serializedObject.Update(); // Draw standard property settings. EditorGUILayout.Space(); EditorGUILayout.Space(); DrawPropertiesExcluding(serializedObject, "m_JobOptions", "m_ReuseCollisionCallbacks", "m_AutoSyncTransforms", "m_GizmoOptions"); // Reuse Collision Callbacks. EditorGUILayout.PropertyField(m_ReuseCollisionCallbacks); if (!m_ReuseCollisionCallbacks.boolValue) { EditorGUILayout.HelpBox(Content.kReuseCollisionCallbacksLabel.ToString(), MessageType.Warning, false); EditorGUILayout.Space(); } // Auto Sync Transforms. EditorGUILayout.PropertyField(m_AutoSyncTransforms); if (m_AutoSyncTransforms.boolValue) { EditorGUILayout.HelpBox(Content.kAutoSyncTransformsLabel.ToString(), MessageType.Warning, false); EditorGUILayout.Space(); } // Draw the Gizmo options. Physics2D.GizmoOptions gizmoOptions = (Physics2D.GizmoOptions)m_GizmoOptions.intValue; gizmoOptions = (Physics2D.GizmoOptions)EditorGUILayout.EnumFlagsField(Content.kGizmosLabel, gizmoOptions); m_GizmoOptions.intValue = (int)gizmoOptions; // Multithreading. GUILayout.BeginHorizontal(); GUILayout.Space(0); EditorGUILayout.PropertyField(m_Multithreading, Content.kMultithreadingLabel, true); GUILayout.EndHorizontal(); // Padding. EditorGUILayout.Space(); // Apply changes. serializedObject.ApplyModifiedProperties(); } else { // Layer Collision Matrix. LayerCollisionMatrixGUI2D.Draw( Content.kLayerCollisionMatrixLabel, (int layerA, int layerB) => { return(!Physics2D.GetIgnoreLayerCollision(layerA, layerB)); }, (int layerA, int layerB, bool val) => { Physics2D.IgnoreLayerCollision(layerA, layerB, !val); } ); } EditorGUILayout.EndVertical(); }
private void DrawToolbar() { if (!canEditInScene) { EditorGUILayout.HelpBox(Styles.disabledEditMessage, MessageType.Info); } EditorGUILayout.BeginVertical("GroupBox"); GUILayout.Label(Styles.sceneTools); EditorGUI.BeginDisabled(!canEditInScene); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditMode.DoInspectorToolbar(Styles.sceneViewEditModes, Styles.toolContents, GetBounds, this); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); // Tools box GUILayout.BeginVertical(EditorStyles.helpBox); string helpText = Styles.baseSceneEditingToolText; if (sceneViewEditing) { int index = ArrayUtility.IndexOf(Styles.sceneViewEditModes, EditMode.editMode); if (index >= 0) { helpText = Styles.ToolNames[index].text; } } GUILayout.Label(helpText, Styles.richTextMiniLabel); GUILayout.EndVertical(); // Editing mode toolbar if (sceneViewEditing) { switch (EditMode.editMode) { case EditMode.SceneViewEditMode.LineRendererEdit: DrawEditPointTools(); break; case EditMode.SceneViewEditMode.LineRendererCreate: CreatePointTools(); break; } } if (!sceneViewEditing) { EditorGUI.BeginChangeCheck(); showSimplifyPreview = EditorGUILayout.Toggle(Styles.simplifyPreview, showSimplifyPreview); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(Styles.tolerance); simplifyTolerance = Mathf.Max(0, EditorGUILayout.FloatField(simplifyTolerance, GUILayout.MaxWidth(35.0f))); if (GUILayout.Button(Styles.simplify, EditorStyles.miniButton)) { SimplifyPoints(); } if (EditorGUI.EndChangeCheck()) { ResetSimplifyPreview(); SceneView.RepaintAll(); } EditorGUILayout.EndHorizontal(); } EditorGUI.EndDisabled(); EditorGUILayout.EndVertical(); }
void ShowTreemaps() { LandmassEditorUtilities editorUtilities = LandmassEditorUtilities.Instance; ImporterConfiguration importCfg = editorUtilities.ImportCfg; EGL.BeginVertical(); { GUILayout.Label("The settings for processing tree maps."); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Postfix for treemap files."); importCfg.TreemapTag = EGL.TextField("Name postfix", importCfg.TreemapTag); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("Treemap file specifications. Please use x^2."); importCfg.SplatmapExtention = EGL.TextField("File extention", importCfg.SplatmapExtention); } EGL.EndVertical(); EGL.Separator(); EGL.BeginVertical(GuiUtils.Skin.box); { GUILayout.Label("The prototypes to assign. (Current count: " + editorUtilities.TreePrototypes.Count + ")"); EGL.Separator(); EGL.BeginHorizontal(); { if (editorUtilities.TreePrototypes.Count >= 8) { GUI.enabled = false; } if (GUILayout.Button("Add Prototype")) { editorUtilities.TreePrototypes.Add(new TreePrototype()); importCfg.IsDirty = true; // Todo: Nasty } GUI.enabled = true; } EGL.EndHorizontal(); // Show the list EGL.BeginVertical(); { _prototypeScrollPos = EGL.BeginScrollView(_prototypeScrollPos, GUILayout.MinHeight(96f), GUILayout.MaxHeight(Screen.height)); { List <TreePrototype> removeThese = new List <TreePrototype>(); int i = 0; foreach (TreePrototype prototype in editorUtilities.TreePrototypes) { if (ShowTreePrototype(prototype, i)) { removeThese.Add(prototype); importCfg.IsDirty = true; // Nasty } i++; } foreach (TreePrototype prototype in removeThese) { editorUtilities.TreePrototypes.Remove(prototype); } } EGL.EndScrollView(); } EGL.EndVertical(); } EGL.EndVertical(); } EGL.EndVertical(); }