ãUnity6ãuGUI(Text)ã§å¶éæéã¨ã²ã¼ã ãªã¼ãã¼ç»é¢ãå®è£ ï¼Time.deltaTimeããã ãã 風7ã
Unity5.0.0f4 Personal(2015å¹´5æ)
Â
ååã®ç¶ãã§ãã
ä»åã¯å¶éæéãè¨å®ããå¶éæéãçµéããã¨ã²ã¼ã ãªã¼ãã¼ã¨ãªãæ©è½ãå®è£ ãããã¨æãã¾ãã
Â
ãç®æ¨ãå¶éæéã¨ã²ã¼ã ãªã¼ãã¼æ©è½ãå®è£ ããã²ã¼ã ãå®æãããï¼
Â
ã課é¡ï¼ãå¶éæéã®GUIã表示ããã
ã¾ãã¯å¶éæéã表示ããGUI(Text)ãã²ã¼ã ç»é¢ã¸åãä»ãã¾ããããHierarchyããCreate>UI>Textãé¸æããååã¯Timeã«ãã¾ãã
Â
GUI(Text)ä½æ
Â
GUI(Text)è¨å®
Â
ç»é¢å³ä¸ã«å¶éæéã®GUI(Text)ä½æ
Â
ã課é¡ï¼ãã«ã¦ã³ããã¦ã³æ©è½ãä»ãã
ç¶ãã¦ã¹ã¯ãªãããä½ãã¾ããTimeScriptãä½æããå ã»ã©ä½æããTimeãªãã¸ã§ã¯ãã«åãä»ãã¾ãã以ä¸ã½ã¼ã¹ã§ãï¼
Â
Â
å¶éæéã¯60ç§ã¨ããStartã¡ã½ããã§è¡¨ç¤ºããTime.deltaTimeããã¤ãã¹ãã¦ãããã¨ã§1ç§ã«1ãã¤ã«ã¦ã³ããã¦ã³ãã¦ãã¾ãã
æéã表示ããéã«ããã®ã¾ã¾è¡¨ç¤ºããã¨å°æ°ç¹ã¾ã§ä»ãã¦ãã¾ãããã(int)ãå¤æ°ã®åã¸ç½®ãã¦floatåããintåã¸å¤æãã¦ããã¾ãããããCastã¨è¨ãã¾ãã
次ã«ãCastããå¤æ°ãæ´ã«ToStringã«ã¦Stringåã¸å¤æãã¦ããã¾ããTextã¨ãã¦è¡¨ç¤ºããããã«ã¯ãStringåã§ãªããã°ãªããªãããã§ãã
Â
ã課é¡ï¼ãã²ã¼ã ãªã¼ãã¼æ©è½ãä»ãã
ç¶ãã¦å¶éæéããªã¼ãã¼ããæã«GAME OVERã®æåã表示ãããæä½ã§ããªãããã«ãã¾ããã¾ãã¯Hierarchy>Create>UI>Textãé¸æããååãGameOverã«å¤æ´ããInspectorãã¥ã¼ã®æ å ±ãå¤æ´ãã¦ããã¾ãã
Â
GUI(Text)ä½æ
Â
Inspectorè¨å®
Â
ãããªæã
Â
ããã§ã¯ã¹ã¯ãªããã§ã²ã¼ã ãªã¼ãã¼æ©è½ãä»ãã¦ãããã¨æãã¾ããååä½æããTimeScriptã«è¿½è¨ãã¦ããå½¢ã§å®ç¾ããã¦ããã¾ãã以ä¸ã½ã¼ã¹ã§ãï¼
Â
Â
ã¾ãã¯publicå¤æ°ã¨ãã¦ãballScriptã»exchangeButtonã»gameOverTextã追å ãããã®ã§ãªãã¸ã§ã¯ããæå®ãããã¨æãã¾ãã
Â
ãã©ãã°ï¼ããããï¼
Â
ã¹ã¯ãªããã®èª¬æã«å ¥ãã¾ããã¾ãã¯Startã¡ã½ããã«ã¦GameOverãªãã¸ã§ã¯ããç¡å¹ã«ããGAME OVERã®æåãæ¶ãã¦ãã¾ãã次ã«ãUpdateã¡ã½ããã«ã¦å¶éæéã0以ä¸ã«ãªã£ãæãGameOverã¡ã½ãããã³ã«ã¼ãã³ã§å¼ã³åºãã¦ãã¾ãã
Â
GameOverã¡ã½ããã§ã¯ãã¾ãã¯Startã¡ã½ããã«ã¦falseã«ãã¦ãããGameOverããã¹ããtrueã«ãããã¨ã§GAME OVERã®æåã表示ããã¦ãã¾ãã
次ã«Exchangeãªãã¸ã§ã¯ãã®interactbleãfalseã«ãããã¨ã§ã²ããExchangeãã¿ã³ã使ç¨ä¸å¯ã«ãã¦ãã¾ãã
次ã«ballScriptã®isPlayingã¨ããå¤æ°ãfalseã«ãã¦ãã¾ãããããã«ã¤ãã¦ã¯å¾è¿°ãã¾ãã
次ã«WaitForSecondsã§2ç§å¾ ã¡ã2ç§å¾ã«ç»é¢ãã¯ãªãã¯ããã¨titleã·ã¼ã³ã¸é·ç§»ãã¾ãã
Â
ããã§ã¯ballScriptã«isPlayingã¨ããå¤æ°ã追å ããã²ã¼ã ãªã¼ãã¼ç¶æ ã§ã¯ã²ãããæ¶ããªãããã«ãã¾ãããã以ä¸ã½ã¼ã¹ã§ãï¼
Â
Â
isPlayingã¨ããboolåã®å¤æ°ã追å ãã¦ãã¾ããåæå¤ã¯trueãªã®ã§æ®éã«ã²ãããæ¶ããã¨ãã§ããç¶æ ã§ããããã¦ãUpdateã¡ã½ããå ã®å ¨ã¦ã®å¦çãif(isPlaying)ã§å²ããã¨ã§ãTimeScriptã«ã¦isPlayingãfalseã«ãããã¨ã«ãããã²ãããæ¶ããªãããã«ãã¦ããã¨ããããã§ãã
Â
ããã§ã¯æå¾ã«titleã·ã¼ã³ãä½æãã¾ãããã
titleã·ã¼ã³ã«ã¤ãã¦ã¯ä»¥ä¸ ã¨ãã»ã³ã¹ãåç §ãã¦ä½ã£ã¦ä¸ããã
Â
Â
ãçµæã
titleã·ã¼ã³ããmainã·ã¼ã³ã¸é·ç§»ãã²ã¼ã éå§ãæ´ã«å¶éæéããªã¼ãã¼ããã¨ã²ã¼ã ãªã¼ãã¼ç»é¢ã«ãªããã¯ãªãã¯ãããã¨ã§ã¿ã¤ãã«ã¸æ»ãã¨ããæµããè¦ã¦ã¿ã¾ãããã
Â
ã¿ã¤ãã«ã·ã¼ã³ãã
Â
ã²ã¼ã ç»é¢ã¸è¡ã
Â
ã²ã¼ã ãªã¼ãã¼ã¨ãªã
Â
ã¿ã¤ãã«ç»é¢ã¸æ»ã
Â
以ä¸ã§ã¤ãã¤ã風ã®ããºã«ã²ã¼ã ã¯çµããã«ãªãã¾ãã
ãããã¨ããããã¾ããã
Â
ãUnityéçº6ãä¸æºåãã¤ãã¤ã風1ã
ãUnityéçº6ãã²ãããçºçããããã¤ãã¤ã風2ã
ãUnityéçº6ãã²ããããªãã£ã¦æ¶ãããï¼ãã¤ãã¤ã風3ã
ãUnityéçº6ããªãã£ãã²ããã ãè²ãå¤ãããï¼ãã¤ãã¤ã風4ã
ãUnityéçº6ãã¹ã³ã¢æ©è½ãä»ãããï¼ãã¤ãã¤ã風5ã
ãUnityéçº6ãå¶éæéã¨ã²ã¼ã ãªã¼ãã¼ãå®è£ ãããï¼ãã¤ãã¤ã風7ã
Â