void SpriteList() { GUILayout.Label("Sprites", "HeaderLabel"); bool hasMissingTextures = false; EditorGUI.BeginChangeCheck(); MadGUI.Indent(() => { for (int i = 0; i < atlas.ListItems().Count; ++i) { MadAtlas.Item item = atlas.ListItems()[i]; EditorGUILayout.BeginHorizontal(); var texture = MadAtlasUtil.GetItemOrigin(item); bool valid = MadGUI.Validate(() => texture != null, () => { item.name = EditorGUILayout.TextField(item.name); }); GUI.enabled = valid; GUI.color = Color.yellow; if (GUILayout.Button("Ping", GUILayout.Width(40))) { EditorGUIUtility.PingObject(texture); } GUI.enabled = true; GUI.color = Color.red; if (GUILayout.Button("X", GUILayout.Width(20))) { MadAtlasBuilder.RemoveFromAtlas(atlas, item); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if (!valid) { hasMissingTextures = true; } } if (hasMissingTextures) { MadGUI.Error("There are sprites with missing origin texture. This will for them to dissapear on edit."); } }); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(atlas); } }
void DropAreaGUI() { Event evt = Event.current; var dropArea = EditorGUILayout.BeginHorizontal(); MadGUI.Message("Drag & drop textures HERE to add them to this atlas.\n\n\n", MessageType.None); EditorGUILayout.EndHorizontal(); GUI.color = new Color(1f, 1f, 1f, 0.5f); int iconW = textureDragDrop.width; int iconH = textureDragDrop.height; GUI.DrawTexture(new Rect(dropArea.center.x - iconW / 2, dropArea.yMax - iconH - 2, iconW, iconH), textureDragDrop); GUI.color = Color.white; List <Texture2D> texturesToAdd = new List <Texture2D>(); switch (evt.type) { case EventType.MouseDrag: case EventType.DragUpdated: case EventType.DragPerform: if (!dropArea.Contains(evt.mousePosition)) { break; } DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (evt.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); foreach (Object draggedObject in DragAndDrop.objectReferences) { if (draggedObject is Texture2D) { texturesToAdd.Add(draggedObject as Texture2D); } } } break; } if (texturesToAdd.Count > 0) { AddTextures(texturesToAdd.ToArray()); } }
void OnGUI() { var style = new GUIStyle(GUI.skin.label); style.fontSize = 25; style.normal.textColor = Color.white; //style.fontStyle = FontStyle.Bold; GUI.color = new Color(1, 61 / 255f, 61 / 255f); GUI.DrawTexture(new Rect(0, 0, Screen.width, 50), Texture2D.whiteTexture); GUI.color = Color.white; GUILayout.Space(10); GUILayout.Label("Energy Bar Toolkit Upgrade Info", style); EditorGUILayout.Space(); EditorGUILayout.Space(); style = new GUIStyle(GUI.skin.label); GUILayout.Label("Thank you for upgrading Energy Bar Toolkit to " + Version.current + "!"); EditorGUILayout.Space(); style.fontSize = 15; GUILayout.Label("Important!", style); MadGUI.Error("Remember to backup your project before upgrading Energy Bar Toolkit to newer version!"); GUILayout.Label("Remember that...", style); MadGUI.Warning("If you see errors after upgrading Energy Bar Toolkit, please remove Energy Bar Toolkit " + "directory and import it again."); MadGUI.Warning("OnGUI bars will not work with Unity 5 and those are no longer maintained."); GUILayout.Label("Tips", style); MadGUI.Info("Mesh bars are now deprecated. We strongly recommend to use new uGUI bars!"); GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(); doNotShow = EditorGUILayout.ToggleLeft("Do not show again until next upgrade", doNotShow); if (GUILayout.Button("Changelog")) { Application.OpenURL(string.Format("http://energybartoolkit.madpixelmachine.com/doc/{0}/changelog.html", Version.current)); } EditorGUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); EditorGUILayout.IntSlider(valueCurrent, valueMin.intValue, valueMax.intValue, "Value Current"); EditorGUILayout.Space(); MadGUI.PropertyField(valueMin, "Value Min"); MadGUI.PropertyField(valueMax, "Value Max"); if (valueMin.intValue >= valueMax.intValue) { MadGUI.Error("Value Min should be lower than Value Max."); } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); MadGUI.PropertyFieldEnumPopup(inputMode, "Input Mode"); EditorGUILayout.Space(); EditorGUI.indentLevel++; switch (script.inputMode) { case MadLevelInputControl.InputMode.InputAxes: MadGUI.PropertyField(axisHorizontal, "Horizontal Axis"); MadGUI.PropertyField(axisVertical, "Vertical Axis"); MadGUI.PropertyField(axisEnter, "Enter Axis"); break; case MadLevelInputControl.InputMode.KeyCodes: MadGUI.PropertyField(keycodeLeft, "Key Code Left"); MadGUI.PropertyField(keycodeRight, "Key Code Right"); MadGUI.PropertyField(keycodeUp, "Key Code Up"); MadGUI.PropertyField(keycodeDown, "Key Code Down"); MadGUI.PropertyField(keycodeEnter, "Key Code Enter"); break; default: Debug.LogError("Unknown input mode: " + script.inputMode); break; } EditorGUI.indentLevel--; EditorGUILayout.Space(); MadGUI.PropertyFieldEnumPopup(activateOnStart, "Activate On Start"); EditorGUILayout.Space(); MadGUI.PropertyField(onlyOnMobiles, "Only On Mobiles"); MadGUI.PropertyField(repeat, "Repeat"); EditorGUI.indentLevel++; MadGUI.PropertyField(repeatInterval, "Interval"); EditorGUI.indentLevel--; EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); traverseRule = (TraverseRules)EditorGUILayout.EnumPopup("Traverse Rule", traverseRule); if (traverseRule == TraverseRules.Custom) { MadGUI.Info( "Custom traverse rule means that you have to assign your own traverse rule programatically when the scene is loaded." + "You don't have to change the rule to 'Custom', just setting it in the component will do. Please refer to the documentation for more information."); } if (EditorGUI.EndChangeCheck()) { switch (traverseRule) { case TraverseRules.Simple: script.traverseRule = new MadLevelInputControl.SimpleTraverseRule(); break; case TraverseRules.Direction: script.traverseRule = new MadLevelInputControl.DirectionTraverseRule(); break; case TraverseRules.Custom: // do nothing break; default: Debug.LogError("Unknown traverse rule: " + traverseRule); break; } EditorUtility.SetDirty(script); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (MadGUI.Button("Help", Color.white, GUILayout.Width(80))) { Application.OpenURL(MadLevelHelp.InputControl); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }