Unity¤Ë´ØÏ¢¤¹¤ëµ­»ö¤Ç¤¹

£±¡¥MVP ¥Ñ¥¿¡¼¥ó¤Ë¤è¤ëÀß·×


¡¡MVP ¥Ñ¥¿¡¼¥ó¤È¤Ï¡¢UI(GUI) ¼þ¤ê¤Ë´Ø¤¹¤ëÀß·×ÊýË¡¤Î£±¤Ä¤Ç¤¹¡£
ÈÑ»¨¤Ë¤Ê¤ê¤¬¤Á¤Ê½èÍý¤Ë¤Ä¤¤¤Æ¡¢ÌÀ³Î¤ÊÀÕ̳(Ìò³ä)¤ò»ý¤Ä¥¯¥é¥¹¤Ëʬ¤±¤Æ¼ÂÁõ¤ò¹Ô¤¦¤³¤È¤Ç¡¢
Á·ë¹ç²½¤·¤¿À߷פǤʤë¤Ù¤¯¤ï¤«¤ê¤ä¤¹¤¤·Á¤Ç¤Î UI ¼þ¤ê¤Î¼ÂÁõ¤ò¹Ô¤¦¡¢¤È¤¤¤¦¹Í¤¨Êý¤Ë¤Ê¤ê¤Þ¤¹¡£



¡¡MVP ¤È¤Ï¡¢À߷פËÍøÍѤµ¤ì¤ëÍ×ÁÇ(¥¯¥é¥¹)¤ÎƬʸ»ú¤Ç¤¢¤ê¡¢¤½¤ì¤¾¤ì¡¢M = Model¡¢V = View¡¢P= Presenter ¤È¤¤¤¦Ìò³ä¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£

¡¡Model ¤È¤Ï¥Ç¡¼¥¿¤Î¼ÂÂΤǤ¹¡£ÃͤòÊÝ»ý¤¹¤ë¤¿¤á¤ÎÊÑ¿ô¤Î´ÉÍý¤Ê¤É¤ò¼õ¤±»ý¤Á¤Þ¤¹¡£

¡¡View ¤È¤Ï¡¢UI ¤ÎÀ©¸æ¤ò¼õ¤±»ý¤ÄÉôʬ¤Ç¤¹¡£Model ¤Î´ÉÍý¤·¤Æ¤¤¤ë¥Ç¡¼¥¿¤ò²èÌ̤Ëɽ¼¨¤·¤¿¤ê¡¢¥Ü¥¿¥ó¤Ê¤É¤Î¥æ¡¼¥¶¡¼¤«¤é¤ÎÁàºî¤ò¼õ¤±¼è¤ëÉôʬ¤ò¼õ¤±»ý¤Á¤Þ¤¹¡£

¡¡Presenter ¤È¤Ï¡¢Model ¥¯¥é¥¹¤È View ¥¯¥é¥¹¤È¤ò¤Ä¤Ê¤²¤ëÃç²ð¼Ô¤Ç¤¹¡£
Presenter ¥¯¥é¥¹¤Î¤ß¤¬ Model ¥¯¥é¥¹¤È View ¥¯¥é¥¹¤Ø¤Î»²¾È¤ò»ý¤Ä·Á¤Ë¤¹¤ë¤³¤È¤Ç¡¢³Æ¥¯¥é¥¹¤ÎÁ·ë¹ç²½¤ò¼Â¸½¤·¤Æ¤¤¤Þ¤¹¡£



¡¡MVP ¥Ñ¥¿¡¼¥ó¤Î¼ÂÁõ¤Ë¤Ï¡¢UniRx ¤È¤¤¤¦Ìµ½þ¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ë¥é¥¤¥Ö¥é¥ê¤òÍøÍѤ·¤Þ¤¹¡£

¡¡Web ¥¢¥×¥ê¤Ê¤É¤òºîÀ®¤¹¤ëºÝ¤ËÍøÍѤµ¤ì¤Æ¤¤¤ë¼ÂÁõÊýË¡¤Ç¤¹¤¬¡¢UniRx ¤Î ReactiveProperty ¤Îµ¡Ç½¤òÍøÍѤ¹¤ë¤³¤È¤Ë¤è¤ê¡¢
UI ¤ÎÉôʬ¤Ë¤Ä¤¤¤Æ¤Ï¡¢Unity ¤Ë¤ª¤¤¤Æ¤â MVP ¥Ñ¥¿¡¼¥ó¤Ç¤Î¼ÂÁõ¤¬¹Ô¤¨¤Þ¤¹¡£
¡¡

£²¡¥¡ãUniRx ¤È¤Ï¡©¡ä


¡¡UniRx ¤È¤Ï¥ê¥¢¥¯¥Æ¥£¥Ö¥×¥í¥°¥é¥ß¥ó¥°¤È¤¤¤¦¹Í¤¨Êý¤ò Unity ¤ÇÍøÍѤǤ­¤ë¤è¤¦¤ËÀ߷פµ¤ì¤Æ¤¤¤ë¥é¥¤¥Ö¥é¥ê¤Ç¤¹¡£
ÈóƱ´ü½èÍý¤È¥¤¥Ù¥ó¥È½èÍý¤ËÂФ·¤Æ¸úΨŪ¤Ê¼ÂÁõÊýË¡¤òÄ󶡤¹¤ë¹½Â¤¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£

