static bool TogglePrivate( String title, ref bool value, bool disclosureStyle = false, bool forceHorizontal = true, float width = 0, params GUILayoutOption[] options ) { bool changed = false; options = options.AddItem(width == 0 ? UI.AutoWidth() : UI.Width(width)).ToArray(); if (!disclosureStyle) { title = value ? title.bold() : title.color(RGBA.lightgrey); if (GL.Button("" + (value ? onMark : offMark) + " " + title, UI.buttonStyle, options)) { value = !value; changed = true; } } else { if (Private.UI.DisclosureToggle(title, value, options)) { value = !value; changed = true; } } return(changed); }
protected virtual void OnGUI() { if (GUI.Button("Init")) { foreach (var go in Selection.gameObjects) { foreach (var scr in go.GetComponents <Base>()) { scr.Init(); } } } foreach (var a in GameObject.FindGameObjectsWithTag("EditorGUI").Where(a => a != Selection.activeGameObject)) { a.GetComponent <Base>().OnEditorGui(); } if (Selection.activeGameObject != null) { var bs2 = Selection.activeGameObject.GetComponent <Base>(); if (bs2 != null) { bs2.OnEditorGui(); } } GUI.BeginHorizontal(); Base.debug = GUI.Toggle(Base.debug, "debug", GUI.ExpandWidth(false)); GUI.EndHorizontal(); DrawSearch(); }
public override void OnEditorGui() { if (GUI.Button("Link Nodes")) { Undo.RegisterSceneUndo("rtools"); Node[] nds = GetNodes(); foreach (Node a in nds) { foreach (var node in nds) { if (a != node && !a.nodes.Contains(node)) { a.nodes.Add(node); } } } } if (GUI.Button("UnLink Nodes")) { Undo.RegisterSceneUndo("rtools"); Node[] nds = GetNodes(); foreach (Node a in nds) { foreach (var node in nds) { a.nodes.Remove(node); } } } }
private void DrawObjects() { List <string> toremove = new List <string>(); foreach (var inst in instances) { GUI.BeginHorizontal(); if (GUI.Button(inst)) { Object o = GameObject.Find(inst) != null?GameObject.Find(inst) : GameObject.FindObjectsOfTypeIncludingAssets(typeof(GameObject)).FirstOrDefault(a => a.name == inst); Selection.activeObject = o; } if (GUI.Button("X", GUI.ExpandWidth(false))) { toremove.Add(inst); } GUI.EndHorizontal(); } foreach (var inst in toremove) { instances.Remove(inst); SaveParams(); } }
public static void SetKeyBinding(ref KeyCode keyCode) { string label = (keyCode == KeyCode.None) ? Strings.GetText("button_PressKey") : keyCode.ToString(); if (GL.Button(label, GL.ExpandWidth(false))) { keyCode = KeyCode.None; } if (keyCode == KeyCode.None && Event.current != null) { if (Event.current.isKey) { keyCode = Event.current.keyCode; Input.ResetInputAxes(); } else { foreach (KeyCode mouseButton in mouseButtonsValid) { if (Input.GetKey(mouseButton)) { keyCode = mouseButton; Input.ResetInputAxes(); } } } } }
/// <summary> /// Draws a dummy GUI layout element and measures its rect. /// If the current event is not the repaint event, then use the backup rect reference. /// </summary> public static U.Rect FindLayoutAreaRect(ref U.Rect backupRect, int border = 0) { //DRAW DUMMY LAYOUT GROUP TO GET THE RECT FROM Gl.BeginVertical(Gl.MaxWidth(U.Screen.width), Gl.MaxHeight(U.Screen.height)); Gl.Label(""); //<- layout dummy Gl.EndVertical(); U.Rect _fieldRect = U.GUILayoutUtility.GetLastRect(); //rect update handling (ignore dummy rect at layout event) if (U.Event.current.type != U.EventType.Repaint) { _fieldRect = backupRect; } else { backupRect = _fieldRect; } _fieldRect.x += border; _fieldRect.y += border; _fieldRect.width -= border * 2; _fieldRect.height -= border * 2; return(_fieldRect); }
protected virtual void OnGUI() { if (!SetPivot && Selection.activeGameObject) { oldpos = Selection.activeGameObject.transform.position; } GUI.BeginHorizontal(); SetPivot = (GUI.Toggle(SetPivot, "Pivot", GUI.ExpandWidth(false)) && Selection.activeGameObject != null); var old = SetCam; SetCam = (GUI.Toggle(SetCam && Camera.main != null, "Cam", GUI.ExpandHeight(false))); //camset if (SetCam != old && SetCam == false) { ResetCam(); } if (GUI.Button("Apply")) { ApplyAll(); } if (GUI.Button("Add")) { if (!instances.Contains(Selection.activeObject.name)) { instances.Add(Selection.activeObject.name); SaveParams(); } } GUI.EndHorizontal(); DrawObjects(); DrawSearch(); }
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(); }
/// <summary> /// Closes the Navigation Field. (Optional) Draws additional controls on top of the content. /// </summary> public static void EndNavigationField(bool showNativeControls = true) { Gl.EndArea(); //end offset area if (lastDrawnNavField != null) { if (showNativeControls) { if (G.Button(new U.Rect(lastDrawnNavField.backupRect.width - lastDrawnNavField.border - 23, 5, 20, 20), new U.GUIContent("+", "Center View"))) { lastDrawnNavField.CenterView(); } } #if UNITY_EDITOR G.Button(new U.Rect(0, 0, lastDrawnNavField.backupRect.width, lastDrawnNavField.backupRect.height), "", "Label"); //force hot control #endif } Gl.EndArea(); //end field viewport area if (lastDrawnNavField != null) { lastDrawnNavField.DragUpdate(); } lastDrawnNavField = null; }
private void EndGUI() { GL.Space(5); EGL.EndHorizontal(); GL.Space(2); EGL.EndVertical(); }
public static void SetModifiedValueButtonAttackType <T>(string name, string guid) { foreach (AttackType attackType in (AttackType[])Enum.GetValues(typeof(AttackType))) { if (GL.Button(Strings.GetText("button_SetTo") + $" {attackType}", GL.ExpandWidth(false))) { FileInfo file = new FileInfo(Storage.modEntryPath + Storage.modifiedBlueprintsFolder + "\\" + guid + ".json"); if (File.Exists(file.FullName)) { T modifiedItem = ModifiedBlueprintTools.DeserialiseItem <T>(file); Traverse.Create(modifiedItem).Property(name).SetValue(attackType); string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented); File.WriteAllText(file.FullName, json); } else { T modifiedItem = default(T); modifiedItem = Activator.CreateInstance <T>(); Traverse.Create(modifiedItem).Property(name).SetValue(attackType); string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented); File.WriteAllText(file.FullName, json); } ModifiedBlueprintTools.blueprintLists = false; ModifiedBlueprintTools.Patch(); } } }
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(); } }
private void OnGUI() { scrollView = Gl.BeginScrollView(scrollView); { Gl.TextArea(log); } Gl.EndScrollView(); EditorUtil.HorizontalRule(); Gl.BeginHorizontal(); { Gl.Label("Save Log:", Gl.ExpandWidth(false)); outputPath = Gl.TextField(outputPath); } Gl.EndHorizontal(); Gl.BeginHorizontal(); { if (Gl.Button("Save")) { PrintLog(); } if (Gl.Button("Close")) { Close(); } } Gl.EndHorizontal(); }
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(); } }
private void OnGUIVendors(Vendors.Vendor vendor) { using (new GUISubScope()) { using (new GL.HorizontalScope()) { GL.Label(string.Format("{0}: ", vendor.DisplayName), MenuHelpers.LabelStyleFixed, falseWidth); if (GL.Button(Local["Menu_Btn_MoveVendor"], MenuHelpers.ButtonStyle, falseWidth)) { var position = Game.Instance.Player.MainCharacter.Value.Position; var rotation = Game.Instance.Player.MainCharacter.Value.OrientationDirection; SettingsWrapper.Positions[vendor.UnitGuid] = position; SettingsWrapper.Rotations[vendor.UnitGuid] = rotation; vendor.Move(position, rotation); } if (GL.Button(Local["Menu_Btn_Enable"], MenuHelpers.ButtonStyle, falseWidth)) { SettingsWrapper.VendorEnabled[vendor.UnitGuid] = true; vendor.Enable(); } if (GL.Button(Local["Menu_Btn_Disable"], MenuHelpers.ButtonStyle, falseWidth)) { SettingsWrapper.VendorEnabled[vendor.UnitGuid] = false; vendor.Disable(); } } } }
private void OnGUIThroneRoom() { using (new GUISubScope(Local["Menu_Tab_TRV"], "box")) { if (!HamHelpers.InThroneRoom()) { GL.Label(Local["Menu_Txt_NotInThrone"]); return; } GL.Label(Local["Menu_Lbl_MoveVendor"], MenuHelpers.LabelStyleWrap, falseWidth); foreach (KeyValuePair <string, Vendors.Vendor> kvp in Vendors.VendorBlueprints.NewVendors.Where(n => n.Value.AreaId == Vendors.Vendor.Area.ThroneRoom)) { OnGUIVendors(kvp.Value); } GL.Label(Local["Menu_Txt_CleanOld"]); if (GL.Button(Local["Menu_Btn_CleanOld"], MenuHelpers.ButtonStyle, falseWidth)) { foreach (UnitEntityData unit in Game.Instance.State.Units) { if (oldVendors.Contains(unit.Blueprint.AssetGuid)) { unit.Destroy(); } } } GUI.enabled = true; } }
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(); }
public static void EnumerablePicker <T>( String title, ref int selected, IEnumerable <T> range, int xCols, Func <T, String> titleFormater = null, params GUILayoutOption[] options ) { if (titleFormater == null) { titleFormater = (a) => $"{a}"; } if (selected > range.Count()) { selected = 0; } int sel = selected; var titles = range.Select((a, i) => i == sel ? titleFormater(a).orange().bold() : titleFormater(a)); if (xCols > range.Count()) { xCols = range.Count(); } if (xCols <= 0) { xCols = range.Count(); } UI.Label(title, UI.AutoWidth()); UI.Space(25); selected = GL.SelectionGrid(selected, titles.ToArray(), xCols, options); }
public static void SetModifiedValueButtonDiceFormula <T>(int rolls, DiceType dice, string name, string guid) { if (GL.Button(Strings.GetText("button_SetTo") + $" {rolls} * {dice}", GL.ExpandWidth(false))) { ModifiedDiceFormula diceFormula = new ModifiedDiceFormula(); diceFormula.m_Rolls = rolls; diceFormula.m_Dice = dice; FileInfo file = new FileInfo(Storage.modEntryPath + Storage.modifiedBlueprintsFolder + "\\" + guid + ".json"); if (File.Exists(file.FullName)) { T modifiedItem = ModifiedBlueprintTools.DeserialiseItem <T>(file); Traverse.Create(modifiedItem).Property(name).SetValue(diceFormula); string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented); File.WriteAllText(file.FullName, json); } else { T modifiedItem = default(T); modifiedItem = Activator.CreateInstance <T>(); Traverse.Create(modifiedItem).Property(name).SetValue(diceFormula); string json = JsonConvert.SerializeObject(modifiedItem, Formatting.Indented); File.WriteAllText(file.FullName, json); } ModifiedBlueprintTools.blueprintLists = false; ModifiedBlueprintTools.Patch(); } }
public static bool LogSlider(String title, ref float value, float min, float max, float defaultValue = 1.0f, int decimals = 0, String units = "", params GUILayoutOption[] options) { if (min < 0) { throw new Exception("LogSlider - min value: {min} must be >= 0"); } UI.BeginHorizontal(options); UI.Label(title.cyan(), UI.Width(300)); UI.Space(25); value = Math.Max(min, Math.Min(max, value)); // clamp it var offset = 1; var places = (int)Math.Max(0, Math.Min(15, 2.01 - Math.Log10(value + offset))); var logMin = 100f * (float)Math.Log10(min + offset); var logMax = 100f * (float)Math.Log10(max + offset); var logValue = 100f * (float)Math.Log10(value + offset); var logNewValue = (float)(GL.HorizontalSlider(logValue, logMin, logMax, UI.Width(200))); var newValue = (float)Math.Round(Math.Pow(10, logNewValue / 100f) - offset, places); UI.Space(25); UI.FloatTextField(ref newValue, null, UI.Width(75)); if (units.Length > 0) { UI.Label($"{units}".orange().bold(), UI.Width(25 + GUI.skin.label.CalcSize(new GUIContent(units)).x)); } UI.Space(25); UI.ActionButton("Reset", () => { newValue = defaultValue; }, UI.AutoWidth()); UI.EndHorizontal(); bool changed = value != newValue; value = newValue; return(changed); }
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(); }
private void CopyComponent() { if (GUI.Button("CloneComp")) { selectedGameObject = selectedGameObject == null ? Selection.activeGameObject : null; } if (selectedGameObject != null) { foreach (var c in selectedGameObject.GetComponents <Component>()) { if (GUI.Button(c.GetType().Name)) { foreach (GameObject g in Selection.gameObjects) { var c2 = g.AddComponent(c.GetType()); foreach (FieldInfo f in c.GetType().GetFields()) { f.SetValue(c2, f.GetValue(c)); } //foreach (PropertyInfo p in c.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) // if(p.CanRead && p.CanWrite) // p.SetValue(c2, p.GetValue(c,null),null); //Debug.Log(c.GetType().GetProperties().Length+"+"); } } } GUI.Space(10); } }
protected override void DoSpecializedGUI() { GUILayout.BeginHorizontal(); GUILayout.Label(string.Format("Text (Length: {0})", m_Text.Length), Styles.BoldLabel); GUILayout.Label(m_Text, Styles.BoldLabel); GUILayout.EndHorizontal(); m_GUIText = GUILayout.TextField(m_GUIText, Styles.BoldTextField); if (Configuration.Instance.OldInputEnabled == false) { GUILayout.Label("Old Input Disabled", Styles.BoldLabel); return; } m_KeysScrollPosition = GUILayout.BeginScrollView(m_KeysScrollPosition); foreach (var key in m_Keys) { var k = key.Value; if (k.keyCounter == 0 || k.keyDown == 0 || k.keyUp == 0) { continue; } GUILayout.Label(string.Format("{0} down - {1}, up - {2}, counter - {3}", key.Key, k.keyDown, k.keyUp, k.keyCounter), Styles.BoldLabel); } GUILayout.EndScrollView(); }
private void DrawDatas() { var packages = BaseData["Packages"]; if (packages.Count > 0) { for (int i = 0; i < packages.Count; i++) { var value = packages[i]; GL.BeginVertical("OL box"); GL.BeginHorizontal("box"); GL.Label(value["name"].ToString()); GL.Label(value["version"].ToString()); if (Directory.Exists(value["localpath"].ToString())) { if (GL.Button("pack", GUILayout.Width(100))) { Export(value["name"].ToString(), value["localpath"].ToString()); } } else if (ExistsLocalPackage(value["name"].ToString())) { if (GL.Button("Import", GUILayout.Width(100))) { } } GL.EndHorizontal(); GL.EndVertical(); } } }
public static void ToggleButton(Setting <bool> val, string label, GUILayoutOption[] lblOpts, GUILayoutOption[] btnOpts) { UGUI.BeginHorizontal(); UGUI.Label(label, Style.Label, lblOpts); UGUI.Space(5f); val.Value = UGUI.Button(val.Value ? GUI.LabelEnabled : GUI.LabelDisabled, Style.TextButton, btnOpts); UGUI.EndHorizontal(); }
public static void ToggleButton(Setting <bool> val, string label) { UGUI.BeginHorizontal(); UGUI.Label(label, Style.Label, DefaultOption); UGUI.Space(5f); val.Value = UGUI.Button(val.Value ? GUI.LabelEnabled : GUI.LabelDisabled, Style.TextButton, DefaultOption); UGUI.EndHorizontal(); }
public static void Toggle(Setting <bool> val, string label, GUILayoutOption[] labelOpts, GUILayoutOption[] tglOpts) { UGUI.BeginHorizontal(); UGUI.Label(label, Style.Label, labelOpts); UGUI.FlexibleSpace(); val.Value = UGUI.Toggle(val.Value, string.Empty, Style.Toggle, tglOpts); UGUI.EndHorizontal(); }
public static void Toggle(Setting <bool> val, string label) { UGUI.BeginHorizontal(); Label(label); UGUI.FlexibleSpace(); val.Value = UGUI.Toggle(val.Value, string.Empty, Style.Toggle); UGUI.EndHorizontal(); }
public static void TextField(Setting <int> val, string label, GUILayoutOption[] lblOpts, GUILayoutOption[] txtopts) { UGUI.BeginHorizontal(); UGUI.Label(label, Style.Label, lblOpts); UGUI.Space(5f); TextField(val, txtopts); UGUI.EndHorizontal(); }
public static void TextField(Setting <int> val, string label) { UGUI.BeginHorizontal(); UGUI.Label(label, Style.Label, DefaultOption); UGUI.Space(5f); TextField(val); UGUI.EndHorizontal(); }
static int _CreateGUILayout(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 0) { GUILayout obj = new GUILayout(); LuaScriptMgr.PushObject(L, obj); return 1; } else { LuaDLL.luaL_error(L, "invalid arguments to method: GUILayout.New"); } return 0; }