static StackObject *Call_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Object[] @args = (System.Object[]) typeof(System.Object[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.String @methodName = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); UnityEngine.AndroidJavaObject instance_of_this_method = (UnityEngine.AndroidJavaObject) typeof(UnityEngine.AndroidJavaObject).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.Call <UnityEngine.AndroidJavaObject>(@methodName, @args); object obj_result_of_this_method = result_of_this_method; if (obj_result_of_this_method is CrossBindingAdaptorType) { return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance)); } return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
/** 削除。 */ public void Delete() { Tool.Log("SoundPool", "Delete"); //アンロード。 { System.Collections.Generic.Dictionary <string, Item> .KeyCollection t_collection = this.list.Keys; string[] t_keylist = new string[t_collection.Count]; t_collection.CopyTo(t_keylist, 0); for (int ii = 0; ii < t_keylist.Length; ii++) { this.UnLoad(t_keylist[ii], true); } } //サウンドプールインスタンス。解放。 #if (UNITY_ANDROID) try{ if (this.java_soundpool != null) { this.java_soundpool.Call("release"); this.java_soundpool.Dispose(); this.java_soundpool = null; } }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } #endif }
/** Awake */ public void Awake() { //openfiledialog_result this.openfiledialog_result = ""; //loadandroidcontentfile #if (UNITY_ANDROID) this.loadandroidcontentfile = null; #endif }
/// <summary> /// Static Constructor to setup opencv environment /// </summary> static CvInvoke() { List <String> modules = CvInvoke.OpenCVModuleList; modules.RemoveAll(String.IsNullOrEmpty); _libraryLoaded = true; #if ANDROID || (UNITY_ANDROID && !UNITY_EDITOR) System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); FileInfo file = new FileInfo(asm.Location); DirectoryInfo directory = file.Directory; #if (UNITY_ANDROID && !UNITY_EDITOR) UnityEngine.AndroidJavaObject jo = new UnityEngine.AndroidJavaObject("java.lang.System"); #endif foreach (String module in modules) { //IntPtr handle = Emgu.Util.Toolbox.LoadLibrary(module); //Debug.WriteLine(string.Format(handle == IntPtr.Zero ? "Failed to load {0}." : "Loaded {0}.", module)); try { Console.WriteLine(string.Format("Trying to load {0}.", module)); #if ANDROID Java.Lang.JavaSystem.LoadLibrary(module); #else //(UNITY_ANDROID && !UNITY_EDITOR) jo.CallStatic("loadLibrary", module); #endif Console.WriteLine(string.Format("Loaded {0}.", module)); } catch (Exception e) { _libraryLoaded = false; Console.WriteLine(String.Format("Failed to load {0}: {1}", module, e.Message)); } } #elif IOS || UNITY_IPHONE || NETFX_CORE #else if (Emgu.Util.Platform.OperationSystem != Emgu.Util.TypeEnum.OS.MacOSX) { String formatString = GetModuleFormatString(); for (int i = 0; i < modules.Count; ++i) { modules[i] = String.Format(formatString, modules[i]); } _libraryLoaded &= LoadUnmanagedModules(null, modules.ToArray()); } #endif #if !UNITY_IPHONE //Use the custom error handler RedirectError(CvErrorHandlerThrowException, IntPtr.Zero, IntPtr.Zero); #endif }
/// <summary> /// Attempts to load tensorflow modules from the specific location /// </summary> /// <param name="modules">The names of tensorflow modules.</param> /// <returns>True if all the modules has been loaded successfully</returns> public static bool DefaultLoadUnmanagedModules(String[] modules) { bool libraryLoaded = true; #if __ANDROID__ foreach (String module in modules) { try { Console.WriteLine(string.Format("Trying to load {0} ({1} bit).", module, Marshal.SizeOf <IntPtr>() * 8)); Java.Lang.JavaSystem.LoadLibrary(module); Console.WriteLine(string.Format("Loaded {0}.", module)); } catch (Exception e) { libraryLoaded = false; Console.WriteLine(String.Format("Failed to load {0}: {1}", module, e.Message)); } } #elif (UNITY_ANDROID && !UNITY_EDITOR) UnityEngine.AndroidJavaObject jo = new UnityEngine.AndroidJavaObject("java.lang.System"); foreach (String module in modules) { try { Console.WriteLine(string.Format("Trying to load {0} ({1} bit).", module, Marshal.SizeOf <IntPtr>() * 8)); jo.CallStatic("loadLibrary", module); Console.WriteLine(string.Format("Loaded {0}.", module)); } catch (Exception e) { libraryLoaded = false; Console.WriteLine(String.Format("Failed to load {0}: {1}", module, e.Message)); } } #elif __IOS__ || UNITY_IOS || NETFX_CORE #else #if !(UNITY_EDITOR || UNITY_STANDALONE || UNITY_ANDROID) if (!System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX)) #endif { String formatString = GetModuleFormatString(); for (int i = 0; i < modules.Length; ++i) { modules[i] = String.Format(formatString, modules[i]); } libraryLoaded &= LoadUnmanagedModules(null, modules); } #endif return(libraryLoaded); }
public static void StartNsd() { #if __UNITY_ANDROID__ UnityEngine.AndroidJavaClass c = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer"); var context = c.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity"); var arg = new UnityEngine.AndroidJavaObject("java.lang.String", "servicediscovery"); context.Call <UnityEngine.AndroidJavaObject>("getSystemService", arg); context.Dispose(); arg.Dispose(); c.Dispose(); #endif }
/// <summary> /// Attempts to load opencv modules from the specific location /// </summary> /// <param name="modules">The names of opencv modules. e.g. "opencv_cxcore.dll" on windows.</param> /// <returns>True if all the modules has been loaded successfully</returns> public static bool DefaultLoadUnmanagedModules(String[] modules) { bool libraryLoaded = true; #if __ANDROID__ foreach (String module in modules) { try { Console.WriteLine(string.Format("Trying to load {0}.", module)); Java.Lang.JavaSystem.LoadLibrary(module); Console.WriteLine(string.Format("Loaded {0}.", module)); } catch (Exception e) { libraryLoaded = false; Console.WriteLine(String.Format("Failed to load {0}: {1}", module, e.Message)); } } #elif (UNITY_ANDROID && !UNITY_EDITOR) UnityEngine.AndroidJavaObject jo = new UnityEngine.AndroidJavaObject("java.lang.System"); foreach (String module in modules) { try { Console.WriteLine(string.Format("Trying to load {0}.", module)); jo.CallStatic("loadLibrary", module); Console.WriteLine(string.Format("Loaded {0}.", module)); } catch (Exception e) { libraryLoaded = false; Console.WriteLine(String.Format("Failed to load {0}: {1}", module, e.Message)); } } #elif __IOS__ || UNITY_IOS || NETFX_CORE #else if (Emgu.Util.Platform.OperationSystem != Emgu.Util.TypeEnum.OS.MacOS) { String formatString = GetModuleFormatString(); for (int i = 0; i < modules.Length; ++i) { modules[i] = String.Format(formatString, modules[i]); } libraryLoaded &= LoadUnmanagedModules(null, modules); } #endif return(libraryLoaded); }
static RegisterService() { UnityEngine.AndroidJavaClass c = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer"); var context = c.GetStatic<UnityEngine.AndroidJavaObject>("currentActivity"); if (context == null) { c.Dispose(); throw new Exception("Failed to get context"); } var arg = new UnityEngine.AndroidJavaObject("java.lang.String", "servicediscovery"); context.Call<UnityEngine.AndroidJavaObject>("getSystemService", arg); context.Dispose(); arg.Dispose(); c.Dispose(); }
/// <summary> /// Attempts to load opencv modules from the specific location /// </summary> /// <param name="modules">The names of opencv modules. e.g. "opencv_cxcore.dll" on windows.</param> /// <returns>True if all the modules has been loaded successfully</returns> public static bool DefaultLoadUnmanagedModules(String[] modules) { bool libraryLoaded = true; #if __ANDROID__ || (UNITY_ANDROID && !UNITY_EDITOR) System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); FileInfo file = new FileInfo(asm.Location); DirectoryInfo directory = file.Directory; #if (UNITY_ANDROID && !UNITY_EDITOR) UnityEngine.AndroidJavaObject jo = new UnityEngine.AndroidJavaObject("java.lang.System"); #endif foreach (String module in modules) { //IntPtr handle = Emgu.Util.Toolbox.LoadLibrary(module); //Debug.WriteLine(string.Format(handle == IntPtr.Zero ? "Failed to load {0}." : "Loaded {0}.", module)); try { Console.WriteLine(string.Format("Trying to load {0}.", module)); #if __ANDROID__ Java.Lang.JavaSystem.LoadLibrary(module); #else //(UNITY_ANDROID && !UNITY_EDITOR) jo.CallStatic("loadLibrary", module); #endif Console.WriteLine(string.Format("Loaded {0}.", module)); } catch (Exception e) { libraryLoaded = false; Console.WriteLine(String.Format("Failed to load {0}: {1}", module, e.Message)); } } #elif __IOS__ || UNITY_IOS || NETFX_CORE #else if (Emgu.Util.Platform.OperationSystem != Emgu.Util.TypeEnum.OS.MacOSX) { String formatString = GetModuleFormatString(); for (int i = 0; i < modules.Length; ++i) { modules[i] = String.Format(formatString, modules[i]); } libraryLoaded &= LoadUnmanagedModules(null, modules); } #endif return(libraryLoaded); }
public string FindDeviceCultureName() { string result = System.Globalization.CultureInfo.CurrentCulture.Name; #if UNITY_EDITOR #elif UNITY_ANDROID using (UnityEngine.AndroidJavaClass cls = new UnityEngine.AndroidJavaClass("java.util.Locale")) { using (UnityEngine.AndroidJavaObject locale = cls.CallStatic <UnityEngine.AndroidJavaObject>("getDefault")) { result = locale.Call <string>("getLanguage") + "-" + locale.Call <string>("getCountry"); } } #elif UNITY_IOS #else #endif return(result); }
static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Object[] args = (System.Object[]) typeof(System.Object[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.String className = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = new UnityEngine.AndroidJavaObject(className, args); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
/// <summary> /// 连接华为推送并获取token,必须集成华为推送SDK /// </summary> public static void InitHuaweiPush() { using (var actClass = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer")) { UnityEngine.AndroidJavaObject curActivityContext = actClass.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity"); if (curActivityContext != null) { UnityEngine.AndroidJavaClass clsSystemUtil = new UnityEngine.AndroidJavaClass("com.netease.hwpushwrapper.HWPush"); if (clsSystemUtil != null) { clsSystemUtil.CallStatic("initHuaweiPush", curActivityContext); UnityEngine.Debug.Log("call java method initHuaweiPush"); } else { UnityEngine.Debug.Log("can't find class com.netease.hwpushwrapper.HWPush"); } } } }
public static string GetAndroidExternalFilesDir() { using (UnityEngine.AndroidJavaClass unityPlayer = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer")) { using (UnityEngine.AndroidJavaObject context = unityPlayer.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity")) { // Get all available external file directories (emulated and sdCards) UnityEngine.AndroidJavaObject[] externalFilesDirectories = context.Call <UnityEngine.AndroidJavaObject[]>("getExternalFilesDirs", (object)null); UnityEngine.AndroidJavaObject emulated = null; UnityEngine.AndroidJavaObject sdCard = null; for (int i = 0; i < externalFilesDirectories.Length; i++) { UnityEngine.AndroidJavaObject directory = externalFilesDirectories[i]; using (UnityEngine.AndroidJavaClass environment = new UnityEngine.AndroidJavaClass("android.os.Environment")) { // Check which one is the emulated and which the sdCard. bool isRemovable = environment.CallStatic <bool>("isExternalStorageRemovable", directory); bool isEmulated = environment.CallStatic <bool>("isExternalStorageEmulated", directory); if (isEmulated) { emulated = directory; } else if (isRemovable && isEmulated == false) { sdCard = directory; } } } // Return the sdCard if available if (sdCard != null) { return(sdCard.Call <string>("getAbsolutePath")); } else { return(emulated.Call <string>("getAbsolutePath")); } } } }
static RegisterService() { Couchbase.Lite.Unity.UnityMainThreadScheduler.TaskFactory.StartNew(() => { UnityEngine.AndroidJavaClass c = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer"); var context = c.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity"); if (context == null) { c.Dispose(); throw new Exception("Failed to get context"); } var arg = new UnityEngine.AndroidJavaObject("java.lang.String", "servicediscovery"); context.Call <UnityEngine.AndroidJavaObject>("getSystemService", arg); context.Dispose(); arg.Dispose(); c.Dispose(); _primedEvent.Set(); }); }
static StackObject *Call_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 3); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Object[] @args = (System.Object[]) typeof(System.Object[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.String @methodName = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 3); UnityEngine.AndroidJavaObject instance_of_this_method = (UnityEngine.AndroidJavaObject) typeof(UnityEngine.AndroidJavaObject).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.Call(@methodName, @args); return(__ret); }
private static void InitSystemUtil() { #if UNITY_ANDROID try { /* The Mono garbage collector should release all created instances of AndroidJavaObject and AndroidJavaClass after use, * but it is advisable to keep them in a using(){} statement to ensure they are deleted as soon as possible. * Without this, you cannot be sure when they will be destroyed. */ using (var actClass = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer")) { UnityEngine.AndroidJavaObject curActivityContext = actClass.GetStatic <UnityEngine.AndroidJavaObject>("currentActivity"); if (curActivityContext != null) { UnityEngine.AndroidJavaClass clsSystemUtil = new UnityEngine.AndroidJavaClass("com.netease.nimlib.NIMSDK"); if (clsSystemUtil != null) { NimUtility.Log.Info("com.netease.nimlib.NIMSDK found"); Boolean init = clsSystemUtil.CallStatic <Boolean>("init", curActivityContext, "fjni_wrapper"); NimUtility.Log.Info("init:" + init); //string androidId = clsSystemUtil.CallStatic<String>("getAndroidId"); //NimUtility.Log.Info("androidId:" + androidId); } } } } catch (System.Exception e) { System.Console.Write("initAndroidExceptionHandler failed, an unexpected error: " + e.ToString()); } #endif #if UNITY_IPHONE || UNITY_IOS if (UnityEngine.Application.platform == UnityEngine.RuntimePlatform.IPhonePlayer) { //TODO: } #endif }
/** 開始。 */ public static bool Start(Root_MonoBehaviour a_root_monobehaviour, Fee.File.Path a_path) { if (a_root_monobehaviour.loadandroidcontentfile == null) { UnityEngine.AndroidJavaObject t_async_object = null; try{ using (UnityEngine.AndroidJavaClass t_class_loadcontentfile = new UnityEngine.AndroidJavaClass("fee.platform.Android_LoadAndroidContentFile_AsyncObject")){ t_async_object = t_class_loadcontentfile.CallStatic <UnityEngine.AndroidJavaObject>("Start", a_path.GetPath()); } }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } if (t_async_object != null) { a_root_monobehaviour.loadandroidcontentfile = t_async_object; return(true); } } return(false); }
/** GetResult。 */ public static byte[] GetResult(Root_MonoBehaviour a_root_monobehaviour) { byte[] t_ret = null; if (a_root_monobehaviour.loadandroidcontentfile != null) { try{ using (UnityEngine.AndroidJavaClass t_class_loadcontentfile = new UnityEngine.AndroidJavaClass("fee.platform.Android_LoadAndroidContentFile_AsyncObject")){ using (UnityEngine.AndroidJavaObject t_array_object = t_class_loadcontentfile.CallStatic <UnityEngine.AndroidJavaObject>("GetResult", a_root_monobehaviour.loadandroidcontentfile)){ if (t_array_object != null) { System.IntPtr t_array_object_pointer = t_array_object.GetRawObject(); t_ret = UnityEngine.AndroidJNIHelper.ConvertFromJNIArray <byte[]>(t_array_object_pointer); } } } }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); t_ret = null; } } return(t_ret); }
/// <summary> /// Attempts to load opencv modules from the specific location /// </summary> /// <param name="modules">The names of opencv modules. e.g. "opencv_cxcore.dll" on windows.</param> /// <returns>True if all the modules has been loaded successfully</returns> public static bool DefaultLoadUnmanagedModules(String[] modules) { bool libraryLoaded = true; #if __ANDROID__ || (UNITY_ANDROID && !UNITY_EDITOR) System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); FileInfo file = new FileInfo(asm.Location); DirectoryInfo directory = file.Directory; #if (UNITY_ANDROID && !UNITY_EDITOR) UnityEngine.AndroidJavaObject jo = new UnityEngine.AndroidJavaObject("java.lang.System"); #endif foreach (String module in modules) { //IntPtr handle = Emgu.Util.Toolbox.LoadLibrary(module); //Debug.WriteLine(string.Format(handle == IntPtr.Zero ? "Failed to load {0}." : "Loaded {0}.", module)); try { Console.WriteLine(string.Format("Trying to load {0}.", module)); #if __ANDROID__ Java.Lang.JavaSystem.LoadLibrary(module); #else //(UNITY_ANDROID && !UNITY_EDITOR) jo.CallStatic("loadLibrary", module); #endif Console.WriteLine(string.Format("Loaded {0}.", module)); } catch (Exception e) { libraryLoaded = false; Console.WriteLine(String.Format("Failed to load {0}: {1}", module, e.Message)); } } #elif IOS || UNITY_IPHONE || NETFX_CORE #else if (Emgu.Util.Platform.OperationSystem != Emgu.Util.TypeEnum.OS.MacOSX) { String formatString = GetModuleFormatString(); for (int i = 0; i < modules.Length; ++i) modules[i] = String.Format(formatString, modules[i]); libraryLoaded &= LoadUnmanagedModules(null, modules); } #endif return libraryLoaded; }
public bool equals(UnityEngine.AndroidJavaObject o) { return(Equals(o)); }
private void onConsentFormClosed(UnityEngine.AndroidJavaObject joConsent) { var consent = new Consent(new AndroidConsent(joConsent)); listener.onConsentFormClosed(consent); }
private void onConsentFormError(UnityEngine.AndroidJavaObject exception) { var consentManagerException = new ConsentManagerException(new AndroidConsentManagerException(exception)); listener.onConsentFormError(consentManagerException); }
/// <summary> /// Attempts to load tensorflow modules from the specific location /// </summary> /// <param name="modules">The names of tensorflow modules.</param> /// <returns>True if all the modules has been loaded successfully</returns> public static bool DefaultLoadUnmanagedModules(String[] modules) { bool libraryLoaded = true; System.Reflection.Assembly monoAndroidAssembly = Emgu.TF.Util.Toolbox.FindAssembly("Mono.Android.dll"); if (monoAndroidAssembly != null) { //Running on Android Type javaSystemType = monoAndroidAssembly.GetType("Java.Lang.JavaSystem"); if (javaSystemType != null) { System.Reflection.MethodInfo loadLibraryMethodInfo = javaSystemType.GetMethod("LoadLibrary"); if (loadLibraryMethodInfo != null) { foreach (String module in modules) { try { Trace.WriteLine(string.Format("Trying to load {0} ({1} bit).", module, IntPtr.Size * 8)); loadLibraryMethodInfo.Invoke(null, new object[] { module }); //Java.Lang.JavaSystem.LoadLibrary(module); Trace.WriteLine(string.Format("Loaded {0}.", module)); } catch (Exception e) { libraryLoaded = false; Trace.WriteLine(String.Format("Failed to load {0}: {1}", module, e.Message)); } } return(libraryLoaded); } } } #if (UNITY_ANDROID && !UNITY_EDITOR) UnityEngine.AndroidJavaObject jo = new UnityEngine.AndroidJavaObject("java.lang.System"); foreach (String module in modules) { try { Trace.WriteLine(string.Format("Trying to load {0} ({1} bit).", module, Marshal.SizeOf <IntPtr>() * 8)); jo.CallStatic("loadLibrary", module); Trace.WriteLine(string.Format("Loaded {0}.", module)); } catch (Exception e) { libraryLoaded = false; Trace.WriteLine(String.Format("Failed to load {0}: {1}", module, e.Message)); } } #elif __IOS__ || UNITY_IOS || NETFX_CORE #else #if !(UNITY_EDITOR || UNITY_STANDALONE || UNITY_ANDROID) if (!System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices .OSPlatform.OSX)) #endif { String formatString = GetModuleFormatString(); for (int i = 0; i < modules.Length; ++i) { modules[i] = String.Format(formatString, modules[i]); } libraryLoaded &= LoadUnmanagedModules(null, modules); } #endif return(libraryLoaded); }
// (ILjava/lang/String;Ljava/util/List;)Ljava/lang/String; public string simpleArgsMethod(int param0, string param1, UnityEngine.AndroidJavaObject param2) { return(_javaObject.Call <string>("simpleArgsMethod", new object[] { param0, param1, param2 })); }
/// <summary> /// Static Constructor to setup opencv environment /// </summary> static CvInvoke() { List<String> modules = CvInvoke.OpenCVModuleList; modules.RemoveAll(String.IsNullOrEmpty); _libraryLoaded = true; #if ANDROID || (UNITY_ANDROID && !UNITY_EDITOR) System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly(); FileInfo file = new FileInfo(asm.Location); DirectoryInfo directory = file.Directory; #if (UNITY_ANDROID && !UNITY_EDITOR) UnityEngine.AndroidJavaObject jo = new UnityEngine.AndroidJavaObject("java.lang.System"); #endif foreach (String module in modules) { //IntPtr handle = Emgu.Util.Toolbox.LoadLibrary(module); //Debug.WriteLine(string.Format(handle == IntPtr.Zero ? "Failed to load {0}." : "Loaded {0}.", module)); try { Console.WriteLine(string.Format("Trying to load {0}.", module)); #if ANDROID Java.Lang.JavaSystem.LoadLibrary(module); #else //(UNITY_ANDROID && !UNITY_EDITOR) jo.CallStatic("loadLibrary", module); #endif Console.WriteLine(string.Format("Loaded {0}.", module)); } catch (Exception e) { _libraryLoaded = false; Console.WriteLine(String.Format("Failed to load {0}: {1}", module, e.Message)); } } #elif IOS || UNITY_IPHONE || NETFX_CORE #else if (Emgu.Util.Platform.OperationSystem != Emgu.Util.TypeEnum.OS.MacOSX) { String formatString = GetModuleFormatString(); for (int i = 0; i < modules.Count; ++i) modules[i] = String.Format(formatString, modules[i]); _libraryLoaded &= LoadUnmanagedModules(null, modules.ToArray()); } #endif #if !UNITY_IPHONE //Use the custom error handler RedirectError(CvErrorHandlerThrowException, IntPtr.Zero, IntPtr.Zero); #endif }
private void onRewardedVideoFinished(double amount, UnityEngine.AndroidJavaObject name) { listener.onRewardedVideoFinished(amount, null); }
static ServiceBrowser() { Couchbase.Lite.Unity.UnityMainThreadScheduler.TaskFactory.StartNew(() => { UnityEngine.AndroidJavaClass c = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer"); var context = c.GetStatic<UnityEngine.AndroidJavaObject>("currentActivity"); if (context == null) { c.Dispose(); throw new Exception("Failed to get context"); } var arg = new UnityEngine.AndroidJavaObject("java.lang.String", "servicediscovery"); context.Call<UnityEngine.AndroidJavaObject>("getSystemService", arg); context.Dispose(); arg.Dispose(); c.Dispose(); _primedEvent.Set(); }); }
private void onConsentInfoUpdated(UnityEngine.AndroidJavaObject joConsent) { listener.onConsentInfoUpdated(new Consent(new AndroidConsent(joConsent))); }
/** constructor */ public SoundPool() { //list this.list = new System.Collections.Generic.Dictionary <string, Item>(); //サウンドプールインスタンス。作成。 #if (UNITY_ANDROID) { this.java_soundpool = null; //読み込み最大数。 int t_max_stream = 64; #if (true) { //UsageType int t_usage_type = (int)UsageType.USAGE_GAME; //ContentType int t_content_type = (int)ContentType.CONTENT_TYPE_MUSIC; try{ UnityEngine.AndroidJavaObject t_attribute = null; { using (UnityEngine.AndroidJavaObject t_jave_attribute_builder = new UnityEngine.AndroidJavaObject("android.media.AudioAttributes$Builder")){ if (t_jave_attribute_builder != null) { t_jave_attribute_builder.Call <UnityEngine.AndroidJavaObject>("setUsage", t_usage_type); t_jave_attribute_builder.Call <UnityEngine.AndroidJavaObject>("setContentType", t_content_type); t_attribute = t_jave_attribute_builder.Call <UnityEngine.AndroidJavaObject>("build"); t_jave_attribute_builder.Dispose(); } else { Tool.Log("SoundPool", "android.media.AudioAttributes$Builder == null"); } } } if (t_attribute != null) { using (UnityEngine.AndroidJavaObject t_java_soundpool_builder = new UnityEngine.AndroidJavaObject("android.media.SoundPool$Builder")){ if (t_java_soundpool_builder != null) { t_java_soundpool_builder.Call <UnityEngine.AndroidJavaObject>("setAudioAttributes", t_attribute); t_java_soundpool_builder.Call <UnityEngine.AndroidJavaObject>("setMaxStreams", t_max_stream); this.java_soundpool = t_java_soundpool_builder.Call <UnityEngine.AndroidJavaObject>("build"); } else { Tool.Log("SoundPool", "android.media.SoundPool$Builder == null"); } } } else { Tool.Log("SoundPool", "android.media.AudioAttributes == null"); } }catch (System.Exception t_exception) { Tool.DebugReThrow(t_exception); } if (this.java_soundpool == null) { Tool.Log("SoundPool", "android.media.SoundPool == null"); } } #else { //ストリームタイプ。 int t_stream_type = (int)StreamType.STREAM_MUSIC; //0固定。 int t_src_quality = (int)SoundPoolConvertQuality.RESERVATION; this.java_soundpool = new AndroidJavaObject("android.media.SoundPool", t_max_stream, t_stream_type, t_src_quality); } #endif } #endif }
private void onFailedToUpdateConsentInfo(UnityEngine.AndroidJavaObject error) { listener.onFailedToUpdateConsentInfo(new ConsentManagerException(new AndroidConsentManagerException(error))); }
/// <summary> /// Attempts to load opencv modules from the specific location /// </summary> /// <param name="modules">The names of opencv modules. e.g. "opencv_core.dll" on windows.</param> /// <returns>True if all the modules has been loaded successfully</returns> public static bool DefaultLoadUnmanagedModules(String[] modules) { bool libraryLoaded = true; #if (UNITY_ANDROID && !UNITY_EDITOR) UnityEngine.AndroidJavaObject jo = new UnityEngine.AndroidJavaObject("java.lang.System"); foreach (String module in modules) { try { Console.WriteLine(string.Format("Trying to load {0}.", module)); jo.CallStatic("loadLibrary", module); Console.WriteLine(string.Format("Loaded {0}.", module)); } catch (Exception e) { libraryLoaded = false; Console.WriteLine(String.Format("Failed to load {0}: {1}", module, e.Message)); } } #elif UNITY_IOS #else if (Emgu.Util.Platform.OperationSystem == Platform.OS.IOS) { return(libraryLoaded); } else if (Emgu.Util.Platform.OperationSystem == Platform.OS.Android) { System.Reflection.Assembly monoAndroidAssembly = Emgu.Util.Toolbox.FindAssembly("Mono.Android.dll"); //Running on Xamarin Android Type javaSystemType = monoAndroidAssembly.GetType("Java.Lang.JavaSystem"); if (javaSystemType != null) { System.Reflection.MethodInfo loadLibraryMethodInfo = javaSystemType.GetMethod("LoadLibrary"); if (loadLibraryMethodInfo != null) { foreach (String module in modules) { if (module.StartsWith("opencv_videoio_ffmpeg")) { continue; //skip the ffmpeg modules. } try { System.Diagnostics.Trace.WriteLine(string.Format("Trying to load {0} ({1} bit).", module, IntPtr.Size * 8)); loadLibraryMethodInfo.Invoke(null, new object[] { module }); //Java.Lang.JavaSystem.LoadLibrary(module); System.Diagnostics.Trace.WriteLine(string.Format("Loaded {0}.", module)); } catch (Exception e) { libraryLoaded = false; System.Diagnostics.Trace.WriteLine(String.Format("Failed to load {0}: {1}", module, e.Message)); } } return(libraryLoaded); } } } else if (Emgu.Util.Platform.OperationSystem != Emgu.Util.Platform.OS.MacOS) { String formatString = GetModuleFormatString(); for (int i = 0; i < modules.Length; ++i) { modules[i] = String.Format(formatString, modules[i]); } libraryLoaded &= LoadUnmanagedModules(null, modules); } #endif return(libraryLoaded); }
public SimpleClass() { _javaObject = new UnityEngine.AndroidJavaObject("unity_aanp.testjar.SimpleClass"); }