¡¡ÊØÍø¤«¤Ä¡¢¹âÅ٤ʽèÍý¤ò¼Â¸½¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¤¬¡¢³Ø½¬¥³¥¹¥È¤âÈó¾ï¤Ë¹â¤¤¤â¤Î¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
¤Þ¤¿³Ø½¬¤·¤¿¤«¤é¤È¤¤¤Ã¤Æ¡¢¤Ê¤ó¤Ç¤â¤³¤Î¹½Â¤¤Ë¤¹¤ì¤Ð¤¤¤¤¡¢¤È¤¤¤¦¤â¤Î¤Ç¤â¤¢¤ê¤Þ¤»¤ó¡£

¡¡C# ¤Î´ðÁäÀ¤±¤Ç¤Ï¤Ê¤¯¡¢Linq¡¢¥é¥à¥À¼°(¤ª¤è¤Ó¡¢¥á¥½¥Ã¥É¥Á¥§¡¼¥ó)¤È¤¤¤Ã¤¿µ¡Ç½¤âÍý²ò¤·¤Æ¤¤¤Ê¤¤¤È°·¤¦¤³¤È¤¬Æñ¤·¤¤¤¿¤á¡¢
¤³¤ì¤é¤Îµ¡Ç½¤Ë¤Ä¤¤¤Æ¤Þ¤ÀÍý²ò¤¬ÉÔ½½Ê¬¤Ç¤¢¤ë¾ì¹ç¤Ë¤Ï¡¢¤½¤Á¤é¤ò³Ø½¬¤·¤Æ¤«¤é¿Ê¤á¤ë¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£

¡¡UniRx ¤Ë¤Ä¤¤¤Æ¤Ïµ­»ö¤â¿¤¤¤Ç¤¹¤·¡¢»²¹Í¤È¤Ê¤ë½ñÀҤ⤢¤ê¤Þ¤¹¤Î¤Ç¡¢¤½¤Á¤é¤â¹ç¤ï¤»¤Æ³Ø½¬¤ò¹Ô¤¦¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£

¡¡¥¹¥¯¥ê¥×¥ÈÆâ¤Ç UniRx ¤òÍøÍѤ¹¤ë¾ì¹ç¡¢using UniRx; ¤ÎÀë¸À¤¬É¬Íפˤʤê¤Þ¤¹¡£


£³¡¥¡ã¥ª¥Ö¥¶¡¼¥Ð¡¼¥Ç¥¶¥¤¥ó¥Ñ¥¿¡¼¥ó¤òÍøÍѤ·¤¿À߷סä


¡¡UniRx ¤Ï¥Ç¥¶¥¤¥ó¥Ñ¥¿¡¼¥ó¤Î£±¤Ä¤Ç¤¢¤ë¡¢¥ª¥Ö¥¶¡¼¥Ð¡¼¥Ç¥¶¥¤¥ó¥Ñ¥¿¡¼¥ó¤È¤¤¤¦¤â¤Î¤ÇÀ߷פµ¤ì¤Æ¤¤¤Þ¤¹¡£

¡¡¶ñÂÎŪ¤Ë¤Ï¡¢¥¤¥Ù¥ó¥È(¥Ü¥¿¥ó¤Ê¤É)¤ò¼Â¹Ô¤·¤¿ºÝ¤Î½èÍý¤ò¡¢ÄÌÃΤ¹¤ë¦¡¢ÄÌÃΤò¼õ¤±¼è¤ë¦¡¢¤È¤¤¤¦³µÇ°¤òÍøÍѤ·¤Æ¼ÂÁõ¤ò¹Ô¤¦À߷פˤʤê¤Þ¤¹¡£

¡¡°Ê²¼¤Îµ­»ö¤ÏÈó¾ï¤Ë¤ï¤«¤ê¤ä¤¹¤¯¤Þ¤È¤á¤é¤ì¤Æ¤¤¤Þ¤¹¡£¤³¤Á¤é¤ò½ç¼¡Æɤ߹þ¤ó¤Ç¡¢Íý²ò¤ò¿¼¤á¤Æ¤¯¤À¤µ¤¤¡£
Qiita @toRisouP ÍÍ
UniRxÆþÌç ¤½¤Î1


£´¡¥¼ÂÁõÊýË¡


¡¡¤Ç¤Ïº£²ó¤Î¼ÂÁõÊýË¡¤Ï¡¢¤É¤Î¤è¤¦¤ËÍøÍѤ·¤Æ¤¤¤¯¤Î¤«¡¢¤É¤ó¤ÊÉôʬ¤ËÍøÅÀ¤¬¤¢¤ë¤Î¤«¤òÀâÌÀ¤·¤Þ¤¹¡£

