ºÇ½ª¹¹¿·¡§ orika_ex_miyako 2023ǯ05·î29Æü(·î) 12:00:01ÍúÎò
¡¡·¿ÊÑ´¹¤È¤Ï¡¢¤¢¤ë¥Ç¡¼¥¿·¿¤«¤éÊ̤Υǡ¼¥¿·¿¤Ø¤ÎÊÑ´¹¤ò»Ø¤·¤Þ¤¹¡£
¡¡Î㤨¤Ðɹ¡Êsolid¡§¸ÇÂΡˤò¿å¡Êliquid¡§±ÕÂΡˤËÊѤ¨¤ë¤è¤¦¤Ê¤â¤Î¤Ç¤¹¡£
¤³¤ÎÊÑ´¹¤Ï³°¸«¤òÊѤ¨¤ë¤À¤±¤Ç¤Ê¤¯¡¢¤½¤ÎÀ¼Á¡Ê¤³¤³¤Ç¤Ï¾õÂ֡ˤâÊѤï¤ê¤Þ¤¹¡£
¥×¥í¥°¥é¥ß¥ó¥°¤Ç¤âƱÍͤˡ¢°ì¤Ä¤Î¥Ç¡¼¥¿·¿¤«¤éÊ̤Υǡ¼¥¿·¿¤ËÊÑ´¹¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£
¡¡¤³¤ì¤¬¡Ö·¿ÊÑ´¹¡×¤Î´ðËÜŪ¤Ê³µÇ°¤Ç¤¹¡£
¡¡Unity ¤Ç¤¢¤ì¤Ð¡¢Æ±¤¸¿ô»ú¤Ç¤¢¤ê¤Þ¤¹¤¬¡¢°·¤¦·¿¤¬°Û¤Ê¤ë¤¿¤á¡¢
À°¿ô·¿¡Êint¡Ë¤Î¥Ç¡¼¥¿¤òÉâÆ°¾®¿ôÅÀ·¿¡Êfloat¡Ë¤ËÊÑ´¹¤·¤¿¤ê¡¢¤½¤ÎµÕ¤ò¹Ô¤Ã¤¿¤ê¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£
¡¡°ÅÌÛŪ¤ÊÊÑ´¹¤Ï¡¢¥×¥í¥°¥é¥à¤¬¼«Æ°Åª¤Ë·¿ÊÑ´¹¤ò¹Ô¤¦¤â¤Î¤Ç¤¹¡£¾ðÊó¤Î»¼º¤¬¤Ê¤¤¾ì¹ç¡¢¤Ä¤Þ¤ê°ÂÁ´¤Ê¾ì¹ç¤Ë¹Ô¤ï¤ì¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢ÆÃÊ̤˲¿¤«¤òµ½Ò¤¹¤ëɬÍפϤʤ¯¡¢¼«Æ°Åª¤Ë·¿¤ÎÊÑ´¹¤¬¹Ô¤ï¤ì¤Þ¤¹¡£
¡¡°Ê²¼¤Î¥³¡¼¥É¤Ç¤Ï int ·¿¤«¤é float ·¿¤Ø¤Î°ÅÌÛŪ¤ÊÊÑ´¹¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£
int myInt = 10; float myFloat = myInt; // °ÅÌÛŪ¤ÊÊÑ´¹¡ long myLong = myInt; // °ÅÌÛŪ¤ÊÊÑ´¹¢
¡¡¤³¤ÎÎã¤Ç¤Ï¡¢myInt ¤«¤émyFloat ¤È MyLong ¤Ø¤Î¤Ï¼«Æ°Åª¤Ë¹Ô¤ï¤ì¤Þ¤¹¡£
¤Ê¤¼¤Ê¤é¡¢int¤«¤é float ¤ä long¤Ø¤ÎÊÑ´¹¤Ï¡¢¾ðÊó¤Î»¼º¤¬¤Ê¤¤¤«¤é¤Ç¤¹¡£
¡¡¤³¤ì¤é¤Ïº¸Êդȱ¦Êդη¿¤¬°Û¤Ê¤ê¤Þ¤¹¤¬¡¢¾ðÊó¤Î»¼º¤¬¤Ê¤¤¤¿¤á¼«Æ°Åª¤Ë·¿¤ÎÊÑ´¹¤¬¹Ô¤ï¤ì¤ë¡¢°ÅÌÛŪ¤ÊÊÑ´¹¤Îµ¡Ç½¤Ë¤è¤ëÂåÆþ½èÍý¤Ç¤¹¡£
¡¡·¿¤ËÃÖ¤´¹¤¨¤Æ¤ß¤ë¤È¡¢¤è¤¯Ê¬¤«¤ê¤Þ¤¹¡£
int myInt = 10; float = int; // °ÅÌÛŪ¤ÊÊÑ´¹¡ long = int; // °ÅÌÛŪ¤ÊÊÑ´¹¢
¡¡º¸Êդȱ¦Êդη¿¤¬°Û¤Ê¤ê¤Þ¤¹¤¬¡¢°ÅÌÛŪ¤ÊÊÑ´¹¤Ë¤è¤ê¡¢ÂåÆþ½èÍý¤¬À®Î©¤·¤Æ¤¤¤Þ¤¹¡£
¡¡°ìÊý¡¢ÌÀ¼¨Åª¤ÊÊÑ´¹¤Ï¡¢¥×¥í¥°¥é¥Þ¡¼¤¬ÌÀ³Î¤Ë·¿ÊÑ´¹¤ò»Ø¼¨¤¹¤ë¤â¤Î¤Ç¤¹¡£¤³¤ì¤ò¥¥ã¥¹¥È¤È¸Æ¤Ó¤Þ¤¹¡£
ÌÀ¼¨Åª¤ÊÊÑ´¹(¥¥ã¥¹¥È)¤Ï¡¢¾ðÊó¤Î»¼º¤¬µ¯¤³¤êÆÀ¤ë¾ì¹ç¤Ë»ÈÍѤ·¤Þ¤¹¡£
¡¡¥¥ã¥¹¥È¤Ë¤Ï (T)E ¤È¤¤¤¦½ñ¼°¤¬¤¢¤ê¤Þ¤¹¡£
(T) ¤ËÊÑ´¹¤·¤¿¤¤·¿¡¢E ¤ËÊÑ´¹¸µ¤Ë¤Ê¤ëÊÑ¿ô¤òµ½Ò¤·¤Þ¤¹¡£
¡¡°Ê²¼¤Î¥³¡¼¥É¤Ç¤Ï float ·¿¤«¤é int ·¿¤Ø¤ÎÌÀ¼¨Åª¤ÊÊÑ´¹(¥¥ã¥¹¥È)¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£
float myFloat = 10.5f; int myInt = (int)myFloat;
¡¡(int) ¤ÎÉôʬ¤¬¥¥ã¥¹¥È¤Î½ñ¼°¤Ë¤ª¤±¤ë (T) ¤Ç¤¹¡£
¤Þ¤¿ myFloat ¤ÎÉôʬ¤¬¥¥ã¥¹¥È¤Î½ñ¼°¤Ë¤ª¤±¤ë E ¤òɽ¤·¤Æ¤¤¤Þ¤¹¡£
¡¡¤³¤Î¥¥ã¥¹¥È¤Ë¤è¤ê myFloat ¤ÎÃͤ¬ int ·¿¤ËÊÑ´¹¤µ¤ì¡¢¾®¿ôÉôʬ¤¬ÀÚ¤ê¼Î¤Æ¤é¤ì¤Þ¤¹¡£
¤³¤ì¤¬¾ðÊó¤Î»¼º¤Ç¤¹¡£ËÜÍè¤Ç¤¢¤ì¤Ð»ý¤Ã¤Æ¤¤¤¿¤Ï¤º¤Î¾®¿ôÉôʬ¤Î¾ðÊó¤¬Ìµ¤¯¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤Í¡£
¡¡°ÅÌÛŪ¤ÊÊÑ´¹¤È¤Ï°Û¤Ê¤ê¡¢¥×¥í¥°¥é¥Þ¡¼¤¬½èÍý¤È¤·¤Æ¥¥ã¥¹¥È¤Î½ñ¼°¤òµ½Ò¤·¤ÆÊÑ´¹¤ò»ØÄꤹ¤ë¤¿¤á¡¢¡ÖÌÀ¼¨Åª¤ÊÊÑ´¹¡×¤Èɽ¸½¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¡¡¤½¤ì¤Ç¤Ï¡¢¼ÂºÝ¤Î¥³¡¼¥ÉÃæ¤Ç¥¥ã¥¹¥È¤¬¤É¤Î¤è¤¦¤Ë»È¤ï¤ì¤ë¤«¸«¤Æ¤ß¤Þ¤·¤ç¤¦¡£
¤³¤Î¥±¡¼¥¹¤Ç¤Ï¡¢°Û¤Ê¤ë¥Ç¡¼¥¿·¿´Ö¤Ç±é»»¤ò¹Ô¤¦ºÝ¤Ë¥¥ã¥¹¥È¤¬ÍøÍѤµ¤ì¤Æ¤¤¤Þ¤¹¡£
int totalItems = 9; int itemsPurchased = 2; // ¥¥ã¥¹¥È¤Ê¤·¤Ç·×»» int percentPurchasedWithoutCast = itemsPurchased / totalItems * 100; Debug.Log("¥¥ã¥¹¥È¤Ê¤·: " + percentPurchasedWithoutCast); // ¥¥ã¥¹¥È¤¢¤ê¤Ç·×»» float percentPurchasedWithCast = (float)itemsPurchased / totalItems * 100; Debug.Log("¥¥ã¥¹¥È¤¢¤êt: " + percentPurchasedWithCast);
¡¡¤Þ¤º¥¥ã¥¹¥È¤Ê¤·¤Ç¥Ñ¡¼¥»¥ó¥Æ¡¼¥¸¤ò·×»»¤·¡¢¤½¤Î·ë²Ì¤ò¥í¥°¤Ë½ÐÎϤ·¤Æ¤¤¤Þ¤¹¡£
¤½¤Î¸å¡¢¥¥ã¥¹¥È¤ò¹Ô¤Ã¤Æ¥Ñ¡¼¥»¥ó¥Æ¡¼¥¸¤òºÆ·×»»¤·¡¢¤½¤Î·ë²Ì¤ò¥í¥°¤Ë½ÐÎϤ·¤Æ¤¤¤Þ¤¹¡£
¡¡¤³¤Î¥³¡¼¥É¤ò¼Â¹Ô¤¹¤ë¤È¡¢"¥¥ã¥¹¥È¤Ê¤·" ¤Î½ÐÎÏ¤Ï 0 ¤È¤Ê¤ê¤Þ¤¹¡£
¤³¤ì¤Ï itemsPurchased / totalItems ¤¬À°¿ô·¿¤Ç·×»»¤µ¤ì¡¢¤½¤Î·ë²Ì¤¬ 0¡Ê¾®¿ôÅÀ°Ê²¼¤ÏÀÚ¤ê¼Î¤Æ¤é¤ì¤ë¡Ë¤Ë¤Ê¤ë¤¿¤á¤Ç¤¹¡£
¡¡°ìÊý¡¢"¥¥ã¥¹¥È¤¢¤ê" ¤Î½ÐÎÏ¤Ï 22.2222222 ¤È¤Ê¤ê¤Þ¤¹¡£
¤³¤ì¤Ï itemsPurchased ¤¬ float ¤Ë¥¥ã¥¹¥È¤µ¤ì¡¢¤½¤Î·ë²Ì¡¢¾®¿ôÅÀ°Ê²¼¤Î¾ðÊó¤¬ÊÝ»ý¤µ¤ì¤ë¤¿¤á¤Ç¤¹¡£
¡¡¤³¤Î¤è¤¦¤Ë C#¤Ç¤Ï¡¢Æ±¤¸·¿¤ÎÃÍƱ»Î¤Ç³ä¤ê»»¤ò¹Ô¤¦¤È¡¢·ë²Ì¤â¤½¤Î·¿¤Ë¤Ê¤ê¤Þ¤¹¡£
¤Ä¤Þ¤ê¡¢À°¿ôƱ»Î¤Î³ä¤ê»»¤ÏÀ°¿ô¤Î·ë²Ì¤òÀ¸¤à¤Î¤Ç¡¢¾®¿ôÅÀ°Ê²¼¤Î¾ðÊ󤬼º¤ï¤ì¤Æ¤·¤Þ¤¤¤Þ¤¹¡£
¡¡¤½¤Î¤¿¤á¡¢¤³¤³¤Ç¤Ï itemsPurchased ¤ò float ¤Ë¥¥ã¥¹¥È¤¹¤ë¤³¤È¤Ç¡¢Àµ³Î¤Ê¥Ñ¡¼¥»¥ó¥Æ¡¼¥¸¤òµá¤á¤Æ¤¤¤Þ¤¹¡£
¡¡ToString¥á¥½¥Ã¥É¤Ï¡¢C#¤Î¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿·¿¤Ç»ÈÍѤǤ¤ë¥á¥½¥Ã¥É¤Ç¤¹¡£
¡¡»ØÄꤷ¤¿ÊÑ¿ô¤Î·¿¤òʸ»úÎó·¿(string)¤ËÊÑ´¹¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
int myInt = 10; string myString = myInt.ToString(); // "10"¤È¤¤¤¦Ê¸»úÎó¤Ë¤Ê¤ê¤Þ¤¹ double myDouble = 9.78; string myDoubleString = myDouble.ToString(); // "9.78"¤È¤¤¤¦Ê¸»úÎó¤Ë¤Ê¤ê¤Þ¤¹
¡¡¤³¤ÎÊýË¡¤Ï¡¢¿ôÃͤòʸ»úÎó¤È¤·¤Æɽ¼¨¤·¤¿¤¤¾ì¹ç¤ä¡¢¿ôÃͤòʸ»úÎóÁàºî¤ÎÂоݤȤ·¤¿¤¤¾ì¹ç¤ËÆäËÊØÍø¤Ç¤¹¡£
UI ¤Ë¿ôÃͤòʸ»úÎó¤È¤·¤Æɽ¼¨¤·¤¿¤¤¾ì¹ç¤ËÍøÍѤ¹¤ë¥±¡¼¥¹¤¬Â¿¤¤¤Ç¤·¤ç¤¦¡£
¡¡°Ê¾å¤¬·¿ÊÑ´¹¤È¥¥ã¥¹¥È¤Î´ðËÜŪ¤ÊÀâÌÀ¤È¤Ê¤ê¤Þ¤¹¡£
¡¡Æä˥¥ã¥¹¥È¤ÏC#¥×¥í¥°¥é¥ß¥ó¥°¤Ë¤ª¤¤¤ÆÉÑÈˤËÍѤ¤¤é¤ì¤ë³µÇ°¤Ç¤¹¤Î¤Ç¡¢¤½¤Î»È¤¤Êý¤òÍý²ò¤·¤Æ¤ª¤¯¤³¤È¤ÏÈó¾ï¤Ë½ÅÍפǤ¹¡£
¤·¤«¤·¡¢¥¥ã¥¹¥È¤Ë¤è¤Ã¤Æ¾ðÊó¤Î»¼º¤¬È¯À¸¤¹¤ë²ÄǽÀ¤¬¤¢¤ë¤Î¤Ç¡¢¤½¤ì¤ò¾ï¤Ë°Õ¼±¤·¤Æ»ÈÍѤ¹¤ë¤³¤È¤¬µá¤á¤é¤ì¤Þ¤¹¡£
¡¡³Ð¤¨¤Æ¤ª¤¯¤ÈÊØÍø¤Êµ¡Ç½¤Î£±¤Ä¤Ç¤¹¤Î¤Ç¡¢À§È󡢼ºݤ˳èÍѤ·¤Æ¼«Ê¬¤Î¥¹¥¥ë¤È¤·¤Æ¿È¤Ë¤Ä¤±¤Æ¤¤¤Ã¤Æ¤¯¤À¤µ¤¤¡£
- ¥«¥Æ¥´¥ê¡§
- ¿Ê³Ø/¥¹¥¯¡¼¥ë
- ¥×¥í¥°¥é¥ß¥ó¥°
¥³¥á¥ó¥È¤ò¤«¤¯