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



LaserPointerController ¥¹¥¯¥ê¥×¥È¤òºîÀ®¤¹¤ë


¡¡LineRenderer ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤òÍøÍѤ·¡¢Ray ¤Ë¹ç¤ï¤»¤Æ¥é¥¤¥ó(¥Ý¥¤¥ó¥¿¡½)¤òÉÁ²è¤¹¤ëµ¡Ç½¤ò¼ÂÁõ¤·¤Þ¤¹¡£
¤³¤Î¥Ý¥¤¥ó¥¿¡¼¤¬¿¯Æþ¤·¤¿¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ë EventBase ¥¯¥é¥¹¤¬¥¢¥¿¥Ã¥Á¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢
¤½¤Î¥¯¥é¥¹¤ò¼èÆÀ¤·¤Æ¡¢TriggerEvent ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤·¡¢¥¤¥Ù¥ó¥È¤òȯ²Ð¤µ¤»¤Þ¤¹¡£

¡¡LineRenderer ¤Ë¤è¤Ã¤ÆÉÁ²è¤µ¤ì¤¿¥é¥¤¥ó¤Ï¼«Æ°Åª¤Ë¤Ïºï½ü¤µ¤ì¤Ê¤¤¤¿¤á¡¢
°ìÄê»þ´Ö¤¬·Ð²á¤·¤¿¤éºï½ü¤¹¤ë¤è¤¦¤Ë¤·¤Æ¤¤¤Þ¤¹¡£

¡¡¥é¥¤¥ó¤ÎÂÀ¤µ¤ò¥¹¥¯¥ê¥×¥ÈÆâ¤ÇÀ©¸æ¤·¤Æ¤¤¤Þ¤¹¡£
³ÆÀ©¸æÃÍ¤Ï private ½¤¾þ»Ò¤Ç¤¹¤¬¡¢¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤è¤êÀßÄêÃͤòÊѹ¹¤·¤¿¤¤¾ì¹ç¤Ë¤Ï SerializeField °À­¤òÉÕÍ¿¤·¤Æ¤¯¤À¤µ¤¤¡£

¡¡
LaserPointerController .cs

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



¡ãLineRenderer ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Îµ¡Ç½¡ä


¡¡Line Renderer (¥é¥¤¥ó¥ì¥ó¥À¥é¡¼) ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Ï¡¢¶õ´Ö¤Î£²¤Ä°Ê¾å¤ÎÅÀ¤ÎÇÛÎó¤ò¤È¤ë¤³¤È¤Ç¡¢¤½¤ì¤¾¤ì¤Î´Ö¤ËľÀþ¤òÉÁ¤­¤Þ¤¹¡£


»²¹Í¥µ¥¤¥È
Unity ¸ø¼°¥Þ¥Ë¥å¥¢¥ë
LineRenderer
https://docs.unity3d.com/ja/current/Manual/class-L...
Unity ¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
LineRenderer
https://docs.unity3d.com/jp/current/ScriptReferenc...


¡¡º£²ó¼ÂÁõ¤·¤Æ¤¤¤ëÊÑ¿ô¤ä¥á¥½¥Ã¥É¤Ë¤Ä¤¤¤Æ¤Þ¤È¤á¤Æ¤ª¤­¤Þ¤¹¡£
ɬ¤º¼«Ê¬¤Ç¤âÄ´¤Ù¤Æ¡¢¼«Ê¬¤ÎÃμ±¤È¤·¤ÆµÛ¼ý¤·¤Æ¤ª¤¤¤Æ¤¯¤À¤µ¤¤¡£


£±¡¥LineRenderer.startWidth

¡¡LineRenderer ¤ÇÉÁ²è¤¹¤ë¥é¥¤¥ó¤ÎÉý¤Î¥¹¥¿¡¼¥È¤Î¥µ¥¤¥º¤òÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ëÊÑ¿ô¤Ç¤¹¡£


»²¹Í¥µ¥¤¥È
Unity ¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
LineRenderer.startWidth
https://docs.unity3d.com/jp/current/ScriptReferenc...


£²¡¥LineRenderer.endWidth

¡¡LineRenderer ¤ÇÉÁ²è¤¹¤ë¥é¥¤¥ó¤ÎÉý¤ÎºÇ¸å¤Î¥µ¥¤¥º¤òÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ëÊÑ¿ô¤Ç¤¹¡£


»²¹Í¥µ¥¤¥È
Unity ¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
LineRenderer.endWidth
https://docs.unity3d.com/jp/current/ScriptReferenc...


¡¡¤³¤ì¤é¤Î¾¤Ë¤â¡¢¿§¤òÊѹ¹¤¹¤ëÊÑ¿ô¤ä¡¢¶ÊÀþ¤òÉÁ¤¯¤¿¤á¤ÎÊÑ¿ô¤Ê¤É¤âÍÑ°Õ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£


