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 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); }
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 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); }
/** 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 }
// (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 })); }