private static GAPlatform GetPlatform()
        {
            GAPlatform result = GAPlatform.None;

            switch (Application.platform)
            {
            case RuntimePlatform.Android:
            {
                result = GAPlatform.Android;
            }
            break;

            case RuntimePlatform.IPhonePlayer:
            {
                result = GAPlatform.iOS;
            }
            break;
            }

            return(result);
        }
Beispiel #2
0
        private static void Initialize()
        {
            if (!Application.isPlaying)
            {
                return;                 // no need to setup anything else if we are in the editor and not playing
            }
                        #if UNITY_EDITOR
            Debug.Log("GameAnalytics running in Unity Editor: event validation disabled.");
                        #endif

            if (SettingsGA.InfoLogBuild)
            {
                GA_Setup.SetInfoLog(true);
            }

            if (SettingsGA.VerboseLogBuild)
            {
                GA_Setup.SetVerboseLog(true);
            }

            GAPlatform platform = GetPlatform();

            GA_Wrapper.SetUnitySdkVersion("unity " + Settings.VERSION);
            GA_Wrapper.SetUnityEngineVersion("unity " + GetUnityVersion());

            if (platform != GAPlatform.None)
            {
                int index = (int)platform;
                GA_Wrapper.SetBuild(SettingsGA.Build[index - 1]);
            }

            if (SettingsGA.CustomDimensions01.Count > 0)
            {
                GA_Setup.SetAvailableCustomDimensions01(SettingsGA.CustomDimensions01);
            }

            if (SettingsGA.CustomDimensions02.Count > 0)
            {
                GA_Setup.SetAvailableCustomDimensions02(SettingsGA.CustomDimensions02);
            }

            if (SettingsGA.CustomDimensions03.Count > 0)
            {
                GA_Setup.SetAvailableCustomDimensions03(SettingsGA.CustomDimensions03);
            }

            if (SettingsGA.ResourceItemTypes.Count > 0)
            {
                GA_Setup.SetAvailableResourceItemTypes(SettingsGA.ResourceItemTypes);
            }

            if (SettingsGA.ResourceCurrencies.Count > 0)
            {
                GA_Setup.SetAvailableResourceCurrencies(SettingsGA.ResourceCurrencies);
            }

            if (platform != GAPlatform.None)
            {
                if (!SettingsGA.UseCustomId)
                {
                    int index = (int)platform;
                    GA_Wrapper.Initialize(SettingsGA.GetGameKey(index - 1), SettingsGA.GetSecretKey(index - 1));
                }
                else
                {
                    Debug.Log("Custom id is enabled. Initialize is delayed until custom id has been set.");
                }
            }
            else
            {
                Debug.LogWarning("Unsupported platform: " + Application.platform);
            }
        }
        private static void Initialize()
        {
            if (!Application.isPlaying)
            {
                return;                 // no need to setup anything else if we are in the editor and not playing
            }
                        #if UNITY_EDITOR
            Debug.Log("GameAnalytics running in Unity Editor: event validation disabled.");
                        #endif

            if (SettingsGA.InfoLogBuild)
            {
                GA_Setup.SetInfoLog(true);
            }

            if (SettingsGA.VerboseLogBuild)
            {
                GA_Setup.SetVerboseLog(true);
            }

#if UNITY_ANDROID && !UNITY_EDITOR
            AndroidJavaClass  jc       = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject activity = jc.GetStatic <AndroidJavaObject>("currentActivity");

            AndroidJavaClass ga = new AndroidJavaClass("com.gameanalytics.sdk.GAPlatform");
            ga.CallStatic("initializeWithActivity", activity);
#endif

            GAPlatform platform = GetPlatform();

            GA_Wrapper.SetUnitySdkVersion("unity " + Settings.VERSION);
            GA_Wrapper.SetUnityEngineVersion("unity " + GetUnityVersion());

            if (platform != GAPlatform.None)
            {
                int index = (int)platform;
                GA_Wrapper.SetBuild(SettingsGA.Build[index - 1]);
            }

            if (SettingsGA.CustomDimensions01.Count > 0)
            {
                GA_Setup.SetAvailableCustomDimensions01(SettingsGA.CustomDimensions01);
            }

            if (SettingsGA.CustomDimensions02.Count > 0)
            {
                GA_Setup.SetAvailableCustomDimensions02(SettingsGA.CustomDimensions02);
            }

            if (SettingsGA.CustomDimensions03.Count > 0)
            {
                GA_Setup.SetAvailableCustomDimensions03(SettingsGA.CustomDimensions03);
            }

            if (SettingsGA.ResourceItemTypes.Count > 0)
            {
                GA_Setup.SetAvailableResourceItemTypes(SettingsGA.ResourceItemTypes);
            }

            if (SettingsGA.ResourceCurrencies.Count > 0)
            {
                GA_Setup.SetAvailableResourceCurrencies(SettingsGA.ResourceCurrencies);
            }

            if (platform != GAPlatform.None)
            {
                int index = (int)platform;
                GA_Wrapper.Initialize(SettingsGA.GetGameKey(index - 1), SettingsGA.GetSecretKey(index - 1));
            }
            else
            {
                Debug.LogWarning("Unsupported platform: " + Application.platform);
            }
        }