예제 #1
0
    void OnGUI()
    {
        int iY = 10;

        if (GUI.Button(new Rect(10, iY, 300, 30), "Unity Call Android ShowAlertDialog"))
        {
            pMyAndroid.UnityCallAndroidAlert("Complete!", "Retry?", "YES", "QUIT");
        }
        iY += 40;
        if (GUI.Button(new Rect(10, iY, 300, 30), "Unity Call Android ShowToast"))
        {
            pMyAndroid.UnityCallAndroidToast("Fail!");
        }
        iY += 40;
                #if UNITY_ANDROID
        sPlatform = "Unity plugins use so file";
                #else
        sPlatform = "Unity plugins use DLL file";
                #endif
        if (GUI.Button(new Rect(10, iY, 300, 30), sPlatform))
        {
            fTemp = UnityPluginsUser.callMultiply(3.1415926535f, 4.0f);
            sTemp = "4Pi=" + fTemp;
        }
        iY += 40;
        if (GUI.Button(new Rect(10, iY, 300, 30), "Unity Tech sample"))
        {
            fTemp = UnityPluginsUser.callAdd(3.1415926535f, 3.1415926f);
            sTemp = "2Pi=" + fTemp;
        }
        iY += 40;
        if (GUI.Button(new Rect(10, iY, 300, 30), sTemp))
        {
        }
        iY += 40;
        if (GUI.Button(new Rect(10, iY, 300, 30), "Unity Call Android SDK Version"))
        {
            int iV = pMyAndroid.UnityCallAndroidSDKVersion();
            sTemp = Application.unityVersion + ",AndroidSDK=" + iV;
        }
        iY += 40;
        if (GUI.Button(new Rect(10, iY, 300, 30), "Unity Call Android Version Name"))
        {
            sTemp = pMyAndroid.UnityCallAndroidVersionName();
        }
        iY += 40;
        if (GUI.Button(new Rect(10, iY, 300, 30), "Unity Call Android ShowToast2"))
        {
            pMyAndroid.UnityCallAndroidToast2("Jar2!");
        }
    }
    //
    void OnGUI()
    {
        scale = new Vector2(Screen.width / baseW, Screen.height / baseH);
        GUIUtility.ScaleAroundPivot(scale, Vector2.zero);
        //
        GUIStyle gsLabel = new GUIStyle();

        //check if game complete
        if (bGameComplete)
        {
            EnableGameMenu(bGameComplete);
            sCount = "Congratulation!!";
            gsLabel.normal.textColor = Color.magenta;
            gsLabel.fontSize         = 36;
            //change complete texture by spriteRender
            spriteRenderer        = mCurrentGameObjectLU.GetComponent <SpriteRenderer>();
            spriteRenderer.sprite = spritesComplete;
            //
            GUI.Label(new Rect(280, 160, 220, 80), sCount, gsLabel);
            sCount = "結算畫面:";
            GUI.Label(new Rect(280, 210, 220, 80), sCount, gsLabel);
            string stringstr = (fTimerPassed).ToString("##0.0");
            sCount = "使用秒數:" + stringstr + "秒.";
            GUI.Label(new Rect(280, 260, 220, 80), sCount, gsLabel);
            sCount = "推圖步數:" + m_iCount + "步.";
            GUI.Label(new Rect(280, 310, 220, 80), sCount, gsLabel);
            sCount = "得分:" + miScore + "分.";
            GUI.Label(new Rect(280, 360, 220, 80), sCount, gsLabel);
//		    pMyAndroid.UnityCallAndroidToast("成功了!") ;
            pMyAndroid.UnityCallAndroidAlert("完成拼圖!", "再玩一次?", "確定", "離開");
        }
        else if (bInitialize == true)
        {
            sCount                   = "九宮格拼圖";
            gsLabel.fontSize         = 24;
            gsLabel.normal.textColor = Color.black;
            GUI.Label(new Rect(280, 165, 220, 80), sCount, gsLabel);
            sCount = "玩法:";
            GUI.Label(new Rect(280, 215, 220, 80), sCount, gsLabel);
            sCount = "圖塊分九格,一格為空格,每次移動一格,";
            GUI.Label(new Rect(280, 265, 220, 80), sCount, gsLabel);
            sCount = "上下左右圖案都必須與緊鄰的圖案接合。";
            GUI.Label(new Rect(280, 315, 220, 80), sCount, gsLabel);
            sCount = "按鍵:上、下、左、右。";
            GUI.Label(new Rect(280, 365, 220, 80), sCount, gsLabel);
        }
        else
        {
            //check if game over
            if (bGameOver == true)
            {
                sCount                   = "Timeout!";
                gsLabel.fontSize         = 36;
                gsLabel.normal.textColor = Color.red;
                GUI.Label(new Rect(280, 160, 220, 80), sCount, gsLabel);
                sCount = "結算畫面:";
                GUI.Label(new Rect(280, 210, 220, 80), sCount, gsLabel);
                string stringstr = (fTimerPassed).ToString("##0.0");
                sCount = "使用秒數:" + stringstr + "秒.";
                GUI.Label(new Rect(280, 260, 220, 80), sCount, gsLabel);
                sCount = "推圖步數:" + m_iCount + "步.";
                GUI.Label(new Rect(280, 310, 220, 80), sCount, gsLabel);
                sCount = "得分:" + miScore + "分.";
                GUI.Label(new Rect(280, 360, 220, 80), sCount, gsLabel);
//			    pMyAndroid.UnityCallAndroidToast("失敗了!") ;
                pMyAndroid.UnityCallAndroidAlert("時間用完了!", "再試一次?", "確定", "離開");
            }
            else
            {
                string stringstr = (fRemainTimer).ToString("##0.0");                 //result: 567.8
                sCount                   = "" + stringstr + "秒";
                gsLabel.fontSize         = 24;
                gsLabel.normal.textColor = Color.black;
                GUI.Label(new Rect(3, 10, 220, 80), sCount, gsLabel);
            }
        }

/*		//Debug message
 *              if (bTouchInput)
 *              {
 *                      gsLabel.fontSize = 24 ;
 *                      gsLabel.normal.textColor = Color.black ;
 *                      GUI.Label(new Rect(3,3,220,80),sTouch,gsLabel) ;
 *              }
 */
    }