¡¡¥²¡¼¥àÆâ¤Ë¤ª¤¤¤Æ¥¹¥³¥¢¤ÎÍ×ÁÇ(int ·¿ score ÊÑ¿ô)¤¬¤¢¤ë¤È¤·¤¿¾ì¹ç¡¢¤½¤ÎÃͤò¥²¡¼¥à²èÌ̤ËÈ¿±Ç¤¹¤ë¤¿¤á¤Ë¤Ï¡¢
Canvas ¤ËÇÛÃÖ¤·¤¿ UI (Text)Éôʬ¤Îɽ¼¨¹¹¿·¤ò¹Ô¤¦É¬Íפ¬¤¢¤ê¤Þ¤¹¡£¤½¤Î¾ì¹ç¤Ë¤Ï¡¢¼ç¤Ë°Ê²¼¤Î¤è¤¦¤Ê¼ê½ç¤Î½èÍý¤Ç¼ÂÁõ¤·¤Æ¤¤¤ë¤È»×¤¤¤Þ¤¹¡£

¡¡£±¡¥score ÊÑ¿ô¤ò´ÉÍý¤¹¤ë Score ¥¯¥é¥¹¤ËÂФ·¤Æ¡¢Ãͤò²Ã»»¤¹¤ë½èÍý¤ò¼Â¹Ô¤¹¤ë
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¢­
¡¡£²¡¥score ÊÑ¿ô¤ò¥²¡¼¥à²èÌ̤Ëɽ¼¨¤·¤Æ¤¤¤ë UI ´ÉÍýÍÑ¥¯¥é¥¹¤ËÂФ·¤ÆÌ¿Îá¤ò½Ð¤·¤Æ¡¢ Text ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤òÍøÍѤ·¤Æ¥²¡¼¥à²èÌ̤Υ¹¥³¥¢É½¼¨¤ò¹¹¿·¤¹¤ë

¡¡¤³¤Î¤¦¤Á¡¢£²¤Î½èÍý¤ò¥¯¥é¥¹´Ö¤Ç¤Î½èÍýÆâÍƤËÃÖ¤­´¹¤¨¤Þ¤·¤ç¤¦¡£

¡¡£²¡Ý£±¡¥Score ¥¯¥é¥¹¡¡(score ÊÑ¿ô¤ò¥²¡¼¥à²èÌ̤Ëɽ¼¨¤·¤Æ¤¤¤ë UI ´ÉÍýÍÑ¥¯¥é¥¹¤ËÂФ·¤ÆÌ¿Îá¤ò½Ð¤·¤Æ)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¢­
¡¡£²¡¼£²¡¥Text ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤ò´ÉÍý¤·¤Æ¤¤¤ë UI ´ÉÍý¥¯¥é¥¹¡¡(Text ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤òÍøÍѤ·¤Æ¥²¡¼¥à²èÌ̤Υ¹¥³¥¢É½¼¨¤ò¹¹¿·¤¹¤ë)

¡¡°Ê¾å¤Î¤³¤È¤è¤ê¡¢Score ¥¯¥é¥¹¤¬ UI ´ÉÍýÍѤΥ¯¥é¥¹¤È°Í¸´Ø·¸¤ò·ë¤ó¤Ç¡¢¤½¤Î¾ðÊó¤òÍøÍѤ·¤Æ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤·¤Æ¤¤¤ëή¤ì¤Ç¤¹¡£

¡¡¤³¤ÎÉôʬ¤Ë¡¢¥ª¥Ö¥¶¡¼¥Ð¡¼¥Ñ¥¿¡¼¥ó¤òÍøÍѤ·¤¿¾ì¹ç¡¢½èÍý¤Ï¼¡¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£

¡¡£±¡¥Score ¥¯¥é¥¹(Model)¤Ë ReactiveProperty ¤òÄêµÁ¤·¤Æ¡¢¤³¤ÎÊÑ¿ô¤Ç¥¹¥³¥¢¤ÎÃͤò´ÉÍý¤¹¤ë¡£ReactivePropery ¤ÎÊÑ¿ô¤ËÃͤò²Ã»»¤¹¤ë½èÍý¤ò¼Â¹Ô¤¹¤ë(²Ã»»¤Þ¤Ç¤Î½èÍý¤Îή¤ì¤ÏƱ¤¸)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¢­
¡¡£²¡¥ReactivePropery ¤ÎÃͤò¿·¤·¤¤ Presenter ¥¯¥é¥¹¤òºîÀ®¤·¤Æ¹ØÆÉ(´Æ»ë)¤µ¤»¤ë¡£
¡¡¡¡¡¡ReactivePropery ¤ÎÃͤ¬¹¹¿·¤µ¤ì¤ë¤¿¤Ó¤Ë¡¢UI ´ÉÍý¥¯¥é¥¹(View)¤ËÂФ·¤Æ¼«Æ°Åª¤ËÌ¿Îá¤ò½Ð¤·¤Æ¡¢¥²¡¼¥à²èÌ̤Îɽ¼¨¤ò¹¹¿·¤¹¤ë(°ÊÁ°¤È°ã¤¦Éôʬ)

