Exemple #1
0
        // -------------------------------------------------------------------------------------------------------------------------
        // Unity <> Android Magic


        /// <summary> Generic function to call any function with various inputs / return values. </summary>
        /// <param name="funcName"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        private static bool CallFunctionGet <T>(string funcName, out T res, object[] parameters = null)
        {
            //#if !UNITY_EDITOR && UNITY_ANDROID
            if (SG_IAndroid.instance.senseComClass != null)
            {
                if (parameters == null)
                {
                    parameters = new object[] { };
                }
                try
                {
                    Log("Attempting to call " + funcName);
                    res = instance.senseComClass.CallStatic <T>(funcName, parameters);
                    Log("Done calling " + funcName);
                    return(true);
                }
                catch (System.Exception ex)
                {
                    SG_IAndroid.Log(ex.Message + "\r\n\r\n" + ex.StackTrace);
                }
            }
            //#endif
            res = default(T);
            return(false);
        }
Exemple #2
0
        /// <summary> Links the Android Library to our Unity Process. Only works on Android builds, otherwise it throws an error. Once called, you should call Dispose when your process terminates. </summary>
        /// <returns></returns>
        public static bool SetupLink()
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            if (instance.senseComClass == null)
            {
                try
                {
                    instance.senseComClass = new AndroidJavaClass(clientClassLocation);
                    return(true);
                }
                catch (System.Exception ex)
                {
                    SG_IAndroid.Log(ex.Message + "\r\n\r\n" + ex.StackTrace);
                }
            }
#endif
            return(false);
        }