changeScreen() public static method

public static changeScreen ( string newScreenName ) : void
newScreenName string
return void
コード例 #1
0
    void OnGUI()
    {
        if (Analytics.Instance == null)
        {
            GUILayout.BeginVertical();
            GUILayout.Label(" ERROR! No Analytics object in scene!");
            GUILayout.Label(" Add Analytics script to an active game object.");
            GUILayout.EndVertical();
            return;
        }

        GUILayout.BeginHorizontal();
        GUILayout.Label("v");
        GUILayout.Label(Analytics.Instance.appVersion);

        GUILayout.BeginVertical();
        GUILayout.Label("- Google Universal Analytics for Unity");
        GUILayout.Label(" Current scene: " + Application.loadedLevelName);

        // Possibility to switch between scenes demonstrates the
        // automatic screen events sent by Analytics.OnLevelWasLoaded().
        //
        // For this test you need to add both AnalyticsExample and
        // AnalyticsExampleSecondaryScene scenes to the project
        // using File->Build Settings.
        //
        if (GUILayout.Button("Go to Secondary Scene (Opt-out menu)"))
        {
            Application.LoadLevel("AnalyticsExampleSecondaryScene");
        }

        GUILayout.Label("Imaginary hits to switch menu screens:");
        if (GUILayout.Button("Send \"Menuscreen A\" Hit"))
        {
            Analytics.changeScreen("AnalyticsExample - Menuscreen A");
        }
        if (GUILayout.Button("Send \"Menuscreen B\" Hit"))
        {
            Analytics.changeScreen("AnalyticsExample - Menuscreen B");
        }


        GUILayout.Label("Web Links:");
        // This is just an inspirational example. In reality you should
        // integrate official social SDKs and probably send the "Like"
        // type of analytics hit only when user actually does that
        // inside your application.
        if (GUILayout.Button("Strobotnik in Google+"))
        {
            Analytics.gua.sendSocialHit("GooglePlus", "plus", "StrobotnikGooglePlus");
            Application.OpenURL("http://plus.google.com/101873213646861422131");
        }
        if (GUILayout.Button("Strobotnik in Facebook"))
        {
            Analytics.gua.sendSocialHit("Facebook", "like", "StrobotnikFacebook");
            Application.OpenURL("http://facebook.com/strobotnik");
        }
        if (GUILayout.Button("Strobotnik in Twitter"))
        {
            Analytics.gua.sendSocialHit("Twitter", "follow", "StrobotnikTwitter");
            Application.OpenURL("http://twitter.com/strobotnik");
        }
        if (GUILayout.Button("Strobotnik Web Site"))
        {
            Analytics.gua.sendEventHit("OpenWebsite", "Strobotnik.com");
            Application.OpenURL("http://strobotnik.com");
        }

        GUILayout.Label("---");

        if (GUILayout.Button("Quit"))
        {
            // End session with custom built hit:
            if (!Analytics.gua.analyticsDisabled)
            {
                Analytics.gua.beginHit(GoogleUniversalAnalytics.HitType.Appview);
                Analytics.gua.addContentDescription("AnalyticsExample - Quit");
                Analytics.gua.addSessionControl(false); // end current session
                Analytics.gua.sendHit();
            }
            #if UNITY_3_5
            gameObject.active = false;
            #else
            gameObject.SetActive(false);
            #endif
            Application.Quit();
        }

        string networkReachability = "Network Reachability: none";
        if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
        {
            networkReachability = "Network Reachability: via carrier data network";
        }
        else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
        {
            networkReachability = "Network Reachability: via local area network";
        }
        GUILayout.Label(networkReachability);

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
    }
