public void LoadScenario(string path) { CurrentScenario = ScenarioSpreadsheetLoader.LoadSocialMediaScenario(path); }
static void DoImport() { var file = EditorUtility.OpenFilePanel("Choose spreadsheet", "", "xlsx"); if (!string.IsNullOrWhiteSpace(file)) { var scenarioName = Path.GetFileNameWithoutExtension(file); var folder = Path.GetDirectoryName("Assets/Data/SocialMediaFeed/"); var newFolder = Path.Combine(folder, "_Imported", scenarioName); if (!Directory.Exists(Path.Combine(folder, "_Imported"))) { AssetDatabase.CreateFolder(folder, "_Imported"); } AssetDatabase.DeleteAsset(newFolder); AssetDatabase.CreateFolder(Path.Combine(folder, "_Imported"), scenarioName); var newData = ScenarioSpreadsheetLoader.LoadSocialMediaScenario(file); SaveOnlineProfile(newData.senderProfile, newFolder); SaveOnlineProfile(newData.receiverProfile, newFolder); if (newData.recommendedVideos.Any()) { var recommenedVideosFolder = Path.Combine(newFolder, "RecommendedVideos"); if (!AssetDatabase.IsValidFolder(recommenedVideosFolder)) { AssetDatabase.CreateFolder(newFolder, "RecommendedVideos"); } int index = 1; foreach (var video in newData.recommendedVideos) { SaveRecommendedVideo(video, recommenedVideosFolder, index++); } } foreach (var messageFeedType in (SocialMediaScenatioMessageFeedType[])Enum.GetValues(typeof(SocialMediaScenatioMessageFeedType))) { var messageFeed = newData.GetMessageFeed(messageFeedType); if (messageFeed == null) { continue; } var name = Enum.GetName(typeof(SocialMediaScenatioMessageFeedType), messageFeedType); AssetDatabase.CreateFolder(newFolder, name); SaveMessageFeed(messageFeed, Path.Combine(newFolder, name), name); } foreach (var messageFeedType in (SocialMediaScenarioSMStype[])Enum.GetValues(typeof(SocialMediaScenarioSMStype))) { var messageFeed = newData.GetSMSMessageFeed(messageFeedType); if (messageFeed == null) { continue; } var name = Enum.GetName(typeof(SocialMediaScenarioSMStype), messageFeedType); AssetDatabase.CreateFolder(newFolder, name); SaveMessageFeed(messageFeed, Path.Combine(newFolder, name), name); } AssetDatabase.CreateAsset(newData, Path.Combine(newFolder, scenarioName + ".asset")); } }