ãUnity1ãuGUI(Text)ã§ã¿ã¤ãã«ç»é¢ã¨ã²ã¼ã ãªã¼ãã¼å®è£ ï¼ãã¦ããã£ã¡ãã縦ã¹ã¯ãã¼ã«6ã
Unity5.1.1f1 Personal(2015å¹´6æ)
Â
ãã®ã³ã³ãã³ãã¯ããã¦ããã£ã¡ããã©ã¤ã»ã³ã¹ãã§æä¾ããã¦ãã¾ã
Â
ååã®ç¶ãã§ãã
Â
ä»åã¯ã¿ã¤ãã«ç»é¢ã¨ã²ã¼ã ãªã¼ãã¼ç»é¢ãä½ãã¾ããåºæ¬çã«ä»¥ä¸ã¨ãã»ã³ã¹ã¨ä¼¼ãå 容ã¨ãªã£ã¦ããã¾ãã
Â
ã¾ããuGUIã®Textãä¸å¿ã®å 容ã¨ãªãã¾ãã®ã§ã以ä¸ã¨ãã»ã³ã¹ããåç §ä¸ããã
Â
Â
uGUIã®åºç¤ã¨ãªãCanvasãGUIã®ã®ä½ç½®ã»å¤§ãããè¨å®ããRect Transformã®ã¨ãã»ã³ã¹ããããã¾ãã®ã§ããåç §ä¸ããã
Â
Â
Â
ãç®æ¨ãã¿ã¤ãã«ç»é¢ã¨ã²ã¼ã ãªã¼ãã¼ç»é¢ã表示ããï¼
Â
â ã¿ã¤ãã«ã·ã¼ã³ãä½æãã
ã¾ãã¯Titleã¨ããååã§NewSceneãä½æãã¾ãã
Â
New Sceneä½æãååã¯ãTitleã
Â
次ã«uGUIã®Textã§ã¿ã¤ãã«ãä½æãã¾ããä»åã¯AssetStoreãããã©ã³ããè½ã¨ãã¦é©ç¨ãã¦ã¿ã¾ãããã
Â
Window>AssetStore
Â
ãfontãã§æ¤ç´¢
Â
ç¡æãªã®ã§SquareFontPackãé¸æ
Â
ãã¦ã³ãã¼ãï¼ã¤ã³ãã¼ã
Â
ã¾ãã¯Canvasã®è¨å®ã§ããCanvas Scalerã®è¨å®ã以ä¸ã®ããã«ãã¦ä¸ããã
Canvas Scalerã®è¨å®
Â
ç¶ãã¦Textã®è¨å®ããã¾ãããã
Â
ã¾ãã¯åå:TitleãText:Jumping Unity ChanãFont:vahika bd itãFontSize:80ã«å¤æ´ãã¾ãã
次ã«Alignmentã縦ã»æ¨ªå ±ã«ä¸å¤®å¯ãã«ãã¾ãã
次ã«ãHorizontal Overflowã¨Vertical Overflowã®è¨å®ãOverflowã«ãã大ããªæåãµã¤ãºã«å¯¾å¿ããã¾ãã
Â
æå¾ã«ã¿ã¤ãã«ã«å½±ãä»ãã¦ããã¾ããAddComponent>UI>Effectsã¨é²ã¿ãShadowãé¸æãã¾ãã
TextColorã¯é»è²ã§ãShadowColorããªã¬ã³ã¸ã«ãã¾ãããï¼
Â
Titleããã¹ãã®Inspectorè¨å®
Â
ã¿ã¤ãã«ç»é¢
Â
â¡ã¿ã¤ãã«ã·ã¼ã³ããã¡ã¤ã³ã·ã¼ã³ã¸ç»é¢é·ç§»ãããï¼
ããã§ã¯Titleã·ã¼ã³ããMainã·ã¼ã³ã¸é·ç§»ããã¹ã¯ãªããã§ããLoadMainScriptãæ¸ããMainCameraã«ä»ãã¾ãããã
Â
Â
ç»é¢ãã¯ãªãã¯ããæãApplication.LoadLevelã«ãã£ã¦æå®ããSceneã¸é·ç§»ãããã¨ãã§ãã¾ãã
Â
ããã§æ³¨æï¼
Â
ç»é¢é·ç§»ãããåã«ãBuildããã¾ãããï¼
Â
ï¼ãªãã§é·ç§»ããªãã®ãã¨è¿·åã«ãªã£ãã²ãããããã«ä¸å¹ã»ã»ã»ï¼
Â
BuildSettingsãé¸æãã»ã»ã»
Â
AddCurrentãã¿ã³ãæ¼ã
Â
Add Currentãã¿ã³ãæ¼ãã¨ãä»ç·¨éãã¦ããTitleã·ã¼ã³ãBuildã®å¯¾è±¡ã«ãªãã¾ãï¼Mainã·ã¼ã³ã§ãåããã¨ããã£ã¦ãTitleã¨MainãBuild対象ã«ãããã¨ã§ãSceneéã§ã®ç§»åãã§ããããã«ãªãã¾ãã
Â
ã¿ã¤ãã«ç»é¢ãã¯ãªãã¯ããã¨ã»ã»ã»
Â
ã²ã¼ã ãå§ã¾ãã¾ã
Â
â¡è½ä¸ãã¦ç»é¢å¤ã«åºãæãã²ã¼ã ãªã¼ãã¼ã®æåã表示ãããï¼
ããã§ãTitleã·ã¼ã³ããMainã·ã¼ã³ã¸é·ç§»ã§ããããã«ãªãã¾ããã次ã¯ãè½ä¸ãã¦ç»é¢å¤ã«åºãæã«ã²ã¼ã ãªã¼ãã¼ã¨ãã¦ããã¾ãã
Â
ã¡ããã©ã«ã¡ã©ã®é«ããããã¤ãã¹6ããã¨ç»é¢ä¸ããå°ãä¸ãããã®ãã¸ã·ã§ã³ã«ãªãã®ã§ããã®ä½ç½®ããã¬ã¤ã¤ã¼ã®é«ããä¸åã£ãæã«ãã²ã¼ã ãªã¼ãã¼ã®æåã表示ããããã«ãã¾ãããã
Â
ã¾ãã¯mainã·ã¼ã³ã®HierarchyããCreate>UI>Textãé¸æãã¦ãã²ã¼ã ãªã¼ãã¼ã®æåãä½æãã¾ãããã
Â
GameOverããã¹ãã®Inspectorè¨å®
Â
ãããªæã
Â
ããã§ã¯ä½æããGameOverããã¹ãã«scriptãä»ãã¾ããStartã¡ã½ããã§GameOverã®æåãæ¶ãã¦ããã¦ãLoseã¡ã½ãããå¼ã°ããæã«GameOverã®æåã表示ããããã«ãã¾ããã¾ããGameOverã®æåã表示ãããç¶æ ã§ç»é¢ãã¯ãªãã¯ããã¨ã¿ã¤ãã«ç»é¢ã¸æ»ãããã«ããã¦ããã¾ãã
Â
Â
ããã§GameOverScriptã®Loseã¡ã½ãããå¤é¨ããå¼ã³åºãã°ãã²ã¼ã ãªã¼ãã¼ã®å®æã§ãã
å¼ã³åºãå¦çã¯CameraScriptã«è¨è¿°ãã¦ããã¾ãã
Â
Â
publicå¤æ°ã®GameOverScriptãä½æãã¾ããã®ã§ãGameOverScriptã®ã¤ãã¦ããGameOverããã¹ãããã©ãã°ï¼ããããã§æå®ãã¾ãã
Â
ãã©ãã°ï¼ããããï¼
Â
ãã¬ã¤ã¤ã¼ã®é«ããç¾å¨ã®ã«ã¡ã©ä½ç½®ãã6ä¸ãã£ãä½ç½®ãä¸åã£ãæãgameOverScriptã®Loseã¡ã½ãããå®è¡ãã¦GameOverã®æåã表示ãããã¬ã¤ã¤ã¼ãDestroyã¡ã½ããã«ãã£ã¦åé¤ãã¦ãã¾ãã
Â
ããã§å ¨ã¦ã®æºåãå®äºè´ãã¾ããã
Â
ãçµæã
ã¿ã¤ãã«ç»é¢ãã¯ãªãã¯
Â
ã²ã¼ã ã¹ã¿ã¼ã
Â
ç»é¢å¤ã¸è½ã¡ã¦GameOver
Â
ã¯ãªãã¯ã§ã¿ã¤ãã«ç»é¢ã¸æ»ã
Â
ããã§ã¿ã¤ãã«âã¡ã¤ã³âã²ã¼ã ãªã¼ãã¼âã¿ã¤ãã«ã¨ããä¸é£ã®æµããå®æãã¾ããã
Â
æ¬æ¥ã¯ããã¾ã§ã§ãã
ãããã¨ããããã¾ããã
Â