コード例 #2
0
    void OnGUI()
    {
        if (Analytics.Instance == null)
        {
            GUILayout.BeginVertical();
            GUILayout.Label(" ERROR! No Analytics object in scene!");
            GUILayout.Label(" Add Analytics script to an active game object.");
            GUILayout.EndVertical();
            return;
        }

        GUILayout.BeginHorizontal();
        GUILayout.Label("v");
        GUILayout.Label(Analytics.Instance.appVersion);

        GUILayout.BeginVertical();
        GUILayout.Label("- Google Universal Analytics for Unity");
        GUILayout.Label(" Current scene: " + Analytics.getActiveSceneName() + "\n");

        // Possibility to switch between scenes demonstrates the
        // automatic screen events sent by Analytics.OnLevelWasLoaded().
        //
        // For this test you need to add both AnalyticsExample and
        // AnalyticsExampleSecondaryScene scenes to the project
        // using File->Build Settings.
        //
        GUILayout.Label("Scene switch sends automatic screen view events:");
        if (GUILayout.Button("Go to Secondary Scene\n(Social, error, exception hit examples)"))
        {
#if UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
            Application.LoadLevel("AnalyticsExampleSecondaryScene");
#else
            UnityEngine.SceneManagement.SceneManager.LoadScene("AnalyticsExampleSecondaryScene");
#endif
        }

        GUILayout.Label("Buttons to send imaginary screen switch events:");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("\"Menuscreen A\""))
        {
            Analytics.changeScreen("AnalyticsExample - Menuscreen A");
        }
        if (GUILayout.Button("\"Menuscreen B\""))
        {
            Analytics.changeScreen("AnalyticsExample - Menuscreen B");
        }
        GUILayout.EndHorizontal();

        GUILayout.Label(" ");
        GUILayout.Label("--- Example for User Consent: ---");

        // Apps should have user consent for collecting and sending analytics data.
        // See https://www.google.com/about/company/user-consent-policy.html
        GUILayout.Label(" This app sends anonymous usage statistics over internet.");
        bool disableAnalyticsByUserOptOut = Analytics.gua.analyticsDisabled;
        bool newValue = GUILayout.Toggle(disableAnalyticsByUserOptOut, "Opt-out from anonymous statistics.");
        if (disableAnalyticsByUserOptOut != newValue)
        {
            Analytics.setPlayerPref_disableAnalyticsByUserOptOut(newValue);
        }

        GUILayout.Label(disableAnalyticsByUserOptOut ? "  :-(" : " ");

        GUILayout.Label("---");

        GUILayout.Label("Remaining entries in offline hit cache:");
        #if UNITY_WEBPLAYER || UNITY_WEBGL
        GUILayout.Label("(not applicable with web builds)");
        #else
        if (Analytics.gua != null)
        {
            GUILayout.Label(Analytics.gua.remainingEntriesInOfflineCache.ToString());
        }
        #endif


        if (GUILayout.Button("Quit"))
        {
            // End session with custom built hit:
            if (!Analytics.gua.analyticsDisabled)
            {
                Analytics.gua.beginHit(GoogleUniversalAnalytics.HitType.Screenview);
                Analytics.gua.addScreenName("AnalyticsExample - Quit");
                Analytics.gua.addSessionControl(false); // end current session
                Analytics.gua.sendHit();
            }
            #if UNITY_3_5
            gameObject.active = false;
            #else
            gameObject.SetActive(false);
            #endif
            Application.Quit();
        }

        GUILayout.Label("Verified internet access: " + Analytics.gua.internetReachable);

        string networkReachability = "Unity NetworkReachability: none";
        if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
        {
            networkReachability = "Unity NetworkReachability: via carrier data network";
        }
        else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
        {
            networkReachability = "Unity NetworkReachability: via local area network";
        }
        GUILayout.Label(networkReachability);

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
    }
