コード例 #1
0
        /// <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);
        }
コード例 #2
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(ClrTypes.TMP_Text, "text")?.GetGetMethod());
 }
コード例 #3
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(ClrTypes.TMP_Text, "maxVisibleCharacters")?.GetSetMethod());
 }
コード例 #4
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(ClrTypes.TextMeshPro, "text").GetSetMethod());
 }
コード例 #5
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(typeof(AssetBundle), "mainAsset").GetGetMethod());
 }
コード例 #6
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(typeof(AssetBundleRequest), "allAssets").GetGetMethod());
 }
コード例 #7
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(typeof(AsyncOperation), "priority").GetSetMethod());
 }
コード例 #8
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(typeof(AsyncOperation), "allowSceneActivation").GetSetMethod());
 }
コード例 #9
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(typeof(GameObject), "active")?.GetSetMethod());
 }
コード例 #10
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(ClrTypes.TextField, "htmlText")?.GetSetMethod());
 }
コード例 #11
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(UnityTypes.UILabel?.ClrType, "text")?.GetSetMethod());
 }
コード例 #12
0
 static bool Prepare(object instance)
 {
     return(AccessToolsShim.Property(typeof(AssetBundleRequest), "allAssets") != null);
 }
コード例 #13
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(ClrTypes.TextArea2D, "TextData")?.GetSetMethod());
 }