public override void OnInspectorGUI() { EditorGUI.BeginChangeCheck(); chosenBackend = EditorGUILayout.Popup( "Load & Save Backend", chosenBackend, backendDisplayedNameList.ToArray()); if (EditorGUI.EndChangeCheck()) { settings.profileBackend = IndexToBackend(chosenBackend); EditorUtility.SetDirty(settings); } if (backendList.Count <= chosenBackend) { return; } string backend = backendList[chosenBackend]; DrawBackendProperties(backend); EditorGUILayout.Space(); DrawBackendHelpIfAvailable(backend); if (backendList[chosenBackend] == (typeof(MadLevelProfile.DefaultBackend).FullName)) { MadGUI.Info("To get access to more Load & Save backends, unpack packages from the \"Mad Level Manager/Save Load Backends\" directory."); } }
// =========================================================== // Methods // =========================================================== void OnGUI() { MadGUI.Info("This tool initialized your scene for GUI drawing. Please choose root object name and layer " + "on which GUI will be painted."); rootObjectName = EditorGUILayout.TextField("Root Name", rootObjectName); layer = EditorGUILayout.LayerField("Layer", layer); OnFormGUI(); if (GUILayout.Button("Create")) { var panel = MadPanel.UniqueOrNull(); bool doInit = true; if (panel != null) { doInit = EditorUtility.DisplayDialog("Scene initialized", "Scene looks like it is already initialized. " + "Are you sure that you want to continue?", "Yes", "No"); } if (doInit) { root = Init(rootObjectName, layer, hideInvisibleSprites, depthBasedRenderMode); AfterCreate(root); } } }
public override void OnInspectorGUI() { EditorGUILayout.Space(); EditorGUILayout.LabelField("Property Name: " + target.name); EditorGUILayout.Space(); MadGUI.Info("Rename this object to match the property name that text value you want to display. " + "When property is not set then the default text will be displayed."); EditorGUILayout.Space(); }
void ActivateAction( SerializedProperty playAudio, SerializedProperty playAudioClip, SerializedProperty playAudioVolume, SerializedProperty message, SerializedProperty messageReceiver, SerializedProperty messageMethodName, SerializedProperty messageIncludeChildren ) { MadGUI.PropertyField(playAudio, "Play Audio"); MadGUI.ConditionallyEnabled(playAudio.boolValue, () => { MadGUI.Indent(() => { if (playAudio.boolValue && !FoundAudioListener()) { if (MadGUI.ErrorFix("There's no AudioListener on the scene. Do you want me to add an " + "AudioListener to Camera 2D?", "Add")) { var camera = MadTransform.FindParent <Camera>((target as Component).transform); if (camera == null) { camera = FindObjectOfType(typeof(Camera)) as Camera; } if (camera != null) { camera.gameObject.AddComponent <AudioListener>(); } else { Debug.LogError("There's no camera on this scene!"); } } } MadGUI.PropertyField(playAudioClip, "Audio Clip", MadGUI.ObjectIsSet); MadGUI.PropertyFieldSlider(playAudioVolume, 0, 1, "Volume"); }); }); MadGUI.PropertyField(message, "Send Message"); MadGUI.ConditionallyEnabled(message.boolValue, () => { MadGUI.Indent(() => { MadGUI.PropertyField(messageReceiver, "Receiver", MadGUI.ObjectIsSet); MadGUI.PropertyField(messageMethodName, "Method Name", MadGUI.StringNotEmpty); MadGUI.PropertyField(messageIncludeChildren, "Include Children"); if (message.boolValue) { MadGUI.Info("This should look like this:\nvoid " + messageMethodName.stringValue + "(MadLevelIcon icon)"); } }); }); }
void OnGUI() { MadGUI.Info("To create a generator, implement IMadLevelGenerator interface and place your script in any Editor folder."); if (generators.Count == 0) { MadGUI.Error("I cannot found any generator in your project. Please implement at least one!"); return; } chosenGeneratorIndex = EditorGUILayout.Popup("Generator", chosenGeneratorIndex, generators.ToArray()); MadLevelConfiguration conf = MadLevelConfiguration.GetActive(); chosenGroupIndex = EditorGUILayout.Popup("Group", chosenGroupIndex, GroupNames(conf)); scene = EditorGUILayout.ObjectField("Scene", scene, typeof(Object), false); levelsCount = EditorGUILayout.IntField("Level Count", levelsCount); GUI.enabled = scene != null; if (MadGUI.Button("Create")) { string generatorName = generators[chosenGeneratorIndex]; Type generatorType = Type.GetType(generatorName + ", Assembly-CSharp-Editor"); var generator = Activator.CreateInstance(generatorType) as IMadLevelGenerator; MadLevelConfiguration.Group group; if (chosenGroupIndex == 0) { group = conf.defaultGroup; } else { group = conf.groups[chosenGroupIndex - 1]; } for (int i = 1; i <= levelsCount; ++i) { MadLevelConfiguration.Level level = conf.CreateLevel(); level.sceneObject = scene; level.groupId = group.id; level.type = MadLevel.Type.Level; level.order = int.MaxValue; level.name = generator.GetLevelName(i); level.arguments = generator.GetLevelArguments(i); conf.levels.Add(level); conf.SetDirty(); } EditorUtility.SetDirty(conf); } }
bool GUIBitmapFontCreator() { MadGUI.Info( "The bitmap font creation mostly takes place outside Unity. " + "For this purpose you can use BMFont on Windows, Glyph Designer, or bmGlyph on Mac.\n\n" + "These tools will create a texture and FNT file that you should drag into the field below. " + "Please note that you should change FNT file extension to TXT."); MadGUI.PropertyField(texture, "Font Texture"); MadGUI.PropertyField(fntFile, "FNT File"); return(script.texture != null && script.fntFile != null); }
void RebuildButton() { GUILayout.Label("Rebuild", "HeaderLabel"); MadGUI.Indent(() => { MadGUI.Info("In a case when you've changed something, and result is not available on the screen, " + "please hit this button."); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); GUI.color = Color.green; if (GUILayout.Button("Rebuild Now")) { Rebuild(); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); }); }
void ActiveInfo() { bool assetLocationRight = IsAssetLocationRight(); GUI.enabled = assetLocationRight; var active = MadLevelConfiguration.FindActive(); if (active == configuration) { MadGUI.Info("This is the active configuration."); } else { string additional = ""; if (!assetLocationRight) { additional = " (But first you must relocate this asset. Please look at the other error.)"; } int choice = MadGUI.MessageWithButtonMulti("This configuration is not active. " + "It's not currently used to manage your scenes." + additional, MessageType.Warning, "Where is active?", "Activate"); if (choice == 0) { var currentlyActive = MadLevelConfiguration.FindActive(); if (currentlyActive != null) { EditorGUIUtility.PingObject(currentlyActive); } else { EditorUtility.DisplayDialog("Not Found", "No level configuration is active at the moment", "OK"); } } else if (choice == 1) { configuration.active = true; } } GUI.enabled = true; }
protected void LoadLevel() { MadGUI.PropertyFieldEnumPopup(loadLevel, "Load Level..."); switch (s.loadLevel) { case MadLevelAbstractLayout.LoadLevel.Immediately: // do nothing break; case MadLevelAbstractLayout.LoadLevel.WithDelay: using (MadGUI.Indent()) { MadGUI.PropertyField(loadLevelLoadLevelDelay, "Delay"); if (loadLevelLoadLevelDelay.floatValue < 0) { loadLevelLoadLevelDelay.floatValue = Mathf.Max(0, loadLevelLoadLevelDelay.floatValue); } } break; case MadLevelAbstractLayout.LoadLevel.SendMessage: using (MadGUI.Indent()) { MadGUI.Info("By choosing this option you are responsible for loading the level. " + "Activated MadLevelIcon will be passed as message argument."); MadGUI.PropertyField(loadLevelMessageReceiver, "Receiver", MadGUI.ObjectIsSet); MadGUI.PropertyField(loadLevelMessageName, "Method Name", MadGUI.StringNotEmpty); MadGUI.PropertyField(loadLevelMessageIncludeChildren, "Include Children"); } break; case MadLevelAbstractLayout.LoadLevel.DoNotLoad: // do nothing break; default: Debug.LogError("Unknown option: " + s.loadLevel); break; } }
protected void SectionSprite(DisplayFlag flags) { serializedObject.Update(); GUIDepthCheck(); MadGUI.PropertyField(panel, "Panel", MadGUI.ObjectIsSet); EditorGUILayout.Space(); MadGUI.PropertyField(visible, "Visible"); if ((flags & DisplayFlag.WithoutMaterial) == 0) { MadGUI.PropertyFieldEnumPopup(inputType, "Input Type"); MadGUI.Indent(() => { switch (sprite.inputType) { case MadSprite.InputType.SingleTexture: MadGUI.PropertyField(texture, "Texture", MadGUI.ObjectIsSet); MadGUI.Indent(() => { MadGUI.PropertyFieldVector2(textureRepeat, "Repeat"); MadGUI.PropertyFieldVector2(textureOffset, "Offset"); }); break; case MadSprite.InputType.TextureAtlas: MadGUI.PropertyField(textureAtlas, "Texture Atlas", MadGUI.ObjectIsSet); if (sprite.textureAtlas != null) { MadAtlasUtil.AtlasField(textureAtlasSpriteGUID, sprite.textureAtlas, "Sprite", this); } break; default: Debug.LogError("Unknown input type: " + sprite.inputType); break; } }); } MadGUI.PropertyField(hasPremultipliedAlpha, "Has Pre-Alpha"); MadGUI.PropertyField(tint, "Tint"); EditorGUILayout.Space(); if ((flags & DisplayFlag.WithoutSize) == 0) { EditorGUILayout.Space(); GUI.backgroundColor = Color.yellow; if (GUILayout.Button(new GUIContent("Resize To Texture", "Resizes this sprite to match texture size"))) { MadUndo.RecordObject2(sprite, "Resize To Texture"); sprite.ResizeToTexture(); EditorUtility.SetDirty(sprite); } GUI.backgroundColor = Color.white; EditorGUILayout.Space(); } EditorGUILayout.Space(); MadGUI.PropertyField(pivotPoint, "Pivot Point"); if (sprite.pivotPoint == MadSprite.PivotPoint.Custom) { MadGUI.Indent(() => { MadGUI.PropertyFieldVector2(customPivotPoint, "Custom Pivot Point"); }); } MadGUI.PropertyField(guiDepth, "GUI Depth"); EditorGUILayout.Space(); if ((flags & DisplayFlag.WithoutFill) == 0) { MadGUI.PropertyField(fillType, "Fill Type"); EditorGUILayout.Slider(fillValue, 0, 1, "Fill Value"); if (sprite.fillType == MadSprite.FillType.RadialCCW || sprite.fillType == MadSprite.FillType.RadialCW) { MadGUI.PropertyFieldSlider(radialFillOffset, -1, 1, "Offset"); MadGUI.PropertyFieldSlider(radialFillLength, 0, 1, "Length"); } } if (showLiveBounds) { GUILayout.Label("Sprite Border", "HeaderLabel"); EditorGUILayout.Space(); if (sprite.CanDraw()) { FieldLiveBounds(); } else { MadGUI.Info("More settings will be available when the sprite texture or atlas is set."); } } serializedObject.ApplyModifiedProperties(); }
private void Properties() { MadGUI.BeginBox("Children"); MadGUI.Indent(() => { MadGUI.Info("Properties are persistent values saved and loaded from the current game state. " + "They are good for things like stars or medals."); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Create:"); GUI.backgroundColor = Color.green; if (GUILayout.Button("Empty")) { if (ShouldCreateProperty()) { CreateEmptyProperty(); } else { CreateEmpty(); } } if (GUILayout.Button("Sprite")) { if (ShouldCreateProperty()) { CreateSpriteProperty(); } else { CreateSprite(); } } if (GUILayout.Button("Text")) { if (ShouldCreateProperty()) { CreateTextProperty(); } else { CreateText(); } } GUI.color = Color.white; GUI.backgroundColor = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); var properties = PropertyList(); foreach (MadLevelProperty property in properties) { GUILayout.BeginHorizontal(); MadGUI.LookLikeControls(0, 150); property.name = EditorGUILayout.TextField(property.name, GUILayout.Width(120)); MadGUI.LookLikeControls(0); //GUILayout.Label(property.name, GUILayout.Width(170)); GUILayout.FlexibleSpace(); GUILayout.Label("Default State: "); if (property.linked) { if (MadGUI.Button("LINKED", Color.cyan, GUILayout.Width(60))) { if (EditorUtility.DisplayDialog( "State Linked", "This property state is linked by '" + property.linkage.name + "' property and cannot be changed directly. Do you want to select the linkage owner?", "Yes", "No")) { Selection.activeObject = property.linkage.gameObject; } } } else if (property.propertyEnabled) { if (MadGUI.Button("ON", Color.green, GUILayout.Width(60))) { property.propertyEnabled = false; EditorUtility.SetDirty(property); } } else { if (MadGUI.Button("OFF", Color.red, GUILayout.Width(60))) { property.propertyEnabled = true; EditorUtility.SetDirty(property); } } GUILayout.FlexibleSpace(); GUI.backgroundColor = Color.yellow; if (GUILayout.Button("Select", GUILayout.Width(55))) { Selection.activeGameObject = property.gameObject; } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); } }); EditorGUILayout.Space(); MadGUI.Info("Level icon's text value will be set to current level number."); if (TextList().Count == 0) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Level Number"); if (MadGUI.Button("Create New", Color.green)) { var text = CreateText(); text.gameObject.name = "level number"; text.font = MadAssets.TryLoadComponent <MadFont>(DefaultFontGUID); text.text = "1"; text.scale = 90; levelIcon.levelNumber = text; } EditorGUILayout.EndHorizontal(); } else { MadGUI.PropertyFieldObjectsPopup <MadText>( target, "Level Number", ref levelIcon.levelNumber, TextList(), false ); } MadGUI.EndBox(); }
public override void OnInspectorGUI() { if (MadTrialEditor.isTrialVersion && MadTrialEditor.expired) { MadTrialEditor.OnEditorGUIExpired("Mad Level Manager"); return; } serializedObject.UpdateIfDirtyOrScript(); GUILayout.Label("Fundaments", "HeaderLabel"); MadGUI.Indent(() => { ConfigurationField(); if (script.currentConfiguration != null) { var group = script.currentConfiguration.FindGroupById(script.configurationGroup); int index = GroupToIndex(script.currentConfiguration, group); var names = GroupNames(script.currentConfiguration); EditorGUI.BeginChangeCheck(); index = EditorGUILayout.Popup("Group", index, names); if (EditorGUI.EndChangeCheck()) { MadUndo.RecordObject2(script, "Changed Group"); script.configurationGroup = IndexToGroup(script.currentConfiguration, index).id; script.dirty = true; EditorUtility.SetDirty(script); } GUI.enabled = true; } EditorGUILayout.Space(); MadGUI.PropertyField(iconTemplate, "Icon Template", MadGUI.ObjectIsSet); if (script.iconTemplate != null) { var prefabType = PrefabUtility.GetPrefabType(script.iconTemplate); if (prefabType == PrefabType.None) { MadGUI.Warning("It's recommended to use prefab as a template. All visible icon instances will be linked to this prefab."); } } using (MadGUI.Indent()) { MadGUI.PropertyFieldEnumPopup(enumerationType, "Enumeration"); using (MadGUI.Indent()) { MadGUI.PropertyField(enumerationOffset, "Offset"); } } EditorGUILayout.Space(); MadGUI.PropertyField(backgroundTexture, "Background Texture"); EditorGUILayout.Space(); MadGUI.Info("Use the button below if you've updated your icon template and you want to replace all icons in your layout with it."); if (MadGUI.Button("Replace All Icons", Color.yellow)) { ReplaceAllIcons(); } MadGUI.Info("More customization options are available in the Draggable object."); if (MadGUI.Button("Select Draggable", Color.magenta)) { SelectDraggable(); } }); EditorGUILayout.Space(); GUILayout.Label("Mechanics", "HeaderLabel"); MadGUI.Indent(() => { LookAtLastLevel(); EditorGUILayout.Space(); HandleMobileBack(); EditorGUILayout.Space(); TwoStepActivation(); EditorGUILayout.Space(); LoadLevel(); }); serializedObject.ApplyModifiedProperties(); }
private static void GUIMainCameraWillBeUsed() { MadGUI.Info("MainCamera is used by default."); }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); MadGUI.PropertyField(draggable, "Draggable", MadGUI.ObjectIsSet); MadGUI.PropertyField(startDepth, "Start Depth", "Depth value of first layer added. " + "Every next layer will receive +1 to it's depth value."); MadGUI.PropertyField(ignoreXMovement, "Ignore X Movement"); MadGUI.PropertyField(ignoreYMovement, "Ignore Y Movement"); serializedObject.ApplyModifiedProperties(); MadGUI.Info("Add new layers, then select them to edit properties for each layer."); var arrayList = new MadGUI.ArrayList <MadLevelBackgroundLayer>(script.layers, (layer) => { if (layer == null) { return(null); } var so = new SerializedObject(layer); so.UpdateIfDirtyOrScript(); var texture = so.FindProperty("texture"); EditorGUILayout.BeginHorizontal(); MadGUI.PropertyField(texture, ""); MadGUI.ConditionallyEnabled(CanMoveUp(layer), () => { if (GUILayout.Button("Up")) { MoveUp(layer); } }); MadGUI.ConditionallyEnabled(CanMoveDown(layer), () => { if (GUILayout.Button("Down")) { MoveDown(layer); } }); GUI.color = Color.yellow; if (GUILayout.Button("Select")) { Selection.activeGameObject = layer.gameObject; } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); if (so.ApplyModifiedProperties()) { layer.SetDirty(); } return(layer); }); arrayList.addLabel = "Add Layer"; arrayList.emptyLabel = "There are currently no layers."; arrayList.createFunctionGeneric = () => { var layer = MadTransform.CreateChild <MadLevelBackgroundLayer>(script.transform, "layer (empty)"); layer.GetComponent <MadSprite>().hideFlags = HideFlags.HideInInspector; return(layer); }; arrayList.onRemove = (layer) => layer.Cleanup(); arrayList.beforeAdd = () => { MadUndo.RecordObject(script, "Add Background Layer"); MadUndo.LegacyRegisterSceneUndo("Add Background Layer"); }; arrayList.beforeRemove = (arg) => { MadUndo.RecordObject(script, "Remove Background Layer"); MadUndo.LegacyRegisterSceneUndo("Remove Background Layer"); return(true); }; if (arrayList.Draw()) { EditorUtility.SetDirty(script); } EditorGUI.BeginChangeCheck(); if (EditorGUI.EndChangeCheck()) { // changed } }