Auto-layouted version of EditorGUI.
public override void OnGUI(Rect rect) { searchText = searchField.OnGUI(searchText); scrollPosition = EGL.BeginScrollView(scrollPosition); foreach (var type in behaviourTypes) { if (type.ToLower().Contains(searchText.ToLower())) { EGL.BeginHorizontal(); EGL.LabelField(type, GL.Width(140)); if (GL.Button("Add", GL.Width(40))) { var instance = (StateBehaviour)ScriptableObject.CreateInstance(type); instance.name = type; instance.hideFlags = HideFlags.HideInHierarchy; list.Add(instance); AssetDatabase.AddObjectToAsset(instance, profile); AssetDatabase.SaveAssets(); editorWindow.Close(); } EGL.EndHorizontal(); } } EGL.EndScrollView(); }
void DrawActionButtonArrayElement(SP dialog, int elementIndex) { DrawArrayElement(dialog, elementIndex, "Consent dialog should have at least 1 button.", MinActionButtonsCount, () => SelectedButtonIndex, param => SelectedButtonIndex = param, obj => { var title = obj.FindPropertyRelative("title"); EditorGUI.indentLevel++; string key = obj.propertyPath; if (!privacyFoldoutStates.ContainsKey(key)) { privacyFoldoutStates.Add(key, false); } string titleValue = !string.IsNullOrEmpty(title.stringValue) ? title.stringValue : "[Untitled Button]"; privacyFoldoutStates[key] = EGL.Foldout(privacyFoldoutStates[key], titleValue, true); EditorGUI.indentLevel--; if (privacyFoldoutStates[key]) { EGL.PropertyField(obj.FindPropertyRelative("id")); EGL.PropertyField(title); EGL.PropertyField(obj.FindPropertyRelative("interactable")); EGL.PropertyField(obj.FindPropertyRelative("titleColor")); EGL.PropertyField(obj.FindPropertyRelative("backgroundColor")); EGL.PropertyField(obj.FindPropertyRelative("uninteractableTitleColor")); EGL.PropertyField(obj.FindPropertyRelative("uninteractableBackgroundColor")); } }); }
internal static void Ruler(int w = 2, int padding = 10) { var r = EGL.GetControlRect(Height(padding + w)); r.height = w; r.x -= 2; r.width += 6; r.y += padding / 2; EditorGUI.DrawRect(r, lightGray); }
public override void OnInspectorGUI() { var script = (BehaviourScript)target; if (script.compileOkay) { EGL.HelpBox("The script is compiled and up to date!", MessageType.Info); } if (script.notUpToDate) { EGL.HelpBox("The compiled script is not up to date.", MessageType.Warning); } if (script.notCompiled) { EGL.HelpBox("The script is not yet compiled.", MessageType.Error); } if (GL.Button("Compile")) { script.Compile(); } if (GL.Button("Print AST")) { script.PrintAST(); } }
void updateShopItems() { for (int i = 0; i <= (vars.characters.Count - 1); i++) { GL.Label("Character " + (i + 1) + " options:", EditorStyles.boldLabel); BV(); GL.Label("Sprite1 for Open Eye / Sprite2 for Close Eye ", EditorStyles.boldLabel); BH(); vars.characters[i].gameCharacterSprite1 = EGL.ObjectField("Game Character sprite1", vars.characters[i].gameCharacterSprite1, typeof(Sprite), false) as Sprite; vars.characters[i].gameCharacterSprite2 = EGL.ObjectField("Game Character sprite2", vars.characters[i].gameCharacterSprite2, typeof(Sprite), false) as Sprite; EH(); BH(); vars.characters[i].shopCharacterSprite = EGL.ObjectField("Shop Character sprite", vars.characters[i].shopCharacterSprite, typeof(Sprite), false) as Sprite; EH(); BH(); vars.characters[i].characterName = EGL.TextField("Character name", vars.characters[i].characterName); if (i != 0) { vars.characters[i].characterPrice = EGL.IntField("Character price", vars.characters[i].characterPrice); } EH(); EV(); separator(); } }
public static string ProjectFileBrowser(string title, string description, string file, string extention) { string path = file; EGL.BeginHorizontal(); { EGL.PrefixLabel(title); GUILayout.Label(file, Skin.textField); string newPath = file; if (GUILayout.Button("Browse", GUILayout.Width(64f))) { newPath = EditorUtility.OpenFilePanel(description, Path.GetFullPath(UPath.GetAbsolutePath(file)), extention); if (newPath != string.Empty) { newPath = UPath.GetProjectPath(newPath); } else { newPath = file; } } path = newPath; } EGL.EndHorizontal(); return(path); }
public override void OnEditorGui() { if (gui.Button("InitLevel")) { foreach (var a in level.GetComponentsInChildren <AnimHelper>()) { a.Init(); } } prefabs = transform.Find("tools").Cast <Transform>().ToArray(); prefabst = prefabs.Select(a => a.name).ToArray(); gridSize = GUI.IntSlider("GridSize", gridSize, 1, 10); PlanePos = GUI.IntSlider("PlanePos", PlanePos, -10, 10); tool = (Tool)gui.SelectionGrid((int)tool, Enum.GetNames(typeof(Tool)), 2); if (tool != oldtool) { //Debug.Log("Chagne"); SelectedPrefab.gameObject.active = false; } oldtool = tool; //oldtooli = tooli; prefabsi = gui.SelectionGrid(prefabsi, prefabst, 2); base.OnEditorGui(); }
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); }
/* 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); }
private void EndGUI() { GL.Space(5); EGL.EndHorizontal(); GL.Space(2); EGL.EndVertical(); }
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("Use Settings"); settings = (ImportSettings)EGL.ObjectField(settings, typeof(ImportSettings), false); EGL.Space(); if (settings && CenteredButton("OK")) { foreach (var path in paths) { var instance = ScriptableObject.CreateInstance <ImportSettingsReference>(); instance.settings = settings; Directory.CreateDirectory(Path.GetDirectoryName(path)); AssetDatabase.CreateAsset(instance, path); } finishedAction(settings); this.Close(); } if (CenteredButton("Cancel")) { this.Close(); } }
private void OnGUI() { EGL.LabelField("Use Settings"); settings = EGL.ObjectField(settings, typeof(ImportSettings), false) as ImportSettings; EGL.Space(); if (settings && CenteredButton("OK")) { var reference = new MetaSpriteImportData { metaSpriteSettingsGuid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(settings)) }; foreach (var path in assetPaths) { var import = AssetImporter.GetAtPath(path); import.userData = JsonUtility.ToJson(reference); import.SaveAndReimport(); } finishedAction(settings); this.Close(); } if (CenteredButton("Cancel")) { this.Close(); } }
public void DrawLuaScript(string filePath) { FindLuaTableInfo(filePath); // 以上是初始化环节 var luaName = filePath.Substring(filePath.LastIndexOf("/") + 1, filePath.Length - filePath.LastIndexOf("/") - 1).Replace(".lua", ""); GL.BeginVertical("OL box"); GL.Label(luaName, EditorStyles.boldLabel); if (mExecuteFunctionDirt == null || mExecuteFunctionDirt.Count() < 1) { EGL.HelpBox("没有可以被执行的方法", MessageType.Warning); } else { foreach (var m in mExecuteFunctionDirt) { GL.BeginHorizontal("box"); var methodName = string.Format("{0}:{1}", luaName, m.Key); GL.Label(methodName); if (GL.Button("Execute", GUILayout.Width(100))) { UnityEngine.Debug.LogFormat("<color=#FFA80B>Execute {0}:{1}</color>", luaName, m.Key); m.Value.Invoke(); } GL.EndHorizontal(); GL.Space(2); } } GL.EndVertical(); }
public static string ProjectFolderBrowser(string title, string description, string folder, string defaultName) { string path = folder; EGL.BeginHorizontal(); { EGL.PrefixLabel(title); GUILayout.Label(folder, Skin.textField); string newPath = folder; if (GUILayout.Button("Browse", GUILayout.Width(64f))) { newPath = EditorUtility.SaveFolderPanel(description, folder, defaultName); if (newPath != string.Empty) { newPath = UPath.GetProjectPath(newPath); } else { newPath = folder; } } path = newPath; } EGL.EndHorizontal(); return(path); }
private void DrawAssurer(VAssetManager Manager) { GL.BeginVertical("OL box"); GL.Label(Manager.ManagerName); var list = Manager.GetAssurerList(); if (list.Count == 0) { EGL.HelpBox("暂无资产", MessageType.Info); } else { list.ForEach(assurer => { GL.BeginVertical("GroupBox"); GL.BeginHorizontal(); GL.Label(String.Format("{0} : Ref {1}", assurer.Value.AssetPath, assurer.Value.UseCount)); if (GL.Button("Kill", GUILayout.Width(100))) { assurer.Value.ForceRecycle(); } GL.EndHorizontal(); GL.EndVertical(); GL.Space(2); }); } GL.EndVertical(); }
string InspectTags(string tags) { if (tags == null) { tags = ""; } tags = EGL.TextField("Tags", tags); string[] splitted = tags.Split(','); var invalidTags = ""; foreach (var tag in splitted) { if (tag.Length > 0 && !state.profile.tags.Contains(tag)) { invalidTags += tag; invalidTags += '|'; } } if (invalidTags.Length != 0) { EGL.HelpBox("Tag |" + invalidTags + " are invalid.", MessageType.Error); } return(tags); }
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 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(); }
private void OnGUI() { if (EntityManager == null) { EditorGUILayout.HelpBox("please set EntityManager -> BuffDebugWindow.EntityManager", MessageType.Warning); return; } var entitys = EntityManager.Entitys; EditorGUILayout.LabelField("Entity count:" + entitys.Count); EditorGUI.indentLevel++; _pos = EditorGUILayout.BeginScrollView(_pos, "box"); { foreach (var entity in entitys) { EditorGUILayout.LabelField($"{entity} Buff Count:" + EntityManager.GetAllBuff(entity).Count()); } } EditorGUILayout.EndScrollView(); EditorGUI.indentLevel--; Repaint(); }
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(); }
public override void OnGUI(Rect rect) { string itemValue = m_Object as string; if (itemValue == null) { Debug.LogError("Invalid object"); return; } if (m_TextSearch == null) { m_TextSearch = itemValue; } const float kColumnWidth = 70f; const float kSpacing = 10f; GUILayout.Space(3); GUILayout.Label(m_MenuType == MenuType.Add ? Styles.headerAdd : Styles.headerEdit, EditorStyles.boldLabel); Rect seperatorRect = GUILayoutUtility.GetRect(1, 1); FlexibleMenu.DrawRect(seperatorRect, (EditorGUIUtility.isProSkin) ? new Color(0.32f, 0.32f, 0.32f, 1.333f) : new Color(0.6f, 0.6f, 0.6f, 1.333f)); // dark : light GUILayout.Space(4); // Optional text GUILayout.BeginHorizontal(); GUILayout.Label(Styles.optionalText, GUILayout.Width(kColumnWidth)); GUILayout.Space(kSpacing); m_TextSearch = EditorGUILayout.TextField(m_TextSearch); GUILayout.EndHorizontal(); GUILayout.Space(5f); // Cancel, Ok GUILayout.BeginHorizontal(); GUILayout.Space(10); if (GUILayout.Button(Styles.cancel)) { editorWindow.Close(); } if (GUILayout.Button(Styles.ok)) { var textSearch = m_TextSearch.Trim(); if (!string.IsNullOrEmpty(textSearch)) { m_Object = m_TextSearch; Accepted(); editorWindow.Close(); } } GUILayout.Space(10); GUILayout.EndHorizontal(); }
void drawArray(string arrayName) { SerializedObject so = new SerializedObject(this); SerializedProperty stringsProperty = so.FindProperty(arrayName); EGL.PropertyField(stringsProperty, true); so.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); neb = target as Nebula; EGL.Space(); EGL.FloatField("Radius", neb.dimensions.magnitude); }
string ToolbarSearchField(string str, SearchField field) { EGL.BeginHorizontal(EditorStyles.toolbar); GL.Label("", GL.Width(150)); str = field.OnToolbarGUI(str); EGL.EndHorizontal(); return(str); }
public static string OnGUI(this SearchField self, string label, string content) { EGL.BeginHorizontal(); EGL.PrefixLabel(label); content = self.OnGUI(content); EGL.EndHorizontal(); return(content); }
void PrivacyModuleGUI() { DrawModuleHeader(); EGL.Space(); DrawAppTrackingSubmoduleGUI(); EGL.Space(); DrawPrivacyConsentDialogSettingsGUI(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); var tree = (BehaviourTree)target; var script = tree.source; if (script) { if (script.notCompiled) { EGL.HelpBox("Script is not compiled.", MessageType.Error); } if (script.notUpToDate) { EGL.HelpBox("Script is not up to date.", MessageType.Warning); } if (script.compileOkay) { EGL.HelpBox("Script is compiled and up to date.", MessageType.Info); } if (GL.Button("Compile")) { script.Compile(); } } if (Application.isPlaying) { EGL.Space(); EGL.LabelField("Conditions"); GUI.enabled = false; foreach (var cond in tree.blackboard) { var k = cond.Key; var v = cond.Value; if (v is float) { EGL.FloatField(k, (float)v); } else if (v is int) { EGL.IntField(k, (int)v); } else if (v is bool) { EGL.Toggle(k, (bool)v); } else if (v is string) { EGL.TextField(k, (string)v); } } GUI.enabled = true; Repaint(); } }
static bool CenteredButton(string content) { EGL.BeginHorizontal(); GL.FlexibleSpace(); var res = GL.Button(content, GL.Width(150)); GL.FlexibleSpace(); EGL.EndHorizontal(); return res; }
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); }