¡¡¤É¤Á¤é¤â½èÍý¤Ï°ã¤¤¤Þ¤¹¤¬¡¢Â礭¤¯°Û¤Ê¤ë¤Î¤Ï¡¢£²¤ÎÉôʬ¤Ç¤¹¡£

¡¡ReactivePropery ¤òÍøÍѤ¹¤ë¤³¤È¤Ë¤è¤ê¡¢¤³¤ÎÃͤò³°Éô¥¯¥é¥¹(Presenter ¥¯¥é¥¹)¤«¤é¹ØÆÉ(´Æ»ë)¤¹¤ë½èÍý¤ò¼ÂÁõ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
¤³¤Î½èÍý¤Ë¤è¤ê¡¢°ÊÁ°¤Î¤è¤¦¤Ë¡¢Ãͤ¬¹¹¿·¤µ¤ì¤ë¤¿¤Ó¤Ë¡¢Score ¥¯¥é¥¹¤«¤é UI ´ÉÍý¥¯¥é¥¹¤ËÂФ·¤ÆÅÔÅÙ¡¢É½¼¨¹¹¿·¤ÎÌ¿Îá¤ò¹Ô¤¦¤Î¤Ç¤Ï¤Ê¤¯¡¢
ReactiveProperty ¤ÎÃͤξõÂÖ¤ò´Æ»ë(¹ØÆÉ)¤¹¤ë¾õ¶·¤ò¤Ä¤¯¤ê¡¢¤³¤ÎÃͤ¬¹¹¿·¤µ¤ì¤ë¤Î¤Ë¹ç¤ï¤»¤Æ¡¢¼«Æ°Åª¤Ë UI ¤Î¹¹¿·½èÍý¤ò¹Ô¤¦¤è¤¦¤Ë¤¹¤ë»ÅÁȤߤǤ¹¡£

¡¡¤½¤Î¤¿¤á¡¢ºÇ½é¤ËÃͤò´Æ»ë(¹ØÆÉ)¤¹¤ë½èÍý¤òºîÀ®¤·¡¢¤½¤ì¤È UI ¤Î¹¹¿·¤ò¹Ô¤¦½èÍý¤òɳ¤Å¤±¤·¤Æ¤ª¤±¤Ð¡¢¤¢¤È¤Ï²¿¤â¤·¤Ê¤¯¤Æ¤â¤è¤¤(¼«Æ°²½)¾õÂÖ¤òºî¤ê½Ð¤·¤Þ¤¹¡£


£µ¡¥MVP ¥Ñ¥¿¡¼¥ó¤Ë¤è¤ë¼ÂÁõÎã


¡¡¤½¤ì¤Ç¤Ï¡¢¼ÂºÝ¤Ë MVP ¥Ñ¥¿¡¼¥ó¤Ë¤è¤ëÀ߷פòÍøÍѤ·¤¿¡¢UI ɽ¼¨¹¹¿·µ¡Ç½¤ÎÀ½ºî¤ò¹Ô¤¤¤Þ¤¹¡£


£±¡¥Canvas ¤ÎºîÀ®


¡¡¤Þ¤º¤Ï Scene ¥Ó¥å¡¼¤Ë Canvas ¤òºîÀ®¤·¡¢Text ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Îµ¡Ç½¤òÍøÍѤ·¤Æ¡¢¥²¡¼¥à²èÌ̤˳ÍÆÀ¤·¤Æ¤¤¤ë¥¹¥³¥¢¤ÎÃͤòɽ¼¨¤µ¤»¤ë UI ¤òºîÀ®¤·¤Æ¤¯¤À¤µ¤¤¡£
¥µ¥¤¥º¤ä°ÌÃ֤ʤɤÏǤ°Õ¤Ç¤¹¡£


£²¡¥UniRx ¤Î¥¤¥ó¥¹¥È¡¼¥ë


¡¡Ìµ½þ¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ë¥é¥¤¥Ö¥é¥ê¤òÍøÍѤ·¤Þ¤¹¡£

¡¡Unity ¤Î¥¢¥»¥Ã¥È¥¹¥È¥¢¤Î¸¡º÷¤Ë¤Æ UniRx ¤ÈÆþÎϤ¹¤ë¤È¸¡º÷·ë²Ì¤È¤·¤Æɽ¼¨¤µ¤ì¤Þ¤¹¤Î¤Ç¡¢¤½¤Á¤é¤ò¥À¥¦¥ó¥í¡¼¥É¤·¤Æ Unity ¤Ë¥¤¥ó¥Ý¡¼¥È¤·¤Þ¤¹¡£
¤¢¤ë¤¤¤Ï²¼µ­¤Î¥ê¥ó¥¯¤«¤éľÀÜ»²¾È¤â½ÐÍè¤Þ¤¹¡£
UniRx
https://assetstore.unity.com/packages/tools/integr...


