public static void CreateAsset() { string currentPath = AssetDatabase.GetAssetPath(Selection.activeObject); if (!string.IsNullOrEmpty(currentPath) && currentPath.EndsWith("Resources/LevelConfig")) { MadAssets.CreateAsset <MadLevelConfiguration>("New Configuration"); } else { MadAssets.CreateAsset <MadLevelConfiguration>("New Configuration", "Assets/Resources/LevelConfig"); } }
static void OpenSettings() { var settings = Resources.Load("MLM_Settings", typeof(MadLevelSettings)); if (settings == null) { if (!Directory.Exists("Assets/Resources")) { Directory.CreateDirectory("Assets/Resources"); } MadAssets.CreateAsset <MadLevelSettings>("Resources/MLM_Settings"); settings = Resources.Load("MLM_Settings", typeof(MadLevelSettings)); } Selection.activeObject = settings; }
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(); }
void InitTemplates(MadRootNode root, out MadLevelIcon icon, out MadSprite slideLeftSprite, out MadSprite slideRightSprite) { var panel = MadTransform.FindChild <MadPanel>(root.transform); var templates = MadTransform.CreateChild(panel.transform, "Templates"); GameObject iconPrefab = MadAssets.TryLoadGameObject(IconPrefabGUID); GameObject slideLeftPrefab = MadAssets.TryLoadGameObject(SlideLeftPrefabGUID); GameObject slideRightPrefab = MadAssets.TryLoadGameObject(SlideRightPrefabGUID); if (MadGameObject.AnyNull(iconPrefab, slideLeftPrefab, slideRightPrefab)) { Debug.LogWarning("I cannot find all needed prefabs to create example templates. Have you removed Mad Level " + "Manager example prefabs?"); } if (iconPrefab != null) { var obj = PrefabUtility.InstantiatePrefab(iconPrefab) as GameObject; obj.transform.parent = templates.transform; obj.name = "icon"; obj.transform.localScale = Vector3.one; obj.transform.localPosition = new Vector2(-400, 150); icon = obj.GetComponent <MadLevelIcon>(); } else { icon = null; } if (slideLeftPrefab != null) { var slide = PrefabUtility.InstantiatePrefab(slideLeftPrefab) as GameObject; slide.transform.parent = templates.transform; slide.name = "slide left"; slide.transform.localScale = Vector3.one; slide.transform.localPosition = new Vector2(-400, 0); slideLeftSprite = slide.GetComponent <MadSprite>(); } else { slideLeftSprite = null; } if (slideRightPrefab != null) { var slide = PrefabUtility.InstantiatePrefab(slideRightPrefab) as GameObject; slide.transform.parent = templates.transform; slide.name = "slide right"; slide.transform.localScale = Vector3.one; slide.transform.localPosition = new Vector2(-400, -150); slideRightSprite = slide.GetComponent <MadSprite>(); } else { slideRightSprite = null; } MadGameObject.SetActive(templates, false); }
public static void CreateAsset() { MadAssets.CreateAsset <MadLevelConfiguration>("New Configuration"); }