ãUnity2ãuGUIã§ã²ã¼ã ãªã¼ãã¼ã¨ã¯ãªã¢ç»é¢ãä½æ(åç·¨)ï¼Canvas, Text, Buttonããããã¯å´©ã4ã
Unityãã¼ã¸ã§ã³ï¼5.0.0f4 Personal (2015/4/23)
Â
ååã®ç¶ããæ¸ãã¦ããã¾ãã
ä»åã¯ãã²ã¼ã ãªã¼ãã¼ã¨ã²ã¼ã ã¯ãªã¢ã«ã¤ãã¦ã§ãï¼
Â
 ãç®æ¨ãã²ã¼ã ãªã¼ãã¼ã¨ã¯ãªã¢ãè¨å®ãã¦ãã²ã¼ã ãå®å ¨ã«åã
Â
ã課é¡ï¼ãã¿ã¤ãã«ãã¼ã¸ãä½ã
ã¾ãã¯ã¿ã¤ãã«ãã¼ã¸ãä½ãã¾ãããã
Â
FileããNewSceneãé¸æãã¦ãã¨ããããSaveSceneãå®è¡ãã¾ããååã¯ã·ã³ãã«ã«ãtitleãã«ãã¾ãããï¼
Â
次ã«Hierarchy>Create>UIãããTextãé¸æãã¾ããããããã¨ãHierarchyä¸ã«Canvasã¨ããé ç®ãåºã¦ãã¦ããã®ä¸ã«Textãå ¥ã£ã¦ã¾ãããã¨ä»ã«EventSystemãåºã¦ãã¾ãããä»åã¯ä½¿ãã¾ããï¼
Â
è²ã åºã¦ãã¦
Â
Gameç»é¢ã¯ãããªæã
Â
åã¯ä»åã²ã¼ã åããSIMPLE BREAKERãã¨ããååã«ãã¾ããçãããèªåã®å¥½ããªååãä»ãã¦ä¸ããã
Â
ãâ»â»â»è¤æ°è§£å度ãã¢ã¹ãã¯ãæ¯ã«å¯¾å¿ããGUIã®è¨å®â»â»â»ã
ã¹ãã¼ããã©ã³ã®è§£å度ãã¢ã¹ãã¯ãæ¯ã¯é常ã«å¹ åºãã§ãããç¾å¨Unityã§ä½¿ããã¦ããuGUIã¯ãè¤æ°è§£å度ãã¢ã¹ãã¯ãæ¯ã«å¯¾å¿ããããã¨ãã§ãã¾ãã
Â
Canvasã®ã³ã³ãã¼ãã³ãã§ããCanvasScalerãè¨å®ãã¾ããCanvasScalerãç¡ãå ´åã¯ãAddComponent>Layoutï¼CanvasScalerã¨é²ãã¨ããã¾ãï¼
Â
ã¾ãã¯UI Scale Modeã¯Scale With Screen Sizeã«è¨å®ãã¾ããããã§ç»é¢ãµã¤ãºãå¤ãã£ã¦ããUIã®ä½ç½®ãé£åãã¦å¤ããã¾ãã
Â
ç¶ãã¦ReferenceResolutionã§ãããããã¯æ³å®ãã¦ãã解å度ãè¨å®ãã¾ããä»åã¯åãæã£ã¦ãã端æ«zenfone5ã«åããã¦X:1280,Y:720ã«è¨å®ãã¾ãã
Â
ScreenMatchModeã¯MatchWidthOrHeightã«ãã¦ãMatchã®é¨åã¯Heightã«å¤æ´ãã¾ããããã§ç»é¢ã®é«ãã«åããã¦GUIã®ãµã¤ãºãå¤æ´ããã¾ãã
Â
ãããªæãã«ãªãã¾ãã
Â
ç¶ãã¦Canvasã®ä¸ã«ããTextã®è¨å®ããã¾ãããï¼
Â
ã¾ãã¯Textã®åºæºç¹ãçãä¸ã«ãã¾ããããã¯Textã®Inspectorã«ããRectTransformã®å·¦å´ã«ããåè§ãã¯ãªãã¯ãã¦ãåºã¦ããåºæºç¹ä¸è¦§ããä¸å¿ãé¸ã³ã¾ãããã®æãaltãæ¼ããªããé¸æããã¨ããã¹ãã®ä½ç½®ãä¸ç·ã«åºæºç¹ã«è¡ã£ã¦ããã¾ãã
Â
次ã«ããã¹ãèªä½ãç·¨éãã¾ãã
Â
åããTextã®Inspectorä¸ã«ãTextScriptã¨ããã³ã³ãã¼ãã³ããããã¾ãã®ã§ãããã§ããã¹ãããã©ã³ããæåãµã¤ãºã決ãã¦ããã¾ãã
Â
ã¡ãªã¿ã«åã¯ãã©ã³ãããasset storeã«ãã£ãã1970s Font Packãã¨ããassetã®ä¸ã®ãscreengemãã¨ãããã©ã³ãã使ãã¾ããã
Â
Window>Asset Storeãã
Â
ããæãã®ãã©ã³ãããã¦ã³ãã¼ãâã¤ã³ãã¼ãã
Â
Â
é¸æã»é©ç¨ãã¾ã
Â
ã ãããçãä¸ããããåºæºç¹ã«ãã¾ãããã微調æ´ããå ´åã¯RectTransformã®PosXãPosYãå¤æ´ãã¾ãããï¼ã¾ããã©ã³ããµã¤ãºã大ããããæã«æåãæ¶ãã¦ãã¾ã£ãå ´åã¯æå表示ç¯å²ãè¶ ãã¦ãã¾ã£ã¦ããã®ã§ãRectTransformã®Widthã»Heightã®å¤ã大ãããã¦èª¿æ´ãã¾ãããã
Â
Â
ããã¹ããããã²ã¨ã¤è¿½å ãããæããã®å¾ãããã¿ã³ãé ç½®ãããæã¯ãåãããã«Create>UIãããã¼ããé¸æããã°ãCanvasã®ä¸ã«ä½æããã¾ãã®ã§ãããããä½ãã¾ãã
Â
ãããªæãã«ãªãã¾ãã
Â
æ´ã«ãã¿ã³ãé ç½®ãã¦ãåã容éã§è¦æ ãããããã¦ã¿ã¾ãããã
Â
ãããªæã
Â
ã課é¡ï¼ãSTARTãã¿ã³ãæ¼ããæãã¡ã¤ã³ç»é¢ã¸é·ç§»ããã
STARTãã¿ã³ãæ¼ããæã«ãååã¾ã§ã«ä½ã£ã¦ãããã²ã¼ã ã®ç»é¢ã¸é·ç§»ãããããã«ãã¾ããããã¾ãã¯scriptããã
Â
Â
é常ã«ã·ã³ãã«ãªscriptã§ãããã¾ãã¯ãã®SceneLoadScriptãButtonãªãã¸ã§ã¯ãã«è²¼ãä»ãã¾ãããï¼
Â
ãApplication.LoadLevel ();ãã¯ãæå®ããSceneã¸é£ã³ã¾ããã¤ã¾ãï¼SceneLoadã¡ã½ãããå¼ã³åºããã°èª²é¡ã¯ãªã¢ã¨ããããã§ãï¼
Â
ãã®ã¡ã½ããããã¿ã³ãæ¼ããæã«å®è¡ããããã«ã¯ãButtonã®Inspectorã«ããButton(script)ã³ã³ãã¼ãã³ãã®ä¸çªä¸ã«ããOnClickã§è¨å®ãããå¿ è¦ãããã¾ããã¾ãã¯ãã©ã¹ãã¿ã³ãæ¼ãã¦
Â
Â
âãã¿ã³ãæ¼ãButtonãé¸ãã§
Â
Â
NoFunctionã¨æ¸ãããé¨åãã¯ãªãã¯ããSceneLoadScript>SceneLoad()ã¨é²ã¿é¸æãã¦ä¸ããã
Â
Â
ããã§è¨å®å®äºã§ãï¼ãããã¿ã³ãã¯ãªãã¯ï¼ãã¿ã³åå¿ãªãï¼
Â
Unityã«ã¯ãã«ãã¨ããæ©è½ãã¤ãã¦ãã¦ãä½æããã¢ããªãPCç¨ãHPç¨ãAndroidç¨ãiOSç¨ãªã©åãã«å¤æãããã¨ãã§ãã¾ãããã®ãã«ãè¨å®ç»é¢ã«ä»ä½æãããtitleãã·ã¼ã³ã¨ãååã¾ã§ã«ä½æãã¦ãããmainãã·ã¼ã³ãé ç½®ããªãã¨ãApplication.LoadLevelããã¾ãæ©è½ãã¦ããã¾ããã
Â
File>Build Settingsãã
Â
Add Currentãæ¼ãã¦Scenes In Buildã®ä¸ã«titleã·ã¼ã³ã
Â
ä¸æ¦mainã·ã¼ã³ãéããªããã¦åããAdd Currentãè¡ã
Â
ããã§æºåã¯æ´ãã¾ããï¼ããã§ã¯æ©éï¼
Â
STARTãã¿ã³ãæ¼ãã¨ã»ã»ã»
Â
ã²ã¼ã ã·ã¼ã³ã¸ï¼
Â
ã¡ãã£ã¨é·ããªã£ã¦ãã¾ã£ãã®ã§ãç¶ãã¯æ¬¡åã§ã
ãããã¨ããããã¾ããã
Â