Esempio n. 1
0
        static MethodBase TargetMethod(object instance)
        {
#if MANAGED
            return(AccessToolsShim.Method(UnityTypes.TMP_Text?.ClrType, "SetText", new[] { typeof(StringBuilder) }));
#else
            return(AccessToolsShim.Method(UnityTypes.TMP_Text?.ClrType, "SetText", new[] { typeof(Il2CppSystem.Text.StringBuilder) }));
#endif
        }
Esempio n. 2
0
        static MethodBase TargetMethod(object instance)
        {
#if MANAGED
            return(AccessToolsShim.Method(UnityTypes.TMP_Text?.ClrType, "SetCharArray", new[] { typeof(int[]), typeof(int), typeof(int) }));
#else
            return(AccessToolsShim.Method(UnityTypes.TMP_Text?.ClrType, "SetCharArray", new[] { typeof(UnhollowerBaseLib.Il2CppStructArray <int>), typeof(int), typeof(int) }));
#endif
        }
        /// <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);
        }
Esempio n. 4
0
        public static void SetAllDirtyEx(this object ui)
        {
            if (ui == null)
            {
                return;
            }

            var type = ui.GetType();

            if (ClrTypes.Graphic != null && ClrTypes.Graphic.IsAssignableFrom(type))
            {
                ClrTypes.Graphic.CachedMethod(SetAllDirtyMethodName).Invoke(ui);
            }
            else
            {
                AccessToolsShim.Method(type, MarkAsChangedMethodName)?.Invoke(ui, null);
            }
        }
Esempio n. 5
0
        public static void SetAllDirtyEx(this object ui)
        {
            if (ui == null)
            {
                return;
            }

            var type = ui.GetUnityType();

            if (UnityTypes.Graphic != null && UnityTypes.Graphic.IsAssignableFrom(type))
            {
                UnityTypes.Graphic.ClrType.CachedMethod(SetAllDirtyMethodName).Invoke(ui);
            }
            else if (!ui.TryCastTo <SpriteRenderer>(out _))
            {
                var clrType = ui.GetType();
                AccessToolsShim.Method(clrType, MarkAsChangedMethodName)?.Invoke(ui, null);
            }
        }
Esempio n. 6
0
        public static void SetAllDirtyEx(this object ui)
        {
            if (ui == null)
            {
                return;
            }

            if (ui is Graphic graphic)
            {
                graphic.SetAllDirty();
            }
            else
            {
                // lets attempt some reflection for several known types
                var type = ui.GetType();

                AccessToolsShim.Method(type, MarkAsChangedMethodName)?.Invoke(ui, null);
            }
        }
Esempio n. 7
0
        public void ResetScrollIn(object ui)
        {
            if (!_hasCheckedTypeWriter)
            {
                _hasCheckedTypeWriter = true;

                if (UnityTypes.Typewriter != null)
                {
                    var component = ui as Component;
                    if (ui != null && component.GetComponent(UnityTypes.Typewriter.UnityType).TryCastTo <MonoBehaviour>(out var typeWriter))
                    {
                        _typewriter = typeWriter;
                    }
                }
            }

            if (_typewriter != null)
            {
                AccessToolsShim.Method(UnityTypes.Typewriter.ClrType, "OnEnable")?.Invoke(_typewriter, null);
            }
        }
        public void ResetScrollIn(object graphic)
        {
            if (!_hasCheckedTypeWriter)
            {
                _hasCheckedTypeWriter = true;

                if (ClrTypes.Typewriter != null)
                {
                    var ui = graphic as Component;
                    if (ui != null)
                    {
                        _typewriter = (MonoBehaviour)ui.GetComponent(ClrTypes.Typewriter);
                    }
                }
            }

            if (_typewriter != null)
            {
                AccessToolsShim.Method(ClrTypes.Typewriter, "OnEnable")?.Invoke(_typewriter, null);
            }
        }
Esempio n. 9
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(ClrTypes.UILabel, "OnEnable"));
 }
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(typeof(AssetBundle), "LoadFromMemory_Internal", typeof(byte[]), typeof(uint))
            ?? AccessToolsShim.Method(typeof(AssetBundle), "LoadFromMemory", typeof(byte[]), typeof(uint)));
 }
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(typeof(AssetBundle), "mainAsset").GetGetMethod());
 }
Esempio n. 12
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(ClrTypes.GUI, "DoButtonGrid", new[] { typeof(Rect), typeof(int), typeof(GUIContent[]), typeof(string[]), typeof(int), typeof(GUIStyle), typeof(GUIStyle), typeof(GUIStyle), typeof(GUIStyle), ClrTypes.GUI_ToolbarButtonSize, typeof(bool[]) }));
 }
Esempio n. 13
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(ClrTypes.GUI, "DoToggle", new[] { typeof(Rect), typeof(int), typeof(bool), typeof(GUIContent), typeof(GUIStyle) }));
 }
Esempio n. 14
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(ClrTypes.TextMeshProUGUI, "OnEnable"));
 }
        static bool Prepare(object instance)
        {
            var returnMainAsset = AccessToolsShim.Method(typeof(AssetBundle), "returnMainAsset", new[] { typeof(AssetBundle) });

            return(returnMainAsset != null);
        }
Esempio n. 16
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(ClrTypes.TMP_Text, "maxVisibleCharacters")?.GetSetMethod());
 }
Esempio n. 17
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(ClrTypes.TMP_Text, "SetCharArray", new[] { typeof(int[]), typeof(int), typeof(int) }));
 }
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(typeof(AssetBundle), "returnMainAsset", new[] { typeof(AssetBundle) }));
 }
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(typeof(Resources), "LoadAll", typeof(string), typeof(Type)));
 }
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(typeof(AssetBundleRequest), "allAssets").GetGetMethod());
 }
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(typeof(AssetBundle), "LoadAssetWithSubAssetsAsync_Internal", typeof(string), typeof(Type)));
 }
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(typeof(AssetBundle), "LoadAll", typeof(Type)));
 }
Esempio n. 23
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(ClrTypes.TextMeshPro, "text").GetSetMethod());
 }
Esempio n. 24
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(ClrTypes.GUI, "BeginGroup", new[] { typeof(Rect), typeof(GUIContent), typeof(GUIStyle), typeof(Vector2) }));
 }
Esempio n. 25
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(ClrTypes.TMP_Text, "SetText", new[] { typeof(string), typeof(float), typeof(float), typeof(float) }));
 }
Esempio n. 26
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(ClrTypes.GUI, "DoRepeatButton", new[] { typeof(Rect), typeof(GUIContent), typeof(GUIStyle), typeof(FocusType) }));
 }
Esempio n. 27
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(ClrTypes.TextWindow, "SetText", new Type[] { typeof(string) }));
 }
Esempio n. 28
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(ClrTypes.GUI, "DoButton", new[] { typeof(Rect), typeof(GUIContent), typeof(IntPtr) }));
 }
Esempio n. 29
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Property(ClrTypes.TMP_Text, "text")?.GetGetMethod());
 }
Esempio n. 30
0
 static MethodBase TargetMethod(object instance)
 {
     return(AccessToolsShim.Method(ClrTypes.GUI, "DoWindow", new[] { typeof(int), typeof(Rect), typeof(WindowFunction), typeof(GUIContent), typeof(GUIStyle), typeof(GUISkin), typeof(bool) }));
 }