¥¢¥»¥Ã¥È¥¹¥È¥¢



£³¡¥Model ¥¯¥é¥¹¤ÎºîÀ®


¡¡Ãͤò´ÉÍý¤¹¤ëÌò³ä¤ò»ý¤Ä¥¯¥é¥¹¤Ç¤¹¡£


<= ¥¯¥ê¥Ã¥¯¤¹¤ë¤È³«¤­¤Þ¤¹¡£



£´¡¥View ¥¯¥é¥¹¤ÎºîÀ®


¡¡UI ɽ¼¨¤Î¹¹¿·¤òÀ©¸æ¤¹¤ë¤¿¤á¤Î View ¥¯¥é¥¹¤òºîÀ®¤·¤Þ¤¹¡£


<= ¥¯¥ê¥Ã¥¯¤¹¤ë¤È³«¤­¤Þ¤¹¡£




£µ¡¥Presenter ¥¯¥é¥¹¤ÎºîÀ®


¡¡Model ¥¯¥é¥¹¤È View ¥¯¥é¥¹¤òÃç²ð¤¹¤ë¤¿¤á¤Î Presenter ¥¯¥é¥¹¤òºîÀ®¤·¤Þ¤¹¡£

¡¡¥µ¥ó¥×¥ë½èÍý¤È¤·¤Æ¡¢¥Þ¥¦¥¹¤Îº¸¥¯¥ê¥Ã¥¯¤ò¤¹¤ëÅ٤ˡ¢Score ÊÑ¿ô¤ÎÃͤ¬²Ã»»¤µ¤ì¤ë¡¢¤È¤¤¤¦½èÍý¤òµ­½Ò¤·¤Æ¤¤¤Þ¤¹¡£


<= ¥¯¥ê¥Ã¥¯¤¹¤ë¤È³«¤­¤Þ¤¹¡£



£¶¡¥¡ãReactivePropery<T> ¡ä


¡¡ReactivePropery¡Ê¥ê¥¢¥¯¥Æ¥£¥Ö¥×¥í¥Ñ¥Æ¥£¡Ë¤Ï¡¢UniRx ¤Î»ý¤Äµ¡Ç½¤Î£±¤Ä¤Ç¤¹¡£
ÍøÍѤ¹¤ë¤Ë¤Ï using UniRx; ¤ÎÀë¸À¤¬É¬Íפˤʤê¤Þ¤¹¡£

  using UniRx;

  public ReactiveProperty<int> Score = new ReactiveProperty<int>(0);

¡¡¥×¥í¥Ñ¥Æ¥£¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¤¿¤á¡¢ÊÑ¿ô̾¤ÎƬʸ»ú¤ÏÂçʸ»ú¤ÇÄêµÁ¤·¤Æ¤¤¤Þ¤¹¡£



¡¡ReactivePropery ¤Ï¥¸¥§¥Í¥ê¥Ã¥¯·¿¤Ç¤¢¤ë¤¿¤á¡¢<T> ¤ÎÉôʬ¤Ë¤ÏǤ°Õ¤Î·¿¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£
º£²ó¤Ï score ÊÑ¿ô¤ÎÂå¤ï¤ê¤È¤Ê¤ë¤¿¤áƱ¤¸ int ·¿¤Ç¤¹¤¬¡¢¼«ºî¤·¤¿¥¯¥é¥¹(Î㤨¤Ð¡¢Ê£¿ô¤Î¥á¥ó¥ÐÊÑ¿ô¤ò»ý¤Ä¥¯¥é¥¹)¤Ê¤É¤ò»ØÄꤹ¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£

¡¡ReactivePropery ¤Ï Value ¥×¥í¥Ñ¥Æ¥£¤ò»ý¤Ã¤Æ¤ª¤ê¡¢¤³¤ÎÃæ¤Ë ReactivePropery ¤Î¾ðÊó¤¬ÂåÆþ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢ Value ¥×¥í¥Ñ¥Æ¥£¤òÍøÍѤ¹¤ë¤³¤È¤ÇÃͤò»²¾È¤·¤¿¤ê¡¢ÂåÆþ½èÍý¤ò¤·¤Æ¹¹¿·¤¹¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£
¡¡
¡¡º£²ó¤Ç¤¢¤ì¤Ð¡¢int ·¿¤ÎÀ°¿ô¤Î¾ðÊ󡢤¹¤Ê¤ï¤Á¡¢score ÊÑ¿ô¤ÎÂå¤ï¤ê¤È¤Ê¤ëÃͤ¬ÂåÆþ¤µ¤ì¤Æ¤¤¤ëÉôʬ¤¬ Value ¤Ë¤Ê¤ê¤Þ¤¹¡£
Ä̾ï¤Î¥×¥í¥Ñ¥Æ¥£¤Ë¤ª¤±¤ë¡¢set Æâ¤Ë¤¢¤ë value ¤ÈƱ¤¸Ìò³ä¤Ç¤¢¤ë¤È¸À¤¨¤Þ¤¹¡£


