public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); MadGUI.PropertyField(dragArea, "Drag Area"); MadGUI.PropertyFieldVector2(dragStartPosition, "Drag Start Position"); MadGUI.PropertyField(scaling, "Allow Scaling"); MadGUI.ConditionallyEnabled(scaling.boolValue, () => { MadGUI.Indent(() => { MadGUI.PropertyField(scalingMin, "Scaling Min"); MadGUI.PropertyField(scalingMax, "Scaling Max"); }); }); MadGUI.PropertyField(moveEasing, "Move Easing"); MadGUI.ConditionallyEnabled(moveEasing.boolValue, () => { MadGUI.Indent(() => { MadGUI.PropertyField(moveEasingType, "Type"); MadGUI.PropertyField(moveEasingDuration, "Duration"); }); }); MadGUI.PropertyField(scaleEasing, "Scale Easing"); MadGUI.ConditionallyEnabled(scaleEasing.boolValue, () => { MadGUI.Indent(() => { MadGUI.PropertyField(scaleEasingType, "Type"); MadGUI.PropertyField(scaleEasingDuration, "Duration"); }); }); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); GUI.color = Color.yellow; if (GUILayout.Button("<< Back To Layer Listing")) { Selection.activeGameObject = layer.parent.gameObject; } GUI.color = Color.white; GUILayout.Space(16); MadGUI.PropertyField(texture, "Texture"); MadGUI.PropertyField(tint, "Tint"); EditorGUILayout.Space(); MadGUI.PropertyField(scaleMode, "Scale Mode"); MadGUI.PropertyField(repeatX, "Repeat X"); MadGUI.PropertyField(repeatY, "Repeat Y"); MadGUI.ConditionallyEnabled(layer.scaleMode == MadLevelBackgroundLayer.ScaleMode.Fill && !layer.repeatX && !layer.repeatY, () => { if (MadGUI.Foldout("Margin", false)) { MadGUI.Indent(() => { MadGUI.PropertyField(fillMarginLeft, "Left"); MadGUI.PropertyField(fillMarginTop, "Top"); MadGUI.PropertyField(fillMarginRight, "Right"); MadGUI.PropertyField(fillMarginBottom, "Bottom"); }); } }); MadGUI.ConditionallyEnabled(!layer.repeatX && !layer.repeatY, () => { MadGUI.PropertyField(dontStretch, "Don't Stretch"); }); if (scaleMode.enumValueIndex == (int)MadLevelBackgroundLayer.ScaleMode.Manual) { MadGUI.PropertyField(align, "Align"); EditorGUILayout.Space(); MadGUI.PropertyFieldVector2Compact(position, "Position", 70); MadGUI.PropertyFieldVector2Compact(scale, "Scale", 70); } else { MadGUI.PropertyFieldVector2Compact(position, "Position", 70); } EditorGUILayout.Space(); MadGUI.PropertyField(followSpeed, "Follow Speed"); MadGUI.PropertyFieldVector2Compact(scrollSpeed, "Auto Scroll", 70); if (serializedObject.ApplyModifiedProperties()) { layer.SetDirty(); } }
void GUICreator(bool created) { serializedObject.Update(); MadGUI.PropertyField(inputType, "Input Type"); bool canCreate = false; switch ((MadFont.InputType)inputType.enumValueIndex) { case MadFont.InputType.TextureAndGlyphList: canCreate = GUITextureAndGlyphListCreator(); break; case MadFont.InputType.Bitmap: canCreate = GUIBitmapFontCreator(); break; } EditorGUI.BeginChangeCheck(); MadGUI.PropertyField(forceWhite, "Force White Color", "Forces this font to be rendered with white color only."); if (EditorGUI.EndChangeCheck()) { if (script.created) { ReloadColors(); } } MadGUI.ConditionallyEnabled(!forceWhite.boolValue, () => { EditorGUI.BeginChangeCheck(); primaryColor = EditorGUILayout.ColorField("Primary Color", primaryColor); secondaryColor = EditorGUILayout.ColorField("Secondary Color", secondaryColor); if (EditorGUI.EndChangeCheck()) { if (created) { SetColors(); } } }); serializedObject.ApplyModifiedProperties(); GUI.enabled = canCreate; if (GUILayout.Button(created ? "Recreate" : "Create")) { var builder = new MadFontBuilder(script); builder.white = forceWhite.boolValue; builder.Build(); if (!forceWhite.boolValue && script.created) { SetColors(); } } GUI.enabled = true; }
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)"); } }); }); }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); MadGUI.PropertyField(dragBounds, "Drag Area"); EditorGUILayout.Space(); MadGUI.ConditionallyEnabled(HasBackground(), () => { if (MadGUI.Button("Resize Drag Area To Background", Color.yellow)) { ResizeDragAreaToBackground(); } }); EditorGUILayout.Space(); MadGUI.PropertyFieldEnumPopup(scaleMode, "Allow Scaling"); MadGUI.ConditionallyEnabled(script.scaleMode == MadFreeDraggable.ScaleMode.Free, () => { MadGUI.Indent(() => { MadGUI.PropertyField(scalingMin, "Scaling Min"); MadGUI.PropertyField(scalingMax, "Scaling Max"); }); }); EditorGUILayout.Space(); MadGUI.PropertyField(moveEasing, "Move Easing"); MadGUI.ConditionallyEnabled(moveEasing.boolValue, () => { MadGUI.Indent(() => { MadGUI.PropertyField(moveEasingType, "Type"); MadGUI.PropertyField(moveEasingDuration, "Duration"); }); }); EditorGUILayout.Space(); MadGUI.PropertyField(scaleEasing, "Scale Easing"); MadGUI.ConditionallyEnabled(scaleEasing.boolValue, () => { MadGUI.Indent(() => { MadGUI.PropertyField(scaleEasingType, "Type"); MadGUI.PropertyField(scaleEasingDuration, "Duration"); }); }); serializedObject.ApplyModifiedProperties(); }
protected void TwoStepActivation() { MadGUI.PropertyFieldEnumPopup(twoStepActivationType, "Two Step Activation"); MadGUI.ConditionallyEnabled( twoStepActivationType.enumValueIndex != (int)MadLevelAbstractLayout.TwoStepActivationType.Disabled, () => { MadGUI.Indent(() => { if (MadGUI.Foldout("On Activate", false)) { MadGUI.Indent(() => { ActivateAction( onIconActivatePlayAudio, onIconActivatePlayAudioClip, onIconActivatePlayAudioVolume, onIconActivateMessage, onIconActivateMessageReceiver, onIconActivateMessageMethodName, onIconActivateMessageIncludeChildren ); }); } if (MadGUI.Foldout("On Deactivate", false)) { MadGUI.Indent(() => { ActivateAction( onIconDeactivatePlayAudio, onIconDeactivatePlayAudioClip, onIconDeactivatePlayAudioVolume, onIconDeactivateMessage, onIconDeactivateMessageReceiver, onIconDeactivateMessageMethodName, onIconDeactivateMessageIncludeChildren ); }); } }); }); }
public static void AtlasField(SerializedProperty textureField, MadAtlas atlas, string label, ScriptableObject parent) { string guid = textureField.stringValue; string spriteName = ""; if (!string.IsNullOrEmpty(guid) && atlas != null) { var item = atlas.GetItem(guid); if (item != null) { spriteName = item.name; } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.TextField(label, spriteName); MadGUI.ConditionallyEnabled(atlas != null, () => { if (GUILayout.Button("Browse", GUILayout.Width(55))) { MadAtlasBrowser.Show(atlas, textureField, parent); } }); EditorGUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { newSetupMethod = (MadLevelGridLayout.SetupMethod)EditorGUILayout.EnumPopup("Setup Method", script.setupMethod); if (newSetupMethod != script.setupMethod) { if (newSetupMethod == MadLevelGridLayout.SetupMethod.Generate && EditorUtility.DisplayDialog( "Are you sure?", "Are you sure that you want to switch to Generate setup method? If you've made any changes to grid " + "object, these changes will be lost!", "Set to Generate", "Cancel")) { script.setupMethod = newSetupMethod; script.deepClean = true; EditorUtility.SetDirty(script); } else { script.setupMethod = newSetupMethod; EditorUtility.SetDirty(script); } } serializedObject.UpdateIfDirtyOrScript(); if (script.setupMethod == MadLevelGridLayout.SetupMethod.Generate) { RebuildButton(); } GUILayout.Label("Fundaments", "HeaderLabel"); MadGUI.Indent(() => { MadGUI.PropertyField(configuration, "Configuration", MadGUI.ObjectIsSet); GUI.enabled = generate; MadGUI.PropertyField(iconTemplate, "Icon Template", MadGUI.ObjectIsSet); MadGUI.Indent(() => { MadGUI.PropertyFieldVector2(iconScale, "Scale"); MadGUI.PropertyFieldVector2(iconOffset, "Offset"); }); GUI.enabled = true; MadGUI.PropertyField(leftSlideSprite, "Prev Page Sprite"); MadGUI.Indent(() => { MadGUI.PropertyFieldVector2(leftSlideScale, "Scale"); MadGUI.PropertyFieldVector2(leftSlideOffset, "Offset"); }); MadGUI.PropertyField(rightSlideSprite, "Next Page Sprite"); MadGUI.Indent(() => { MadGUI.PropertyFieldVector2(rightSlideScale, "Scale"); MadGUI.PropertyFieldVector2(rightSlideOffset, "Offset"); }); }); GUILayout.Label("Dimensions", "HeaderLabel"); MadGUI.Indent(() => { MadGUI.PropertyField(pixelsWidth, "Pixels Width"); MadGUI.PropertyField(pixelsHeight, "Pixels Height"); GUI.enabled = generate; MadGUI.PropertyField(gridHeight, "Grid Rows"); MadGUI.PropertyField(gridWidth, "Grid Columns"); GUI.enabled = true; MadGUI.PropertyField(pagesOffsetFromResolution, "Page Offset Auto"); MadGUI.ConditionallyEnabled(!pagesOffsetFromResolution.boolValue, () => { MadGUI.Indent(() => { MadGUI.PropertyField(pagesOffsetManual, "Pixels Offset"); }); }); }); GUILayout.Label("Mechanics", "HeaderLabel"); MadGUI.Indent(() => { MadGUI.PropertyField(lookAtLastLevel, "Look At Last Level", "When scene is loaded, it will automatically " + "go to the page of previously played level (but only if previous scene is of type Level."); HandleMobileBack(); TwoStepActivation(); }); GUILayout.Label("Debug", "HeaderLabel"); MadGUI.Indent(() => { MadGUI.PropertyField(hideManagerdObjects, "Hide Managed", "Hides managed by Mad Level Manager objects from the Hierarchy. If you want to have a look at what the hierarchy " + "looks like exacly, you can unckeck this option. Be aware that all direct changes to generated " + "objects will be lost!"); }); serializedObject.ApplyModifiedProperties(); }
void OnGUI() { var size = EditorGUILayout.BeginVertical(); GUILayout.Label(description); GUI.SetNextControlName("TextField"); MadGUI.Validate(() => { if (allowEmpty || !string.IsNullOrEmpty(textValue)) { return(true); } else { return(false); } }, () => { textValue = EditorGUILayout.TextField(textValue); }); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); MadGUI.ConditionallyEnabled(allowEmpty || !string.IsNullOrEmpty(textValue), () => { GUI.backgroundColor = Color.green; if (GUILayout.Button(okLabel)) { Close(); callback(textValue); } GUI.backgroundColor = Color.white; }); if (GUILayout.Button(cancelLabel)) { Close(); callback(null); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); if (!positionSet && Event.current.type == EventType.Repaint) { position = new Rect(position.x, position.y, size.width, size.height); positionSet = true; GUI.FocusControl("TextField"); } if (allowEmpty || !string.IsNullOrEmpty(textValue)) { if (Event.current.isKey && Event.current.keyCode == KeyCode.Return) { Close(); callback(textValue); } } }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); EditorGUILayout.Space(); if (MadGUI.Button("Select Parent Icon", Color.yellow)) { Selection.activeObject = property.icon.gameObject; } EditorGUILayout.Space(); GUILayout.Label("Property", "HeaderLabel"); EditorGUILayout.Space(); MadGUI.Indent(() => { EditorGUILayout.Space(); GUILayout.Label("Property Name: " + property.name); EditorGUILayout.BeginHorizontal(); GUILayout.Label("State"); GUILayout.FlexibleSpace(); 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(50))) { property.propertyEnabled = false; EditorUtility.SetDirty(property); } } else { if (MadGUI.Button("Off", Color.red, GUILayout.Width(50))) { property.propertyEnabled = true; EditorUtility.SetDirty(property); } } EditorGUILayout.EndHorizontal(); if (property.GetComponent <MadText>() != null) { EditorGUILayout.Space(); MadGUI.PropertyField(textFromProperty, "Text From Property"); MadGUI.ConditionallyEnabled(textFromProperty.boolValue, () => { MadGUI.PropertyField(textPropertyName, "Text Property Name"); }); } }); GUILayout.Label("Connections", "HeaderLabel"); EditorGUILayout.Space(); MadGUI.Indent(() => { bool connectionChanged; GUILayout.Label("Things to show when this property is enabled:"); connectionChanged = new MadGUI.ArrayList <GameObject>(showWhenEnabled, (p) => { MadGUI.PropertyField(p, ""); }).Draw(); if (connectionChanged) { property.icon.ApplyConnections(); } EditorGUILayout.Space(); GUILayout.Label("Things to show when this property is disabled:"); connectionChanged = new MadGUI.ArrayList <GameObject>(showWhenDisabled, (p) => { MadGUI.PropertyField(p, ""); }).Draw(); if (connectionChanged) { property.icon.ApplyConnections(); } }); serializedObject.ApplyModifiedProperties(); }
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(); var arrayList = new MadGUI.ArrayList <MadLevelBackgroundLayer>(script.layers, (layer) => { if (layer == null) { return; } 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(); } }); 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"); }; if (arrayList.Draw()) { EditorUtility.SetDirty(script); } EditorGUI.BeginChangeCheck(); if (EditorGUI.EndChangeCheck()) { // changed } }
public override void OnInspectorGUI() { if (MadTrialEditor.isTrialVersion && MadTrialEditor.expired) { MadTrialEditor.OnEditorGUIExpired("Mad Level Manager"); return; } newSetupMethod = (MadLevelGridLayout.SetupMethod)EditorGUILayout.EnumPopup("Setup Method", script.setupMethod); if (newSetupMethod != script.setupMethod) { if (newSetupMethod == MadLevelGridLayout.SetupMethod.Generate && EditorUtility.DisplayDialog( "Are you sure?", "Are you sure that you want to switch to Generate setup method? If you've made any changes to grid " + "object, these changes will be lost!", "Set to Generate", "Cancel")) { script.setupMethod = newSetupMethod; script.deepClean = true; EditorUtility.SetDirty(script); } else if (EditorUtility.DisplayDialog( "Are you sure?", "Are you sure that you want to switch to Manual setup method? Be aware that after doing this:\n" + "- You won't be able to change your level group (currently " + script.configuration.FindGroupById(script.configurationGroup).name + ")\n" + "- You won't be able to regenerate grid without losing custom changes", "Set to Manual", "Cancel")) { script.setupMethod = newSetupMethod; EditorUtility.SetDirty(script); } } serializedObject.UpdateIfDirtyOrScript(); if (script.setupMethod == MadLevelGridLayout.SetupMethod.Generate) { RebuildButton(); } GUILayout.Label("Fundaments", "HeaderLabel"); MadGUI.Indent(() => { MadGUI.PropertyField(configuration, "Configuration", MadGUI.ObjectIsSet); if (script.configuration != null) { var group = script.configuration.FindGroupById(script.configurationGroup); int index = GroupToIndex(script.configuration, group); var names = GroupNames(script.configuration); GUI.enabled = script.setupMethod == MadLevelGridLayout.SetupMethod.Generate; EditorGUI.BeginChangeCheck(); index = EditorGUILayout.Popup("Group", index, names); if (EditorGUI.EndChangeCheck()) { script.configurationGroup = IndexToGroup(script.configuration, index).id; Rebuild(); } GUI.enabled = true; } EditorGUILayout.Space(); GUI.enabled = generate; 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"); MadGUI.PropertyFieldVector2(iconScale, "Scale"); MadGUI.PropertyFieldVector2(iconOffset, "Offset"); } EditorGUILayout.Space(); GUI.enabled = true; MadGUI.PropertyField(leftSlideSprite, "Prev Page Sprite"); MadGUI.Indent(() => { MadGUI.PropertyFieldVector2(leftSlideScale, "Scale"); MadGUI.PropertyFieldVector2(leftSlideOffset, "Offset"); }); MadGUI.PropertyField(rightSlideSprite, "Next Page Sprite"); MadGUI.Indent(() => { MadGUI.PropertyFieldVector2(rightSlideScale, "Scale"); MadGUI.PropertyFieldVector2(rightSlideOffset, "Offset"); }); }); EditorGUILayout.Space(); GUILayout.Label("Dimensions", "HeaderLabel"); MadGUI.Indent(() => { MadGUI.PropertyField(pixelsWidth, "Pixels Width"); MadGUI.PropertyField(pixelsHeight, "Pixels Height"); EditorGUILayout.Space(); GUI.enabled = generate; MadGUI.PropertyField(gridHeight, "Grid Rows"); MadGUI.PropertyField(gridWidth, "Grid Columns"); EditorGUILayout.Space(); MadGUI.PropertyFieldEnumPopup(horizontalAlign, "Horizontal Align"); MadGUI.PropertyFieldEnumPopup(verticalAlign, "Vertical Align"); GUI.enabled = true; EditorGUILayout.Space(); MadGUI.PropertyField(pagesOffsetFromResolution, "Page Offset Auto"); MadGUI.ConditionallyEnabled(!pagesOffsetFromResolution.boolValue, () => { MadGUI.Indent(() => { MadGUI.PropertyField(pagesOffsetManual, "Pixels Offset"); }); }); }); EditorGUILayout.Space(); GUILayout.Label("Mechanics", "HeaderLabel"); MadGUI.Indent(() => { LookAtLastLevel(); EditorGUILayout.Space(); HandleMobileBack(); EditorGUILayout.Space(); TwoStepActivation(); EditorGUILayout.Space(); LoadLevel(); }); GUILayout.Label("Debug", "HeaderLabel"); MadGUI.Indent(() => { MadGUI.PropertyField(hideManagerdObjects, "Hide Managed", "Hides managed by Mad Level Manager objects from the Hierarchy. If you want to have a look at what the hierarchy " + "looks like exacly, you can unckeck this option. Be aware that all direct changes to generated " + "objects will be lost!"); }); serializedObject.ApplyModifiedProperties(); }