/// <summary> /// Attempt to translated the provided untranslated text. Will be used in a "coroutine", /// so it can be implemented in an asynchronous fashion. /// </summary> public IEnumerator Translate(ITranslationContext context) { var wwwContext = new WwwTranslationContext(context); // allow implementer of HttpEndpoint to do anything before starting translation var setup = OnBeforeTranslate(wwwContext); if (setup != null) { while (setup.MoveNext()) { yield return(setup.Current); } } // prepare request OnCreateRequest(wwwContext); if (wwwContext.RequestInfo == null) { wwwContext.Fail("No request object was provided by the translator."); } var request = wwwContext.RequestInfo; var url = request.Address; var data = request.Data; var headers = request.Headers; // execute request var www = CreateWww(request.Address, data != null ? Encoding.UTF8.GetBytes(data) : null, headers); // wait for completion yield return(www); // extract error string error = (string)AccessToolsShim.Property(ClrTypes.WWW, "error").GetValue(www, null); if (error != null) { wwwContext.Fail("Error occurred while retrieving translation. " + error); } // extract text var text = (string)AccessToolsShim.Property(ClrTypes.WWW, "text").GetValue(www, null); if (text == null) { wwwContext.Fail("Error occurred while extracting text from response."); } wwwContext.ResponseData = text; // extract text OnExtractTranslation(wwwContext); }
static MethodBase TargetMethod(object instance) { return(AccessToolsShim.Property(ClrTypes.TMP_Text, "text")?.GetGetMethod()); }
static MethodBase TargetMethod(object instance) { return(AccessToolsShim.Property(ClrTypes.TMP_Text, "maxVisibleCharacters")?.GetSetMethod()); }
static MethodBase TargetMethod(object instance) { return(AccessToolsShim.Property(ClrTypes.TextMeshPro, "text").GetSetMethod()); }
static MethodBase TargetMethod(object instance) { return(AccessToolsShim.Property(typeof(AssetBundle), "mainAsset").GetGetMethod()); }
static MethodBase TargetMethod(object instance) { return(AccessToolsShim.Property(typeof(AssetBundleRequest), "allAssets").GetGetMethod()); }
static MethodBase TargetMethod(object instance) { return(AccessToolsShim.Property(typeof(AsyncOperation), "priority").GetSetMethod()); }
static MethodBase TargetMethod(object instance) { return(AccessToolsShim.Property(typeof(AsyncOperation), "allowSceneActivation").GetSetMethod()); }
static MethodBase TargetMethod(object instance) { return(AccessToolsShim.Property(typeof(GameObject), "active")?.GetSetMethod()); }
static MethodBase TargetMethod(object instance) { return(AccessToolsShim.Property(ClrTypes.TextField, "htmlText")?.GetSetMethod()); }
static MethodBase TargetMethod(object instance) { return(AccessToolsShim.Property(UnityTypes.UILabel?.ClrType, "text")?.GetSetMethod()); }
static bool Prepare(object instance) { return(AccessToolsShim.Property(typeof(AssetBundleRequest), "allAssets") != null); }
static MethodBase TargetMethod(object instance) { return(AccessToolsShim.Property(ClrTypes.TextArea2D, "TextData")?.GetSetMethod()); }