¡ãValue ¥×¥í¥Ñ¥Æ¥£¡ä
  Score.Value += amount;

¡¡Score.Value++;

  int x = Score.Value;


¡¡
¡¡¤â¤Ã¤È¤âÂ礭¤ÊÆÃħ¤È¤·¤Æ¡¢ReactivePropery ¤Ë¤Ï¡ÖÃͤ¬¹¹¿·¤µ¤ì¤ë¤ÈÄÌÃΤò¹Ô¤¦¡×¤È¤¤¤¦µ¡Ç½¤¬È÷¤ï¤Ã¤Æ¤¤¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢ReactivePropery ¤ÎÃͤ¬ 0 => 10 ¤È¤¤¤¦¤è¤¦¤ËÊѲ½¤ò¤¹¤ë¤È¡¢ReactivePropery ¤«¤éÄÌÃΤò¼õ¤±¼è¤ë(´Æ»ë¤¹¤ë)½èÍý¤ò»Ü¤¹¤³¤È¤Ç
¤³¤Î½èÍý¤ËÉտ路¤Æ¡¢¼«Æ°Åª¤Ë¥¤¥Ù¥ó¥È½èÍý¤òȯÀ¸¤µ¤»¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£

¡¡º£²ó¤Ï Score ¥¯¥é¥¹¤ËÍÑ°Õ¤·¤¿ ReactivePropery ¤ÎÃͤò¡¢Presenter ¥¯¥é¥¹Â¦¤Ë¤Æ´Æ»ë¤·¤Æ¤â¤é¤¦¤è¤¦¤ËÀ߷פ·¤Æ¤¤¤Þ¤¹¡£

¡¡ReactivePropery ¦¤¬¡ÖÄÌÃΤò¹Ô¤¦Â¦ = ȯ¹Ô¡×¤È¤¤¤¤¡¢ReactivePropery ¤ÎÃͤδƻë¤ò¹Ô¤¦Â¦¤ò¡ÖÄÌÃΤò¼õ¤±¼è¤ë¦ = ¹ØÆɡפȤ¤¤¤¤Þ¤¹¡£



¡¡ReactivePropery ¤«¤é¤ÎÄÌÃΤò¼õ¤±¼è¤ë¤¿¤á¤Ë¤Ï¡¢ÄÌÃΤò¼õ¤±¼è¤ê¤¿¤¤ ReactivePropery ¤ËÂФ·¤Æ¡¢Subscribe ¥á¥½¥Ã¥É¤ò¼ÂÁõ¤·¤Þ¤¹¡£
Subscribe ¥á¥½¥Ã¥É¤Ï°ú¿ôÆâ¤Ë¡¢½èÍý¤Î¼ÂÁõ¡¢¤¢¤ë¤¤¤Ï¥á¥½¥Ã¥É¤Î¸Æ¤Ó½Ð¤·½èÍý¤ò¼ÂÁõ¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢
¡ÖReactivePropery ¤ÎÃͤ¬¹¹¿·¤µ¤ì¤¿¤é¡¢Subscribe ¥á¥½¥Ã¥É¤Î°ú¿ô¤Ëµ­½Ò¤·¤Æ¤¢¤ë½èÍý¤ò¼«Æ°Åª¤ËËè²ó¼Â¹Ô¤¹¤ë¡×¤È¤¤¤¦½èÍý¤¬Æ°¤­¤Þ¤¹¡£

¡¡¤³¤Îµ¡Ç½¤Ë¤è¤Ã¤Æ¡¢¡Ö¤¢¤ë¾õÂ֤ˤʤ俤Ȥ­¤Ë¡¢»ØÄꤷ¤Æ¤¢¤ë½èÍý¤ò¼Â¹Ô¤¹¤ë¡×¤È¤¤¤¦¥¤¥Ù¥ó¥È½èÍý¤ò¼ÂÁõ¤¹¤ë¤³¤È¤¬½ÐÍè¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£


  modelScore.Subscribe(x => view.UpdateDisplayCount(x))

¡¡Subscribe ¥á¥½¥Ã¥É¤Ï¥é¥à¥À¼°¤Ç½èÍý¤òµ­½Ò¤·¤Þ¤¹¡£°ú¿ô¤òÍøÍѤ·¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢(_ => ) ¤È¥¢¥ó¥À¡¼¥Ð¡¼¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£

¡¡º£²ó¤Î Subscribe ¥á¥½¥Ã¥É¤Î½èÍý¤Ï¡Ú x => view.UpdateDisplayCount(x) ¡Û¤Ç¤¹¤Î¤Ç¡¢
''ReactivePropery ¤ÎÃÍ(Score ÊÑ¿ô)¤¬Êѹ¹¤Ë¤Ê¤Ã¤¿¤é¡¢¤½¤ÎÅÔÅÙ¡¢View ¥¯¥é¥¹¤Î UpdateDisplayCount ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤·¤Þ¤¹¡£
¤½¤ÎºÝ¤Î°ú¿ô(º£²ó¤Ï x ÊÑ¿ô)¤Ë¤Ï Score ÊÑ¿ô¤ÎºÇ¿·¤ÎÃͤ¬ÍøÍѤµ¤ì¤Þ¤¹¡£

