Example #1
0
 public static int GetShortSideInDP()
 {
     return(DisplayMetricsUtil.PixelToDp(DisplayMetricsUtil.GetShortSide()));
 }
    /**
     * PLAYER SETTINGS - SCRIPTING BACKEND - auf 64 bit gesetzt. Siehe: http://docs.unity3d.com/Manual/iphone-64bit.html
     *
     * Bundle Identifier
     *
     *          The Bundle Identifier string MUST MATCH the provisioning profile of the game you are building. The basic structure of the identifier is com.CompanyName.GameName. This structure may vary internationally based on where you live, so always default to the string provided to you by Apple for your Developer Account. Your GameName is set up in your provisioning certificates, that are manageable from the Apple iPhone Developer Center website. Please refer to the Apple iPhone Developer Center website for more information on how this is performed.
     *
     *
     *
     *
     * TODO  - CHECK PERFORMANCE IMPACT (IF IT IS NOT OBVIOUS I MIGHT JUST NEGLECT THIS)
     *          What kind of performance impact will UnityGUI make on my games?
     *
     *          A: UnityGUI is fairly expensive when many controls are used.
     *          It is ideal to limit your use of UnityGUI to game menus or very minimal GUI Controls while your game is running.
     *          It is important to note that every object with a script containing an OnGUI() call
     *          will require additional processor time – even if it is an empty OnGUI() block.
     *          It is best to disable any scripts that have an OnGUI() call if the GUI Controls are not being used.
     *          You can do this by marking the script as enabled = false.
     *
     *
     *
     *          Any other tips for using UnityGUI?
     *          A: Try using GUILayout as little as possible. If you are not using GUILayout at all from one OnGUI() call, you can disable all GUILayout rendering using MonoBehaviour.useGUILayout = false; This doubles GUI rendering performance. Finally, use as few GUI elements while rendering 3D scenes as possible.
     */
    void OnGUI()
    {
        OnGUI_Before("");
        OnGUI_ScrollViewStart();
        GUILayout.FlexibleSpace();

        if (!Member.isMember)
        {
            if (!Member.connectionCheckCompleted || !Member.internetConnectionExists)
            {
                GUILayout.Label("DIE EUROPÄISCHEN WERTE", Master.styleTextStartSceneBig);

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(Master.circle7a, Master.styleButtonNoStyle, GUILayout.MaxHeight(DisplayMetricsUtil.GetShortSide() * 0.6f), GUILayout.MaxWidth(DisplayMetricsUtil.GetShortSide() * 0.6f)))
                {
                    Application.LoadLevel("MainScene");
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.FlexibleSpace();
                if (Member.connectionCheckCompleted && !Member.internetConnectionExists)
                {
                    GUILayout.Label("Bitte stellen Sie eine Verbindung mit dem Internet her.\nDas ist nur einmal notwendig.", Master.styleTextDefaultCenter);
                }
                else
                {
                    GUILayout.Label("Die APP wird initialisiert.\nBitte warten ...", Master.styleTextDefaultCenter);
                }
            }
            else
            {
                // This code is reached when
                // - Connection check is completed
                // - Internet connection exists
                // - User is NOT a member
                //GUILayout.Label("Geben Sie unten Ihren Code ein,\nden Sie von TeamFreiheit erhalten,\n um die App zu aktivieren:", Master.styleTextDefaultCenter);
                //GUILayout.Label("", GUILayout.MinHeight(DisplayMetricsUtil.DpToPixel(3)));
                GUILayout.Label("APP CODE eingeben:", Master.styleTextHeaderCenter);

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                //GUILayout.Label("APP CODE:", Master.styleTextAppCode, GUILayout.Height(Master.guiElementHeightDefault*1.1f)); //NOTE: Dirty small UI fix
                enteredMemberId = GUILayout.TextField(enteredMemberId, Master.menuSkin.textField, GUILayout.Height(Master.guiElementHeightDefault), GUILayout.Width(DisplayMetricsUtil.DpToPixel(130)));
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.Label("", GUILayout.MinHeight(DisplayMetricsUtil.DpToPixel(3)));
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Aktivieren", Master.styleButtonTorquise, GUILayout.Height(Master.guiElementHeightDefault), GUILayout.Width(DisplayMetricsUtil.DpToPixel(250))))
                {
                    Application.LoadLevel("MainScene");
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.Label("", GUILayout.MinHeight(DisplayMetricsUtil.DpToPixel(5)));
                if (Member.checkFailed)
                {
                    GUILayout.Label(Member.errorMessage, Master.styleTextDefaultRed);
                }
                else
                {
                    if (!Member.isEveryone)
                    {
                        GUILayout.Label("Der Code ist nicht gültig", Master.styleTextDefaultRed);
                    }
                }
                GUILayout.Label("", GUILayout.MinHeight(DisplayMetricsUtil.DpToPixel(5)));

                GUILayout.FlexibleSpace();

                GUILayout.FlexibleSpace();



                GUILayout.Label("Um einen App Code zu bekommen, \nschreiben Sie eine E-Mail mit dem Betreff \"APP CODE\" an:", Master.styleTextDefaultCenter);
                GUILayout.Label("", GUILayout.MinHeight(DisplayMetricsUtil.DpToPixel(3)));
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(GetActive.emailAdress, Master.styleButtonTorquise, GUILayout.Height(Master.guiElementHeightDefault)))
                {
                    Application.OpenURL("mailto:" + GetActive.emailAdress);
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.FlexibleSpace();



                GUILayout.Label("Besuchen Sie auch die Website:", Master.styleTextDefaultCenter);
                GUILayout.Label("", GUILayout.MinHeight(DisplayMetricsUtil.DpToPixel(3)));
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Europaeischewerte.info", Master.styleButtonTorquise, GUILayout.Height(Master.guiElementHeightDefault)))
                {
                    Application.OpenURL(GetActive.urlEuropeanValues);
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
        }
        else
        {
            GUILayout.Label("DIE EUROPÄISCHEN WERTE", Master.styleTextStartSceneBig);
            GUILayout.Label("", GUILayout.MinHeight(DisplayMetricsUtil.DpToPixel(15)));

            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.MinWidth(DisplayMetricsUtil.DpToPixel(1))); // Indent complete menu to the right
            GUILayout.BeginVertical();
            GUI.skin = Master.menuSkin;
            if (GUILayout.Button(new GUIContent("     Die Werte ", Master.v1p)))
            {
                Application.LoadLevel("ValuesScene");
            }
            if (GUILayout.Button(new GUIContent("     Ihre Geschichte", Master.v2p)))
            {
                Application.LoadLevel("HistoryOfValuesScene");
            }
            if (GUILayout.Button(new GUIContent("     Werte? Wozu?", Master.menuIconQuestionMark)))
            {
                Application.LoadLevel("NeedOfValues");
            }
            if (GUILayout.Button(new GUIContent("     Was kann ich tun?", Master.menuIconDefault)))
            {
                Application.LoadLevel("GetActiveScene");
            }
            GUILayout.EndVertical();
            GUILayout.Label("", GUILayout.MinWidth(DisplayMetricsUtil.DpToPixel(1))); // Indent complete menu to the left
            GUILayout.EndHorizontal();

            GUILayout.Label("", GUILayout.MinHeight(DisplayMetricsUtil.DpToPixel(15)));
            GUILayout.Label("Copyright by TeamFreiheit.info\nHumanistischer Verein für Demokratie und Menschenrechte", Master.styleTextStartSceneSmall);
        }
        GUILayout.FlexibleSpace();
        GUILayout.FlexibleSpace();
        OnGUI_ScrollViewEnd();
        OnGUI_Button();
    }
    private void OnGUI_debugInfo()
    {
        GUILayout.Label("\n\n\n\nDEBUG MODE\n", Master.styleTextStartSceneBig);
        GUILayout.BeginVertical();
        GUILayout.Label("Current display settings", Master.styleTextHeader);
        GUILayout.Label("   DPI (in use)______: " + DisplayMetricsUtil.GetDPI_Debug(), Master.styleTextDefault);
        GUILayout.Label("   DPI by Unity______: " + Screen.dpi, Master.styleTextDefault);
        if (DisplayMetricsAndroid.IsAndroid)
        {
            GUILayout.Label("   DPI by Android____: " + DisplayMetricsAndroid.DensityDPI, Master.styleTextDefault);
        }
        GUILayout.Label("   Resolution type__: " + DisplayMetricsUtil.GetResolutionType(), Master.styleTextDefault);
        GUILayout.Label("   Scale____________: " + DisplayMetricsUtil.GetScale_DEBUG(), Master.styleTextDefault);
        GUILayout.Label("   Screensize_______: " + DisplayMetricsUtil.GetScreenSize_DEBUG(), Master.styleTextDefault);

        GUILayout.Label("   Short Side: " + DisplayMetricsUtil.GetShortSideInDP() + " dp = " +
                        DisplayMetricsUtil.GetShortSide() + " pixel = " +
                        DisplayMetricsUtil.GetShortSideInInch() + " inch = " +
                        DisplayMetricsUtil.GetShortSideInCentimeters() + " cm", Master.styleTextDefault);
        GUILayout.Label("   Long Side: " + DisplayMetricsUtil.GetLongSideInDP() + " dp = " +
                        DisplayMetricsUtil.GetLongSide() + " pixel = " +
                        DisplayMetricsUtil.GetLongSideInInch() + " inch = " +
                        DisplayMetricsUtil.GetLongSideInCentimeters() + " cm", Master.styleTextDefault);
        GUILayout.Label("Member information:", Master.styleTextHeader);
        GUILayout.Label("  Was there an internet connection(at last check) " + Member.internetConnectionExists, Master.styleTextDefault);
        GUILayout.Label("  Error message(In case an error occurred): " + Member.errorMessage, Master.styleTextDefault);
        if (GUILayout.Button("Delete Member information"))
        {
            Member.DeleteMember();
        }
        GUILayout.Label("\n\n", Master.styleTextDefault);

        if (debugTouchCounter > debugTouchCountActiv * 4)
        {
            GUILayout.Label("Touch Data: \n" + debugTouchEnd, Master.styleTextDefault);

            GUILayout.Label("\n\n", Master.styleTextDefault);
            GUILayout.Label("How often was Update() called: " + countUpdate, Master.styleTextDefault);
            GUILayout.Label("\n\n\n", Master.styleTextDefault);

            GUILayout.Label("DisplayMetricsAndroid says", Master.styleTextHeader);
            GUILayout.Label("   IsAndroid=" + DisplayMetricsAndroid.IsAndroid, Master.styleTextDefault);
            if (DisplayMetricsAndroid.IsAndroid)
            {
                GUILayout.Label("   " + DisplayMetricsAndroid.HeightPixels + "x" + DisplayMetricsAndroid.WidthPixels + " (Screen size)", Master.styleTextDefault);
                GUILayout.Label("   Density=" + DisplayMetricsAndroid.Density, Master.styleTextDefault);
                GUILayout.Label("   DensityDPI=" + DisplayMetricsAndroid.DensityDPI, Master.styleTextDefault);
                GUILayout.Label("   X-DPI=" + DisplayMetricsAndroid.XDPI, Master.styleTextDefault);
                GUILayout.Label("   Y-DPI=" + DisplayMetricsAndroid.YDPI, Master.styleTextDefault);

                float widthInch2  = DisplayMetricsAndroid.HeightPixels / DisplayMetricsAndroid.DensityDPI;
                float heightInch2 = DisplayMetricsAndroid.WidthPixels / DisplayMetricsAndroid.DensityDPI;
                GUILayout.Label("   " + widthInch2 + "x" + heightInch2 + " inch", Master.styleTextDefault);
                GUILayout.Label("   " + System.Math.Round(widthInch2 * 2.54f, 1) + "x" + System.Math.Round(heightInch2 * 2.54f, 1) + " (Calculated cm)", Master.styleTextDefault);
            }
            GUILayout.Label("\n\n\n", Master.styleTextDefault);


            GUILayout.Label("What is the right dpi for this display?", Master.styleTextDefault);
            GUILayout.Label("Measure below which grey line has 5.08 cm(+/-0.1; equal to 2 inch).", Master.styleTextDefault);
            GUILayout.Label("The line which matches is the right dpi:", Master.styleTextDefault);
            GUILayout.Label("The line should match the first grey line - if not then UI might not be as perfect as possible:", Master.styleTextDefault);

            GUILayout.Button("MATCH THIS", GUILayout.Height(15), GUILayout.Width(DisplayMetricsUtil.DpToPixel(160 * 2)));
            GUILayout.Button(" 96 dpi", GUILayout.Height(15), GUILayout.Width(96 * 2));
            GUILayout.Button("101 dpi", GUILayout.Height(15), GUILayout.Width(101 * 2));
            GUILayout.Button("160 dpi", GUILayout.Height(15), GUILayout.Width(160 * 2));
            GUILayout.Button("213 dpi", GUILayout.Height(15), GUILayout.Width(213 * 2));
            GUILayout.Button("234 dpi", GUILayout.Height(15), GUILayout.Width(234 * 2));
            GUILayout.Button("240 dpi", GUILayout.Height(15), GUILayout.Width(240 * 2));
            GUILayout.Button("267 dpi", GUILayout.Height(15), GUILayout.Width(267 * 2));
            GUILayout.Button("285 dpi", GUILayout.Height(15), GUILayout.Width(285 * 2));
            GUILayout.Button("294 dpi", GUILayout.Height(15), GUILayout.Width(294 * 2));
            GUILayout.Button("312 dpi", GUILayout.Height(15), GUILayout.Width(312 * 2));
            GUILayout.Button("326 dpi", GUILayout.Height(15), GUILayout.Width(326 * 2));
            GUILayout.Button("342 dpi", GUILayout.Height(15), GUILayout.Width(342 * 2));
            GUILayout.Button("367 dpi", GUILayout.Height(15), GUILayout.Width(367 * 2));
            GUILayout.Button("380 dpi", GUILayout.Height(15), GUILayout.Width(380 * 2));
        }

        GUILayout.EndVertical();
    }