示例#1
0
        public static void AnalyticsLogEvent(GameObject gObject, Action eventCategory, string eventAction, long value,
                                             Dictionary <string, object> dataObject, Dictionary <string, string> dataString)
        {
            if (!Application.isEditor)
            {
                // ObjectName:Action
                string subData = SubData(gObject, eventAction);
                // Event:ObjectName:Action:(SceneName)
                string data = FullData(gObject, EnumExtantions.GetDescription(eventCategory), eventAction);
                // Event:ObjectName:Action:(SceneName):value
                // string fullDataWithValue = data + (value > 0 ? ":" + value : "");


                if (value > 0)
                {
                    dataObject.Add("value", value);
                    dataString.Add("value", value.ToString());
                }

                // Google       --- Event, ObjectName:Action, (SceneName), value
                try
                {
                    //GoogleAnalyticsV3.instance.LogEvent(new EventHitBuilder()
                    //                                        .SetEventCategory(eventCategory)
                    //                                        .SetEventAction(subData)
                    //                                        .SetEventLabel(SceneName)
                    //                                        .SetEventValue(value));
                }
                catch (System.Exception e) { AnalyticsError(e); }

                // Game         --- Event:ObjectName:Action:(SceneName), value
                try
                {
                    //if (value > 0) GameAnalytics.NewDesignEvent(data, value);
                    //else GameAnalytics.NewDesignEvent(data);
                }
                catch (System.Exception e) { AnalyticsError(e); }

                // Flurry       --- Event:ObjectName:Action:(SceneName), value
                try
                {
                    //if (dataString.Count > 0) Flurry.Instance.LogEvent(data, dataString);
                    //else Flurry.Instance.LogEvent(data);
                }
                catch (System.Exception e) { AnalyticsError(e); }

                // Amplitude    --- Event:ObjectName:Action:(SceneName), value
                try
                {
                    //if (dataObject.Count > 0) Amplitude.Instance.logEvent(data, dataObject);
                    //else Amplitude.Instance.logEvent(data);
                }
                catch (System.Exception e) { AnalyticsError(e); }

                data    = null;
                subData = null;
            }
        }
        private void ExecuteLoading(BuildingScenes scene, bool showLoading)
        {
            if (onLoading != null)
            {
                onLoading.Invoke();
            }
            DestroyOldData();

            string sceneName;

            if (showLoading)
            {
                GamePackageSettings gamePackageSettings = GamePackageSettings.Load();
                BuildingScenes      loadingScene        = gamePackageSettings.loadingScene;
                sceneName = EnumExtantions.GetDescription(loadingScene);

                gameObject.Log("Creating middle gameObject");
                GameObject middleGameObject = new GameObject("LoadingMiddleObject");
                gameObject.Log("Adding Loading component");
                middleGameObject.AddComponent <Loading>().Scene = scene;
            }
            else
            {
                sceneName = EnumExtantions.GetDescription(scene);
            }

            gameObject.Log("Loading scene:" + sceneName);
#if UNITY_5_3
            if (loadAsync)
            {
                UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(sceneName);
            }
            else
            {
                UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName);
            }
#else
            if (loadAsync)
            {
                Application.LoadLevelAsync(sceneName);
            }
            else
            {
                Application.LoadLevel(sceneName);
            }
#endif
        }