£³¡¥LineRenderer.SetPosition

¡¡¥é¥¤¥ó¤ÎĺÅÀ¤Î°ÌÃÖ¤òÀßÄꤹ¤ë¥á¥½¥Ã¥É¤Ç¤¹¡£¤³¤Î½èÍý¤Ë¤è¤Ã¤ÆÉÁ²è½èÍý¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£
£²¤Ä¤Î 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...


LaserPointer ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òºîÀ®¤·¡¢ÀßÄê¤ò¹Ô¤¦


¡¡¥Ò¥¨¥é¥ë¥­¡¼¤Î¶õ¤¤¤Æ¤¤¤ë¾ì½ê¤Ç±¦¥¯¥ê¥Ã¥¯¤ò¤·¤Æ¥á¥Ë¥å¡¼¤ò³«¤­¡¢Create Empty ¤Ç¿·¤·¤¤¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òºîÀ®¤·¤Þ¤¹¡£
̾Á°¤ò LaserPointer ¤ËÊѹ¹¤·¡¢LineRenderer ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤ò Add Component ¤ò»È¤Ã¤ÆÄɲ䷤Ƥ¯¤À¤µ¤¤¡£
¥Þ¥Æ¥ê¥¢¥ë¤ÎÀßÄ꤬ None ¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢Ç¤°Õ¤Î¥Þ¥Æ¥ê¥¢¥ë¤òºîÀ®¤¹¤ë¤«¡¢Unity ¤ËÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤ò¥¢¥µ¥¤¥ó¤·¤Þ¤¹¡£
¥Þ¥Æ¥ê¥¢¥ë¤ÎÀßÄê°Ê³°¤ÏÊѹ¹¤¹¤ëÉôʬ¤Ï¤¢¤ê¤Þ¤»¤ó¡£



¡¡Â³¤¤¤Æ¡¢LaserPointerController ¥¹¥¯¥ê¥×¥È¤ò¥É¥é¥Ã¥°¥¢¥ó¥É¥É¥í¥Ã¥×¤·¤Æ¥¢¥¿¥Ã¥Á¤·¤Þ¤¹¡£
¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¾å¤Ç¥¢¥¿¥Ã¥Á¤µ¤ì¤Æ¤¤¤ë¤³¤È¤ò³Îǧ¤·¤¿¤é¡¢³ÆÊÑ¿ô¤Ë¥¢¥µ¥¤¥ó¤ò¹Ô¤¤¤Þ¤¹¡£

¡¡handAnchor ÊÑ¿ô¤Ë¤Ï¡¢¥Ý¥¤¥ó¥¿¡¼¤òȯ¼Í¤¹¤ë¥³¥ó¥È¥í¡¼¥é¡¼¤òÁªÂò¤·¤Þ¤¹¡£
º£²ó¤Ï±¦¼ê¤Î¥³¥ó¥È¥í¡¼¥é¡¼¤ÇÁàºî¤¹¤ë¤³¤È¤òÁÛÄꤷ¤Æ¤¤¤Þ¤¹¤¬¡¢º¸¼ê¤Ç¤âÌäÂꤢ¤ê¤Þ¤»¤ó¡£

¡¡LineRenderer ÊÑ¿ô¤Ë¤Ï¡¢LaserPointer ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ë¥¢¥¿¥Ã¥Á¤·¤¿ LineRenderer ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤ò¥¢¥µ¥¤¥ó¤·¤Þ¤¹¡£


¡ã¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü¡ä






¥²¡¼¥à¤ò¼Â¹Ô¤·¤ÆÆ°ºî¤ò³Îǧ¤¹¤ë


¡¡¼Âµ¡¤Ë¤Æ¥²¡¼¥à¤ò¼Â¹Ô¤·¤Æ¡¢Ray ¤òȯ¼Í¤·¤¿Éôʬ¤Ë¥é¥¤¥ó¤¬ÉÁ²è¤µ¤ì¤ë¤«¡¢°ìÄê»þ´Ö¸å¤Ëºï½ü¤µ¤ì¤ë¤«¤ò³Îǧ¤·¤Þ¤¹¡£

¡¡ÌäÂ꤬¤Ê¤±¤ì¤Ð¤½¤Î¤Þ¤Þ¡¢ItemEvent ¥¯¥é¥¹¤¬¥¢¥¿¥Ã¥Á¤µ¤ì¤Æ¤¤¤ë¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ë¤âȯ¼Í¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
¥Ç¥Ð¥Ã¥°ÍѤΠCanvas ¤Ë¥¤¥Ù¥ó¥È¤¬¼Â¹Ô¤µ¤ì¤¿¤³¤È¤¬É½¼¨¤µ¤ì¤ì¤ÐÀ©¸æÀ®¸ù¤Ç¤¹¡£

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


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

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

Menu


´ðÁÃ

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

private



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

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