コード例 #3
0
    void OnGUI()
    {
        if (Analytics.Instance == null)
        {
            GUILayout.BeginVertical();
            GUILayout.Label(" ERROR! No Analytics object in scene!");
            GUILayout.Label(" Add Analytics script to an active game object.");
            GUILayout.EndVertical();
            return;
        }

        GUILayout.BeginHorizontal();
        GUILayout.Label("v");
        GUILayout.Label(Analytics.Instance.appVersion);

        GUILayout.BeginVertical();
        GUILayout.Label("- Google Universal Analytics for Unity");
        GUILayout.Label(" Current scene: " + Application.loadedLevelName + "\n");

        // Possibility to switch between scenes demonstrates the
        // automatic screen events sent by Analytics.OnLevelWasLoaded().
        //
        // For this test you need to add both AnalyticsExample and
        // AnalyticsExampleSecondaryScene scenes to the project
        // using File->Build Settings.
        //
        GUILayout.Label("Scene switch sends automatic screen view events:");
        if (GUILayout.Button("Go to Secondary Scene\n(Opt-out example & more)"))
        {
            Application.LoadLevel("AnalyticsExampleSecondaryScene");
        }

        GUILayout.Label("Buttons to send imaginary screen switch events:");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("\"Menuscreen A\""))
        {
            Analytics.changeScreen("AnalyticsExample - Menuscreen A");
        }
        if (GUILayout.Button("\"Menuscreen B\""))
        {
            Analytics.changeScreen("AnalyticsExample - Menuscreen B");
        }
        GUILayout.EndHorizontal();


        GUILayout.Label("\nSocial hits and events - Links to Strobotnik:");
        // This is just an inspirational example. In reality you should
        // integrate official social SDKs and probably send the "Like"
        // type of analytics hit only when user actually does that
        // inside your application.
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Google+"))
        {
            Analytics.gua.sendSocialHit("GooglePlus", "plus", "StrobotnikGooglePlus");
            Application.OpenURL("http://plus.google.com/101873213646861422131");
        }
        if (GUILayout.Button("Facebook"))
        {
            Analytics.gua.sendSocialHit("Facebook", "like", "StrobotnikFacebook");
            Application.OpenURL("http://facebook.com/strobotnik");
        }
        if (GUILayout.Button("Twitter"))
        {
            Analytics.gua.sendSocialHit("Twitter", "follow", "StrobotnikTwitter");
            Application.OpenURL("http://twitter.com/strobotnik");
        }
        if (GUILayout.Button(" Web "))
        {
            Analytics.gua.sendEventHit("OpenWebsite", "Strobotnik.com");
            Application.OpenURL("http://strobotnik.com");
        }
        GUILayout.EndHorizontal();

        GUILayout.Label("\nSend errors and exceptions to analytics:");
        if (Analytics.Instance.sendExceptions)
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Log Error"))
            {
                Debug.LogError("Logged Error to analytics", this);
            }
            if (GUILayout.Button("Divide by zero"))
            {
                // Cause an exception to be sent to analytics
                int b = 0;
                int a = 31337 / b;
                Debug.Log("" + a); // won't get here
            }
            GUILayout.EndHorizontal();
        }
        else
        {
            GUILayout.Label("(Analytics.sendExceptions is disabled)");
        }

        GUILayout.Label("---");

        GUILayout.Label("Remaining entries in offline hit cache:");
        #if UNITY_WEBPLAYER
        GUILayout.Label("(not applicable with web player)");
        #else
        if (Analytics.gua != null)
        {
            GUILayout.Label(Analytics.gua.remainingEntriesInOfflineCache.ToString());
        }
        #endif


        if (GUILayout.Button("Quit"))
        {
            // End session with custom built hit:
            if (!Analytics.gua.analyticsDisabled)
            {
                Analytics.gua.beginHit(GoogleUniversalAnalytics.HitType.Screenview);
                Analytics.gua.addScreenName("AnalyticsExample - Quit");
                Analytics.gua.addSessionControl(false); // end current session
                Analytics.gua.sendHit();
            }
            #if UNITY_3_5
            gameObject.active = false;
            #else
            gameObject.SetActive(false);
            #endif
            Application.Quit();
        }

        GUILayout.Label("Verified internet access: " + Analytics.gua.internetReachable);

        string networkReachability = "Unity NetworkReachability: none";
        if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
        {
            networkReachability = "Unity NetworkReachability: via carrier data network";
        }
        else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
        {
            networkReachability = "Unity NetworkReachability: via local area network";
        }
        GUILayout.Label(networkReachability);

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
    }