private void OnValidate() { LevelOrderSettings levelOrderSettings = globalSettings.LevelOrderSettings; for (int i = 0; i < levelOrderSettings.RuleSettings.Length; i++) { int levelIdentifier = i + 1; string result = "" + levelIdentifier; levelOrderSettings.RuleSettings[i].Id = result; } }
public static void CreateLevelGroups() { List <int> collectionSizes = new List <int> { 6, 9, 12, 15, 18, 18, 21, 18, 21, 21, 21, 21, 21, 24, 27, 27, 27, 27, 24, 27, 27, 27, 30, 30, 30, 30, 39, 39, 39, 39, 39, 39 }; LevelOrderSettings levelOrder = (LevelOrderSettings)AssetDatabase.LoadAssetAtPath("Assets/" + GameConstants.GameName.NameOfGame + "/Settings/LevelOrder/LevelOrder.asset", typeof(LevelOrderSettings)); int levelNumber = 0; // make level group assets for (int i = 1; i < (collectionSizes.Count + 1); i++) // needs to be one more than number of collections { string name = "Assets/" + GameConstants.GameName.NameOfGame + "/Settings/LevelGroupings/LevelGroup" + i + ".asset"; Sprite levelCard = (Sprite)AssetDatabase.LoadAssetAtPath("Assets/" + GameConstants.GameName.NameOfGame + "/Textures/Icons/Level card icons/QXALUIBlurredPhoto" + i + ".png", typeof(Sprite)); Sprite background = (Sprite)AssetDatabase.LoadAssetAtPath("Assets/" + GameConstants.GameName.NameOfGame + "/Textures/Backgrounds/QXALUIBackground" + i + ".png", typeof(Sprite)); Sprite backgroundMain = (Sprite)AssetDatabase.LoadAssetAtPath("Assets/" + GameConstants.GameName.NameOfGame + "/Textures/Backgrounds/QXALUIBackgroundMain" + i + ".png", typeof(Sprite)); AssertExistingAsset(name); LevelGroupingSettings newLevelGroupSettings = ScriptableObject.CreateInstance("LevelGroupingSettings") as LevelGroupingSettings; newLevelGroupSettings.Init(i.ToString(), false, levelCard, background, backgroundMain); for (int j = 0; j < collectionSizes[i - 1]; j++) { if (!levelOrder.RuleSettings[levelNumber + j].IsGold) { newLevelGroupSettings.Levels.Add(levelOrder.RuleSettings[levelNumber + j]); } else { newLevelGroupSettings.GoldLevels.Add(levelOrder.RuleSettings[levelNumber + j]); } } string suffix = GetPrefabSuffix(newLevelGroupSettings.Levels.Count, newLevelGroupSettings.GoldLevels.Count); GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath("Assets/" + GameConstants.GameName.NameOfGame + "/Prefabs/CollectionWindows/Collection-" + suffix + ".prefab", typeof(GameObject)); newLevelGroupSettings.CollectionPrefab = prefab; levelNumber += collectionSizes[i - 1]; AssetDatabase.CreateAsset(newLevelGroupSettings, name); AssetDatabase.SaveAssets(); } }