private void ManipulateWorld(string command) { World world = LoadWorld(); if (world == null) { return; } switch (command) { case "SetToCurrentVersion": PackageInfo pi = PackageInfo.FindForAssetPath("Packages/com.wetzold.travrsal.sdk/package.json"); if (pi != null) { world.minAppVersion = pi.version; EditorUtility.DisplayDialog("Success", $"Set minimum app version required to play the world to {pi.version}.", "OK"); } break; case "AddZone": if (string.IsNullOrEmpty(zoneName)) { return; } string root = GetWorldPaths()[0]; string path = $"{root}/Data/{zoneName}.tmx"; if (File.Exists(path)) { EditorUtility.DisplayDialog("Error", "A zone with that name already exists.", "OK"); return; } AssetDatabase.CopyAsset($"Packages/{SDKUtil.PACKAGE_NAME}/Editor/CopyTemplates/EmptyZone.copy", $"Assets/Worlds/{world.key}/Data/{zoneName}.tmx"); // two cases: either world explicitly lists files already or default is used with config.world mechanism if (world.worldData != null && world.worldData.Count > 0) { world.worldData.Add(new WorldDataReference(path, WorldDataReference.ImportType.TileMap)); } else { string mapFile = root + "/Data/Config.world"; TMWorld worldMap = SDKUtil.ReadJSONFileDirect <TMWorld>(mapFile); if (worldMap != null) { worldMap.maps = worldMap.maps.Append(new WorldMap(Path.GetFileName(path))); File.WriteAllText(mapFile, SDKUtil.SerializeObject(worldMap)); } else { EditorUtility.DisplayDialog("Error", $"Data/Config.world file for {world.key} does not exist. New zone was created but needs to be manually linked.", "OK"); } } zoneName = ""; AssetDatabase.Refresh(); break; case "AddVariable": if (string.IsNullOrEmpty(varName)) { return; } if (world.initialVariables == null) { world.initialVariables = new List <Variable>(); } world.initialVariables.Add(new Variable(varName)); varName = ""; break; case "AddSetting": if (string.IsNullOrEmpty(worldSetting)) { return; } if (world.settings == null) { world.settings = new List <WorldSetting>(); } world.settings.Add(new WorldSetting(worldSetting)); worldSetting = ""; break; case "AddCustomShader": if (string.IsNullOrEmpty(customShader)) { return; } if (world.customShaders == null) { world.customShaders = new List <string>(); } world.customShaders.Add(customShader); customShader = ""; break; case "SetFixedTileCount": if (string.IsNullOrEmpty(fixedSize)) { return; } int size = int.Parse(fixedSize); if (size <= 0) { return; } world.minSize = $"{size},{size}"; world.maxSize = $"{size},{size}"; fixedSize = ""; break; } SaveWorld(world); }