※文字数のチェックはしていないので注意。
-----
/* * @file Sample_Twitter.cs * @attention * @note Open Twitter site sample */ using UnityEngine; public class Sample_Twitter : MonoBehaviour { string tweetText = "つい~とのテスト"; //!< Tweet strings /*! Unity builtin function * OnGUI() */ void OnGUI(){ if(ScrnHor!=Screen.width){ ReCalcScrn(); } // ReCalculation size of screen GUI.Box(rectBg, "Twetter"); // Draw background if(GUI.Button(rectURL, "Tweet: "+tweetText)) { // Tweet button Application.OpenURL("https://twitter.com/intent/tweet?text="+WWW.EscapeURL(tweetText)); // Call browser for tweet } } //============================================================ float ScrnHor; //!< Currently size of screen horizontal float ScrnVert; //!< Currently size of screen vertical Rect rectBg; //!< Background rectangle Rect rectURL; //!< URL button rectangle /*! ReCalculation size of screen */ void ReCalcScrn(){ ScrnHor = (float)Screen.width; ScrnVert = (float)Screen.height; rectBg = new Rect(ScrnHor*0.1f,ScrnVert*0.1f,ScrnHor*0.8f,ScrnVert*0.8f); rectURL = new Rect(ScrnHor*0.12f,ScrnVert*0.16f,ScrnHor*0.76f,ScrnVert*0.1f); } /*! Unity builtin function * Awake() */ void Start () { Screen.orientation = ScreenOrientation.AutoRotation; // Auto rotation ReCalcScrn(); } /*! Unity builtin function * Update() */ void Update () { // Exit app when hit back button(Android) ※機種判定を外すとESCでアプリ終了(Windows) if(Application.platform == RuntimePlatform.Android && Input.GetKey(KeyCode.Escape)){ // Back button Application.Quit(); } } //============================================================ }-----
0 件のコメント:
コメントを投稿