¡¡¤½¤Î¤¿¤áº£²ó¤Î¼ÂÁõ¤Ç¤Ï¡¢¥¹¥³¥¢ÍѤÎÃͤò¹¹¿·¤·¤¿¤¢¤È¤Ë¡¢¼êÆ°¤Ç UI ɽ¼¨¤ò¹¹¿·¤¹¤ë¤È¤¤¤¦½èÍý¤¬¤Ê¤¯¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢
¤³¤Î ReactivePropery ¤Îµ¡Ç½¤Ë¤è¤Ã¤Æ¡¢¤¤¤Þ¤Þ¤Ç¤ÈƱ¤¸½èÍý¤ò¼«Æ°Åª¤ËÆ°ºî¤¹¤ë¤è¤¦¤Ëµ¡Ç½¤òºî¤Ã¤Æ¤¤¤Þ¤¹¡£¤³¤³¤¬Â礭¤Ê°ã¤¤¤Ë¤Ê¤ê¤Þ¤¹¡£

¡¡¼ÂÁõ¤·¤¿¥×¥í¥°¥é¥à¤òÆɤßľ¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
²èÌ̤Îɽ¼¨¤ò¹¹¿·¤¹¤ë½èÍý¤Ï¡¢Presenter ¥¯¥é¥¹¤Î Start ¥á¥½¥Ã¥É¤Ç£±²ó¼Â¹Ô¤µ¤ì¤Æ¤¤¤ë¤À¤±¤Ç¤¢¤ë¤³¤È¤¬Ê¬¤«¤ë¤È»×¤¤¤Þ¤¹¡£



¡¡¤â¤¦£±¤ÄÂçÀڤʤ³¤È¤¬¤¢¤ê¤Þ¤¹¡£¤³¤Î ReactiveProperty ¤Î Subscribe(¹ØÆÉ)¤Î½èÍý¤Ï¡¢¼Â¹Ô¤·¤Æ¤¤¤ë¥¹¥¯¥ê¥×¥È¤¬ÇË´þ¤µ¤ì¤Æ¤â¡¢½èÍý¤Î¤ß¤¬»Ä¤ê³¤±¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢Å¬Àڤʥ¿¥¤¥ß¥ó¥°(¥¹¥¯¥ê¥×¥È¤Î¥¢¥¿¥Ã¥Á¤·¤Æ¤¤¤ë¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤ÎÇË´þ¤Ê¤É)¤Ë¹ç¤ï¤»¤Æ¡¢Subscribe ¤Î½èÍý¤âÇË´þ¤µ¤»¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£

¡¡¤³¤ÎÇË´þ¤µ¤»¤ë½èÍý¤ò˺¤ì¤Æ¤·¤Þ¤¦¤È¡¢Î¢Â¦¤Ç±Ê³Ū¤Ë½èÍý¤¬Æ°¤¤¤Æ¤·¤Þ¤¦¤³¤È¤Ë¤Ê¤ê¡¢¥á¥â¥ê¥ê¡¼¥¯¤Î¸¶°ø¤È¤Ê¤ê¤Þ¤¹¡£

¡¡ÇË´þ¤µ¤»¤ë¤Ë¤Ï Dispose ¥á¥½¥Ã¥É¤òÍøÍѤ·¡¢ÌÀ¼¨Åª¤ËÇË´þ¤·¤Þ¤¹¡£
¤¢¤ë¤¤¤Ï Subscribe ¤µ¤»¤ë¤È¤­¤Ë AddTo ¥á¥½¥Ã¥É¤òµ­½Ò¤¹¤ë¤³¤È¤Ç¡¢¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤ÎÇË´þ¤Î¥¿¥¤¥ß¥ó¥°¤Ë Dispose ¥á¥½¥Ã¥É¤òɳ¤Å¤±¤Æ¤ª¤¯¤³¤È¤¬½ÐÍè¤Þ¤¹¡£
Ää¤á˺¤ì¤ò¤·¤Ê¤¤¤¿¤á¤Ë¤â¡¢Í½¤á¡¢¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤ÎÇË´þ¤Î¥¿¥¤¥ß¥ó¥°¤Ëɳ¤Å¤±¤Æ¤ª¤¯ÊýË¡¤¬°ÂÁ´¤Ç¤¹¡£


£¶¡¥ÂçÀڤʤ³¤È


¡¡¤³¤Î¶µºà¤Ç¤Ï¡¢MVP¥Ñ¥¿¡¼¥ó¤Ë¤è¤ë¼ÂÁõ¤ò¹Ô¤¤¡¢¤½¤Î½èÍý¤ÎÆ°¤­¤òÂ賤·¤Æ¤¤¤¿¤À¤­¤Þ¤·¤¿¡£

