protected override bool ShouldHandleAsset(TextAsset asset, IAssetOrResourceLoadedContext context) { Logger.DebugLogDebug($"{GetType()}.ShouldHandleAsset({asset.name}[{asset.GetType()}])?"); var result = base.ShouldHandleAsset(asset, context) && CanHandleAsset(asset, context); Logger.DebugLogDebug($"{GetType()}.ShouldHandleAsset({asset.name}[{asset.GetType()}]) => {result}"); return(result); }
protected override bool ShouldHandleAsset(TextAsset asset, IAssetOrResourceLoadedContext context) { Logger.DebugLogDebug($"{GetType()}.ShouldHandleAsset({asset.name}[{asset.GetType()}])?"); var result = Enabled && !context.HasReferenceBeenRedirectedBefore(asset) && this.IsPathAllowed(asset, context) && asset.bytes != null; Logger.DebugLogDebug($"{GetType()}.ShouldHandleAsset({asset.name}[{asset.GetType()}]) => {result}"); return(result); }
protected override bool ShouldHandleAsset(TextAsset asset, IAssetOrResourceLoadedContext context) { var result = Enabled && TextAssetMessagePackHelper.CanHandleAsset(asset, context) && !context.HasReferenceBeenRedirectedBefore(asset); Logger.LogDebug($"{GetType()}.ShouldHandleAsset({asset.name}[{asset.GetType()}]) => {result}"); return(result); }
public JSONDatabase(string loadPath) { assetMap = new Dictionary <string, string>(); UnityEngine.Object[] assets = Resources.LoadAll(loadPath); for (int i = 0; i < assets.Length; i++) { TextAsset asset = assets[i] as TextAsset; if (asset.GetType() == typeof(TextAsset)) { Add(asset.name, asset.text); } } }
void ExtractFilesButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { if (modSettings.Length < 1) { return; } Mod mod = ModManager.Instance.GetMod(modSettings[modList.SelectedIndex].modInfo.ModTitle); if (mod == null) { return; } string[] assets = mod.AssetNames; string path = Path.Combine(mod.DirPath, mod.Title + "_ExtractedFiles"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } for (int i = 0; i < assets.Length; i++) { string extension = assets[i].Substring(assets[i].LastIndexOf('.')); if (!ModManager.textExtensions.Contains(extension)) { continue; } TextAsset asset = mod.GetAsset <TextAsset>(assets[i]); if (asset == null) { continue; } File.WriteAllText(Path.Combine(path, asset.name + ".txt"), asset.ToString()); //append .txt at end of asset name so mod info file will never end in .dfmod //which would cause it to be tried to load by mod manager as an asset bundle if in mod directory Debug.Log(string.Format("asset type for asset : {0} {1}", asset.name, asset.GetType().Name)); } var messageBox = new DaggerfallMessageBox(uiManager, this, true); messageBox.AllowCancel = true; messageBox.ClickAnywhereToClose = true; messageBox.ParentPanel.BackgroundTexture = null; messageBox.SetText(string.Format(ModManager.GetText("extractTextConfirmation"), path)); uiManager.PushWindow(messageBox); }
protected override IEnumerator runTest() { string payload = "small_text?dl=res&x=txt"; ContentManifest.AssetEntry entry = ContentManifest.AssetEntry.Parse(payload); DeviceManager deviceManager = new DeviceManager(); ResourceDevice device = new ResourceDevice(deviceManager); deviceManager.Mount(device); TextAsset textAsset = deviceManager.LoadImmediate <TextAsset>(entry.DeviceList, ref entry); IntegrationTestEx.FailIf(textAsset == null); IntegrationTestEx.FailIf(textAsset.GetType() != typeof(TextAsset)); IntegrationTestEx.FailIf(!textAsset.text.StartsWith("hello world")); IntegrationTest.Pass(); yield break; }
void ExtractFilesButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { if (modSettings.Length < 1) { return; } Mod mod = ModManager.Instance.GetMod(modSettings[modList.SelectedIndex].modInfo.ModTitle); if (mod == null) { return; } string[] assets = mod.AssetNames; string path = System.IO.Path.Combine(mod.DirPath, mod.Title + "_ExtractedFiles"); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } for (int i = 0; i < assets.Length; i++) { string extension = assets[i].Substring(assets[i].LastIndexOf('.')); if (!ModManager.textExtensions.Contains(extension)) { continue; } TextAsset asset = mod.GetAsset <TextAsset>(assets[i]); if (asset == null) { continue; } System.IO.File.WriteAllText(System.IO.Path.Combine(path, asset.name + ".txt"), asset.ToString()); //append .txt at end of asset name so mod info file will never end in .dfmod //which would cause it to be tried to load by mod manager as an asset bundle if in mod directory Debug.Log(string.Format("asset type for asset : {0} {1}", asset.name, asset.GetType().Name)); } }