ºÇ½ª¹¹¿·¡§ orika_ex_miyako 2021ǯ12·î16Æü(ÌÚ) 17:43:37ÍúÎò
¡¡LineRenderer ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤òÍøÍѤ·¡¢Ray ¤Ë¹ç¤ï¤»¤Æ¥é¥¤¥ó(¥Ý¥¤¥ó¥¿¡½)¤òÉÁ²è¤¹¤ëµ¡Ç½¤ò¼ÂÁõ¤·¤Þ¤¹¡£
¤³¤Î¥Ý¥¤¥ó¥¿¡¼¤¬¿¯Æþ¤·¤¿¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ë EventBase ¥¯¥é¥¹¤¬¥¢¥¿¥Ã¥Á¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢
¤½¤Î¥¯¥é¥¹¤ò¼èÆÀ¤·¤Æ¡¢TriggerEvent ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤·¡¢¥¤¥Ù¥ó¥È¤òȯ²Ð¤µ¤»¤Þ¤¹¡£
¡¡LineRenderer ¤Ë¤è¤Ã¤ÆÉÁ²è¤µ¤ì¤¿¥é¥¤¥ó¤Ï¼«Æ°Åª¤Ë¤Ïºï½ü¤µ¤ì¤Ê¤¤¤¿¤á¡¢
°ìÄê»þ´Ö¤¬·Ð²á¤·¤¿¤éºï½ü¤¹¤ë¤è¤¦¤Ë¤·¤Æ¤¤¤Þ¤¹¡£
¡¡¥é¥¤¥ó¤ÎÂÀ¤µ¤ò¥¹¥¯¥ê¥×¥ÈÆâ¤ÇÀ©¸æ¤·¤Æ¤¤¤Þ¤¹¡£
³ÆÀ©¸æÃÍ¤Ï private ½¤¾þ»Ò¤Ç¤¹¤¬¡¢¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤è¤êÀßÄêÃͤòÊѹ¹¤·¤¿¤¤¾ì¹ç¤Ë¤Ï SerializeField °À¤òÉÕÍ¿¤·¤Æ¤¯¤À¤µ¤¤¡£
¡¡
LaserPointerController .cs
¡¡Line Renderer (¥é¥¤¥ó¥ì¥ó¥À¥é¡¼) ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Ï¡¢¶õ´Ö¤Î£²¤Ä°Ê¾å¤ÎÅÀ¤ÎÇÛÎó¤ò¤È¤ë¤³¤È¤Ç¡¢¤½¤ì¤¾¤ì¤Î´Ö¤ËľÀþ¤òÉÁ¤¤Þ¤¹¡£
»²¹Í¥µ¥¤¥È
Unity ¸ø¼°¥Þ¥Ë¥å¥¢¥ë
LineRenderer
https://docs.unity3d.com/ja/current/Manual/class-L...
Unity ¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
LineRenderer
https://docs.unity3d.com/jp/current/ScriptReferenc...
¡¡º£²ó¼ÂÁõ¤·¤Æ¤¤¤ëÊÑ¿ô¤ä¥á¥½¥Ã¥É¤Ë¤Ä¤¤¤Æ¤Þ¤È¤á¤Æ¤ª¤¤Þ¤¹¡£
ɬ¤º¼«Ê¬¤Ç¤âÄ´¤Ù¤Æ¡¢¼«Ê¬¤ÎÃμ±¤È¤·¤ÆµÛ¼ý¤·¤Æ¤ª¤¤¤Æ¤¯¤À¤µ¤¤¡£
¡¡LineRenderer ¤ÇÉÁ²è¤¹¤ë¥é¥¤¥ó¤ÎÉý¤Î¥¹¥¿¡¼¥È¤Î¥µ¥¤¥º¤òÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤¤ëÊÑ¿ô¤Ç¤¹¡£
»²¹Í¥µ¥¤¥È
Unity ¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
LineRenderer.startWidth
https://docs.unity3d.com/jp/current/ScriptReferenc...
¡¡LineRenderer ¤ÇÉÁ²è¤¹¤ë¥é¥¤¥ó¤ÎÉý¤ÎºÇ¸å¤Î¥µ¥¤¥º¤òÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤¤ëÊÑ¿ô¤Ç¤¹¡£
»²¹Í¥µ¥¤¥È
Unity ¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
LineRenderer.endWidth
https://docs.unity3d.com/jp/current/ScriptReferenc...
¡¡¤³¤ì¤é¤Î¾¤Ë¤â¡¢¿§¤òÊѹ¹¤¹¤ëÊÑ¿ô¤ä¡¢¶ÊÀþ¤òÉÁ¤¯¤¿¤á¤ÎÊÑ¿ô¤Ê¤É¤âÍÑ°Õ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¡¡¥é¥¤¥ó¤ÎĺÅÀ¤Î°ÌÃÖ¤òÀßÄꤹ¤ë¥á¥½¥Ã¥É¤Ç¤¹¡£¤³¤Î½èÍý¤Ë¤è¤Ã¤ÆÉÁ²è½èÍý¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£
£²¤Ä¤Î SetPosition ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Ç¡¢A ÃÏÅÀ¤«¤é BÃÏÅÀ¤È¤¤¤¦·Á¼°¤Ç¡¢Ä¾Àþ¤Î¥é¥¤¥ó¤¬ÉÁ²è¤µ¤ì¤Þ¤¹¡£
¡¡Ä¾Àþ°Ê³°¤ÎÊ£¿ô¤Î¥é¥¤¥ó¤òÉÁ²è¤¹¤ë¥á¥½¥Ã¥É¤È¤·¤Æ SetPositions ¥á¥½¥Ã¥É¤È¤¤¤¦½èÍý¤âÍÑ°Õ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¡ãÉÁ²è¡ä
// LineRenderer ¤Î1ÅÀÌܤÈ2ÅÀÌܤò»ØÄꤷ¤Æ¥ì¡¼¥¶¡¼¤È¤·¤ÆÉÁ²è lineRenderer.SetPosition(0, from); lineRenderer.SetPosition(1, to);
¡¡¤Ê¤ª¡¢¥é¥¤¥ó¤òºï½ü¤¹¤ëÀìÍѤΥ᥽¥Ã¥É¤ÏÍÑ°Õ¤µ¤ì¤Æ¤ª¤ê¤Þ¤»¤ó¤Î¤Ç¡¢²¼µ¤Î½èÍý¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Çºï½ü¤Ç¤¤Þ¤¹¡£
¡ãºï½ü¡ä
lineRenderer.SetPosition(0, Vector3.zero); lineRenderer.SetPosition(1, Vector3.zero);
»²¹Í¥µ¥¤¥È
Unity ¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
LineRenderer.SetPositions
https://docs.unity3d.com/jp/current/ScriptReferenc...
¡¡¤½¤Î¤Û¤«¤Î³èÍÑ»öÎã¤ò¾Ò²ð¤·¤Æ¤¤¤ë¥µ¥¤¥È¤â¤¿¤¯¤µ¤ó¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢¼«Ê¬¤Ç¤â¸¡º÷¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
»²¹Í¥µ¥¤¥È
¤Ï¤Ê¤Á¤ë¤Î¥Þ¥¤¥Î¡¼¥È ÍÍ
¡ÚUnity¡ÛLineRenderer¤ò¥¹¥¯¥ê¥×¥È¤«¤é¼«Í³¼«ºß¤ËÁà¤ë
https://www.hanachiru-blog.com/entry/2020/10/05/12...
¡¡¥Ò¥¨¥é¥ë¥¡¼¤Î¶õ¤¤¤Æ¤¤¤ë¾ì½ê¤Ç±¦¥¯¥ê¥Ã¥¯¤ò¤·¤Æ¥á¥Ë¥å¡¼¤ò³«¤¡¢Create Empty ¤Ç¿·¤·¤¤¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òºîÀ®¤·¤Þ¤¹¡£
̾Á°¤ò LaserPointer ¤ËÊѹ¹¤·¡¢LineRenderer ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤ò Add Component ¤ò»È¤Ã¤ÆÄɲ䷤Ƥ¯¤À¤µ¤¤¡£
¥Þ¥Æ¥ê¥¢¥ë¤ÎÀßÄ꤬ None ¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢Ç¤°Õ¤Î¥Þ¥Æ¥ê¥¢¥ë¤òºîÀ®¤¹¤ë¤«¡¢Unity ¤ËÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤ò¥¢¥µ¥¤¥ó¤·¤Þ¤¹¡£
¥Þ¥Æ¥ê¥¢¥ë¤ÎÀßÄê°Ê³°¤ÏÊѹ¹¤¹¤ëÉôʬ¤Ï¤¢¤ê¤Þ¤»¤ó¡£
¡¡Â³¤¤¤Æ¡¢LaserPointerController ¥¹¥¯¥ê¥×¥È¤ò¥É¥é¥Ã¥°¥¢¥ó¥É¥É¥í¥Ã¥×¤·¤Æ¥¢¥¿¥Ã¥Á¤·¤Þ¤¹¡£
¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¾å¤Ç¥¢¥¿¥Ã¥Á¤µ¤ì¤Æ¤¤¤ë¤³¤È¤ò³Îǧ¤·¤¿¤é¡¢³ÆÊÑ¿ô¤Ë¥¢¥µ¥¤¥ó¤ò¹Ô¤¤¤Þ¤¹¡£
¡¡handAnchor ÊÑ¿ô¤Ë¤Ï¡¢¥Ý¥¤¥ó¥¿¡¼¤òȯ¼Í¤¹¤ë¥³¥ó¥È¥í¡¼¥é¡¼¤òÁªÂò¤·¤Þ¤¹¡£
º£²ó¤Ï±¦¼ê¤Î¥³¥ó¥È¥í¡¼¥é¡¼¤ÇÁàºî¤¹¤ë¤³¤È¤òÁÛÄꤷ¤Æ¤¤¤Þ¤¹¤¬¡¢º¸¼ê¤Ç¤âÌäÂꤢ¤ê¤Þ¤»¤ó¡£
¡¡LineRenderer ÊÑ¿ô¤Ë¤Ï¡¢LaserPointer ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥¢¥¿¥Ã¥Á¤·¤¿ LineRenderer ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤ò¥¢¥µ¥¤¥ó¤·¤Þ¤¹¡£
¡ã¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü¡ä
¡¡¼Âµ¡¤Ë¤Æ¥²¡¼¥à¤ò¼Â¹Ô¤·¤Æ¡¢Ray ¤òȯ¼Í¤·¤¿Éôʬ¤Ë¥é¥¤¥ó¤¬ÉÁ²è¤µ¤ì¤ë¤«¡¢°ìÄê»þ´Ö¸å¤Ëºï½ü¤µ¤ì¤ë¤«¤ò³Îǧ¤·¤Þ¤¹¡£
¡¡ÌäÂ꤬¤Ê¤±¤ì¤Ð¤½¤Î¤Þ¤Þ¡¢ItemEvent ¥¯¥é¥¹¤¬¥¢¥¿¥Ã¥Á¤µ¤ì¤Æ¤¤¤ë¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ë¤âȯ¼Í¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
¥Ç¥Ð¥Ã¥°ÍѤΠCanvas ¤Ë¥¤¥Ù¥ó¥È¤¬¼Â¹Ô¤µ¤ì¤¿¤³¤È¤¬É½¼¨¤µ¤ì¤ì¤ÐÀ©¸æÀ®¸ù¤Ç¤¹¡£
- ¥«¥Æ¥´¥ê¡§
- ¿Ê³Ø/¥¹¥¯¡¼¥ë
- ¥×¥í¥°¥é¥ß¥ó¥°
¥³¥á¥ó¥È¤ò¤«¤¯