¡¡¤¿¤À¤·¡¢ËÜÅö¤Ë½ÅÍפʤΤϡ¢Æ°¤¤¤¿¡¢¤³¤È¤Ç¤Ï¤Ê¤¯¤Æ¡¢¤É¤¦¤·¤Æ¤½¤Î¤è¤¦¤ÊÆ°¤­¤Ë¤Ê¤ë¤Î¤«¡¢¤ò¼«Ê¬¤Ç¹Í¤¨¤Æ¤¤¤¯¤è¤¦¤Ë¤¹¤ë¤³¤È¤Ç¤¹¡£
¤½¤Î¤¿¤á¤Ë¤Ï¡¢ReactiveProperty ¤ò¹½À®¤·¤Æ¤¤¤ë UniRx ¼«ÂΤε¡Ç½¤ò¤·¤Ã¤«¤ê¤ÈÍý²ò¤·¤Æ¤¤¤¯É¬Íפ¬¤¢¤ê¤Þ¤¹¡£

¡¡Æñ¤·¤¤µ¡Ç½¤Î¾ì¹ç¤Ë¤Ï¡¢¤³¤Î¤è¤¦¤Ê¸åÄɤ¤³Ø½¬¤ÎÊý¤¬Íý²ò¤¬Áᤤ¥±¡¼¥¹¤â¤¢¤ê¤Þ¤¹¡£
¤Þ¤º¤Ï¼ÂºÝ¤Ë½èÍý¤òÆ°¤«¤·¤Æ¤ß¤Æ¡¢½èÍý¤ò²þ¤¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£

¡¡¤½¤·¤Æ¡¢UniRx ¤Î¹½Â¤¡¢¥ª¥Ö¥¶¡¼¥Ð¡¼¥Ñ¥¿¡¼¥ó¤Ë¤Ä¤¤¤Æ¡¢³Ø½¬¤ò¤·¤Æ¤¤¤¯¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£



¡¡°Ê¾å¤Ë¤Ê¤ê¤Þ¤¹¡£

¥³¥á¥ó¥È¤ò¤«¤¯


¡Öhttp://¡×¤ò´Þ¤àÅê¹Æ¤Ï¶Ø»ß¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

ÍøÍѵ¬Ìó¤ò¤´³Îǧ¤Î¤¦¤¨¤´µ­Æþ²¼¤µ¤¤

Menu


´ðÁÃ

µ»½Ñ/Ãμ±(¼ÂÁõÎã)

3D¥¢¥¯¥·¥ç¥ó¥²¡¼¥à

2D¤ª¤Ï¤¸¤­¥²¡¼¥à(ȯŸÊÔ)

2D¶¯À©²£¥¹¥¯¥í¡¼¥ë¥¢¥¯¥·¥ç¥ó(ȯŸÊÔ)

2D¥¿¥Ã¥×¥·¥å¡¼¥Æ¥£¥ó¥°(³ÈÄ¥ÊÔ)

¥ì¡¼¥¹¥²¡¼¥à(È´¿è)

2DÊüÃÖ¥²¡¼¥à(ȯŸÊÔ)

3D¥ì¡¼¥ë¥¬¥ó¥·¥å¡¼¥Æ¥£¥ó¥°(±þÍÑÊÔ)

3Dæ½Ð¥²¡¼¥à(È´¿è)

2D¥ê¥¢¥ë¥¿¥¤¥à¥¹¥È¥é¥Æ¥¸¡¼

3D¥¿¥Ã¥×¥¢¥¯¥·¥ç¥ó(NavMeshAgent »ÈÍÑ)

2D¥È¥Ã¥×¥Ó¥å¡¼¥¢¥¯¥·¥ç¥ó(¥«¥¨¥ë¤Î°Ù¤Ë¡Á¡¢¥Ü¥³¥¹¥«¥¦¥©¡¼¥ºÉ÷)

VideoPlayer ¥¤¥Ù¥ó¥ÈϢư¤Î¼ÂÁõÎã

VideoPlayer ¥ê¥¹¥ÈÆ⤫¤é¥à¡¼¥Ó¡¼ºÆÀ¸¤Î¼ÂÁõÎã(ȯŸ)

AR ²èÁüÉÕ¤­¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¤Î¼ÂÁõÎã

AR ¥ê¥¹¥ÈÆ⤫¤éÀ¸À®¤Î¼ÂÁõÎã(ȯŸ)

2D¥È¥Ã¥×¥Ó¥å¡¼¥¢¥¯¥·¥ç¥ó(¥µ¥Ð¥¤¥Ð¡¼É÷)

private



¤³¤Î¥µ¥¤¥ÈÆâ¤ÎºîÉʤϥæ¥Ë¥Æ¥£¤Á¤ã¤ó¥é¥¤¥»¥ó¥¹¾ò¹à¤Î¸µ¤ËÄ󶡤µ¤ì¤Æ¤¤¤Þ¤¹¡£

´ÉÍý¿Í/Éû´ÉÍý¿Í¤Î¤ßÊÔ½¸¤Ç¤­¤Þ¤¹