Upgrade to Pro — share decks privately, control downloads, hide ads and more …

uGUI の自動操作の考え方と操作方法

Kuniwak
December 01, 2023

uGUI の自動操作の考え方と操作方法

uGUI の仕組みのおさらいをしつつ、自動操作へのおすすめの取り組み方針と自動操作の方法を紹介します。
https://meetup.unity3d.jp/jp/events/1411

Kuniwak

December 01, 2023
Tweet

More Decks by Kuniwak

Other Decks in Technology

Transcript

  1. V(6*ͷࣗಈૢ࡞ͷ

    ߟ͑ํͱૢ࡞ํ๏
    6OJUZ6*׬શʹཧղͨ͠,VOJXBL %F/"$P -UE

    View full-size slide

  2. ,VOJXBL
    OPXTQSJOUJOHUFTUIFMQFSNPOLFZͷ

    ίϯτϦϏϡʔλɻήʔϜ։ൃ͔Β

    ۤ͠ΈΛऔΓআ͖͍ͨɻ
    Ͱ੩తղੳثͳͲΛ։ൃ͍ͯ͠Δɻ
    2

    View full-size slide

  3. ఻͍͑ͨ͜ͱ
    3

    View full-size slide

  4. V(6*͸ϓϩάϥϜ͔Βࣗಈૢ࡞Ͱ͖Δ
    V(6*Λࣗಈૢ࡞ͯ͠௿ίετͰ

    ࠷௿ݶͷಈ࡞֬ೝΛͰ͖ΔΑ͏ʹ͠Α͏
    4

    View full-size slide

  5. V(6*Λ࢖ͬͨ6OJUZΞϓϦέʔγϣϯͷ

    ࣗಈૢ࡞Λ͍ͨ͜͠ͱ͕͋Δ
    ࠓճͷࣗಈૢ࡞ͷ໨త͸࠷௿ݶͷಈ࡞֬ೝ
    6

    View full-size slide

  6. ࠷௿ݶͷಈ࡞֬ೝͱͯ͠ɺ͍ͬͨ͡पลՕॴͰ

    Ϋϥογϡਐߦෆೳ͕ͳ͍͜ͱ͸ϓϩάϥϚଆͰ

    ֬ೝ͓͖͍ͯͨ͠
    Ϋϥογϡਐߦෆೳ͸ޙʹ߇͑Δݕূ޻ఔΛ

    ϒϩοΫͯ͠͠·͍εέδϡʔϧ஗Ԇʹܨ͕Δ
    7

    View full-size slide

  7. ࠷௿ݶͷಈ࡞֬ೝ
    ΛͲ͏΍Δ͔
    8

    View full-size slide

  8. 9
    खಈΆͪΆͪ͸͍ͬͨ͡Օॴ͚ͩͳΒͰ͖Δɻ͔͠͠

    ຊ౰͸Өڹͦ͠͏ͳՕॴ͸͢΂ͯ֬ೝ͠ͳ͍ͱ͍͚ͳ͍
    ͢ΔͱͲ͏ͳΔ͔ɻϓϩάϥϚʔ͕ϓϩάϥϛϯάͷ

    ࣌ؒΛऔΕͣʹखಈΆͪΆͪϚϯͱԽ͢
    ͦΜͳ͜ͱ͸͋ͬͯ͸ͳΒͳ͍ͷͰϓϩάϥϚͳΒ

    खಈΆͪΆͪΛࣗಈԽͯ͠͠·͍·͠ΐ͏

    View full-size slide

  9. 10
    ࣗಈԽʹ͸ͭͷํ਑͕͋Δɿ
    w γφϦΦϕʔεͷಈ࡞֬ೝ
    w γφϦΦʹґଘ͠ͳ͍ಈ࡞֬ೝ

    View full-size slide

  10. γφϦΦϕʔεͷಈ࡞֬ೝ
    "ը໘͕ग़ͨΒ#Λԡͯ࣍͠ʹ$ը໘Ͱʙɺͱ

    ͍͏ͷ͕γφϦΦϕʔεͷಈ࡞֬ೝ
    γφϦΦϕʔεͷಈ࡞֬ೝ͸յΕ΍͘͢อकίετ
    ͕ߴ͍ɻखಈΆͪΆͪϚϯ͔ΒγφϦΦϝϯςϚϯ
    ʹδϣϒνΣϯδͯ͠΋શવخ͘͠ͳ͍
    11

    View full-size slide

  11. γφϦΦʹґଘ͠ͳ͍ಈ࡞֬ೝ
    ૢ࡞ՄೳͳཁૉΛద౰ʹબΜͰΆͪΆͪਐΜͰ͍͘

    ϓϩάϥϜ͕͋Ε͹ɺγφϦΦʹґଘ͠ͳ͍࠷௿ݶͷ
    ಈ࡞֬ೝΛ௿͍อकίετͰ࣮ݱͰ͖Δ
    ͜ͷΑ͏ͳಈ࡞֬ೝΛϞϯΩʔςετͱ͍͏
    12

    View full-size slide

  12. ϞϯΩʔςετΛ࣮ݱ͢ΔͨΊʹ͸ϓϩάϥϜ͔Βͷ

    ૢ࡞ΛϢʔβ͔Βͷૢ࡞ͷΑ͏ʹݟ͔͚ͤΔඞཁ͕͋Δ
    ࠓճͷର৅ΞϓϦέʔγϣϯ͸V(6*Λ࢖͍ͬͯͨͷͰ
    V(6*Λத৺ʹઆ໌͍ͯ͘͠
    13
    ΞϓϦ ΞϓϦ
    Ϣʔβ
    ϞϯΩʔ
    ϓϩάϥϜ

    View full-size slide

  13. V(6*ͷ͓͞Β͍
    14

    View full-size slide

  14. 15
    V(6*ͰϢʔβೖྗΛॲཧ͢Δத৺͸*OQVU.PEVMF
    w *OQVU.PEVMFΛ࢖͍ͬͯΔਓ

    ˠ4UBOEBMPOF*OQVU.PEVMF
    w *OQVU4ZTUFNΛ࢖͍ͬͯΔਓ

    ˠ*OQVU4ZTUFN6**OQVU.PEVMF
    ͲͪΒ΋େࡶ೺ͳॲཧͷྲྀΕ͸มΘΒͳ͍

    View full-size slide

  15. 16
    ຖϑϨʔϜ*OQVU.PEVMFͷ1SPDFTTͰ࣍ͷΑ͏ʹॲཧ͞ΕΔɿ
    Ϛ΢εೖྗ΍λονೖྗͳͲ͕͋Δ͔Λ֬ೝ͢Δ
    ೖྗ͕͋Ε͹ͦͷ࠲ඪ΁޲͔ͬͯSBZDBTU͢Δ
    ͦͷΦϒδΣΫτͷUSBOTGPSNQBSFOU΁޲͔ͬͯ

    ΠϕϯτϋϯυϥΛ୳͠ɺ΋͠ݟ͔ͭΕ͹ݺͼग़͠ɺ

    ͦ͏Ͱͳ͚Ε͹Կ΋͠ͳ͍
    ݫີʹ͸SBZDBTUFS͸ෳ਺ଘࡏ͠͏ΔɻSBZDBTUFS͕ෳ਺͋Δ৔߹͸ͦͷ਺͚ͩ

    IJUͨ͠ΦϒδΣΫτ͕ಘΒΕΔɻ͜ͷத͔Βը໘ͷ࠷લ໘ʹදࣔ͞Ε͍ͯΔ

    ΦϒδΣΫτ͕બ͹ΕΔΑ͏ʹͳ͍ͬͯΔɻ


    Ͱ
    ͸
    ׂ
    Ѫ

    View full-size slide

  16. 17
    parent.parent
    parent
    Raycaster

    View full-size slide

  17. 18
    Raycaster
    EventTrigger or IEventHandler
    parent.parent
    parent

    View full-size slide

  18. 19
    SBZ
    EventTrigger or IEventHandler
    parent.parent
    parent
    Raycaster

    View full-size slide

  19. 20
    EventTrigger or IEventHandler
    parent.parent
    parent
    Raycaster
    &WFOU5SJHHFSPS*&WFOU)BOEMFS͕ͳ͍

    View full-size slide

  20. 21
    EventTrigger or IEventHandler
    parent.parent
    parent
    Raycaster
    &WFOU5SJHHFSPS*&WFOU)BOEMFS͕ͳ͍

    View full-size slide

  21. 22
    EventTrigger or IEventHandler
    parent.parent
    parent
    Raycaster
    &WFOU5SJHHFSPS*&WFOU)BOEMFS͕͋Δ

    View full-size slide

  22. 23
    ݺͼग़͠
    Raycaster
    EventTrigger or IEventHandler

    View full-size slide

  23. V(6*ͷࣗಈૢ࡞ͷجຊ
    24

    View full-size slide

  24. 25
    ૢ࡞͍ͨ͠ΦϒδΣΫτΛ'JOE0CKFDU౳Ͱೖख͢Δ
    ૢ࡞छผʹରԠ͍ͯ͠Δ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ͕Ϣʔβ͔Βૢ࡞Մೳͳ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ΁ͷૢ࡞Λ࣮ߦ

    View full-size slide

  25. 26
    ૢ࡞͍ͨ͠ΦϒδΣΫτΛ'JOE0CKFDU౳Ͱೖख͢Δ
    ૢ࡞छผʹରԠ͍ͯ͠Δ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ͕Ϣʔβ͔Βૢ࡞Մೳͳ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ΁ͷૢ࡞Λ࣮ߦ

    View full-size slide

  26. 27
    ૢ࡞͍ͨ͠ΦϒδΣΫτΛ'JOE0CKFDU౳Ͱೖख͢Δ
    ૢ࡞छผʹରԠ͍ͯ͠Δ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ͕Ϣʔβ͔Βૢ࡞Մೳͳ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ΁ͷૢ࡞Λ࣮ߦ

    View full-size slide

  27. 28
    ૢ࡞͍ͨ͠ΦϒδΣΫτΛ'JOE0CKFDU౳Ͱೖख͢Δ
    ૢ࡞छผʹରԠ͍ͯ͠Δ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ͕Ϣʔβ͔Βૢ࡞Մೳͳ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ΁ͷૢ࡞Λ࣮ߦ
    *&WFOU)BOEMFSͳΒରԠ͢ΔJOUFSGBDFʢ*1PJOUFS%PXO)BOEMFSͳͲʣΛ

    ࣮૷͍ͯ͠Δ͔Ͳ͏͔֬ೝ͢Δɻ&WFOU5SJHHFSͳΒUSJHHFSTϓϩύςΟ

    ͔ΒFWFOU*%Ͱ֬ೝ͢Δ

    View full-size slide

  28. 29
    ૢ࡞͍ͨ͠ΦϒδΣΫτΛ'JOE0CKFDU౳Ͱೖख͢Δ
    ૢ࡞छผʹରԠ͍ͯ͠Δ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ͕Ϣʔβ͔Βૢ࡞Մೳͳ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ΁ͷૢ࡞Λ࣮ߦ

    View full-size slide

  29. 30
    ૢ࡞͍ͨ͠ΦϒδΣΫτΛ'JOE0CKFDU౳Ͱೖख͢Δ
    ૢ࡞छผʹରԠ͍ͯ͠Δ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ͕Ϣʔβ͔Βૢ࡞Մೳͳ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ΁ͷૢ࡞Λ࣮ߦ

    View full-size slide

  30. 31
    ૢ࡞͍ͨ͠ΦϒδΣΫτΛ'JOE0CKFDU౳Ͱೖख͢Δ
    ૢ࡞छผʹରԠ͍ͯ͠Δ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ͕Ϣʔβ͔Βૢ࡞Մೳͳ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ΁ͷૢ࡞Λ࣮ߦ
    ͦͷཁૉ΁SBZDBTUΛඈ͹͠ɺࣗ਎·ͨ͸ͦͷUSBOTGPSNͷࢠଙʹ
    SBZDBTU͕౰ͨΔ͜ͱΛ֬ೝ͢ΔɻSBZDBTU͕౰ͨΒͳ͚Ε͹લ໘ʹ

    ো֐෺͕͋Γ࣮ࡍʹ͸Ϣʔβ͔Βૢ࡞Ͱ͖ͳ͍

    View full-size slide

  31. 32
    ૢ࡞͍ͨ͠ΦϒδΣΫτΛ'JOE0CKFDU౳Ͱೖख͢Δ
    ૢ࡞छผʹରԠ͍ͯ͠Δ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ͕Ϣʔβ͔Βૢ࡞Մೳͳ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ΁ͷૢ࡞Λ࣮ߦ
    ࣗ਎ͱSBZDBTUʹ౰ͨͬͨཁૉͷதʹผͷΠϕϯτϋϯυϥ͕

    ͳ͍͜ͱ΋֬ೝ͢ΔɻผͷΠϕϯτϋϯυϥ͕͋ΔͱͦΕʹ

    ΠϕϯτΛऔΒΕͯ͠·͏ͷͰϢʔβ͔Βૢ࡞Ͱ͖ͳ͍

    View full-size slide

  32. 33
    ૢ࡞͍ͨ͠ΦϒδΣΫτΛ'JOE0CKFDU౳Ͱೖख͢Δ
    ૢ࡞छผʹରԠ͍ͯ͠Δ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ͕Ϣʔβ͔Βૢ࡞Մೳͳ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ΁ͷૢ࡞Λ࣮ߦ

    View full-size slide

  33. 34
    ૢ࡞͍ͨ͠ΦϒδΣΫτΛ'JOE0CKFDU౳Ͱೖख͢Δ
    ૢ࡞छผʹରԠ͍ͯ͠Δ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ͕Ϣʔβ͔Βૢ࡞Մೳͳ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ΁ͷૢ࡞Λ࣮ߦ

    View full-size slide

  34. 35
    ૢ࡞͍ͨ͠ΦϒδΣΫτΛ'JOE0CKFDU౳Ͱೖख͢Δ
    ૢ࡞छผʹରԠ͍ͯ͠Δ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ͕Ϣʔβ͔Βૢ࡞Մೳͳ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ΁ͷૢ࡞Λ࣮ߦ
    &WFOU5SJHHFSͱ*&WFOU)BOEMFSͷͲͪΒͰ΋ૢ࡞छผʹ

    ରԠ͢ΔJOUFSGBDFͷϝιουΛݺ΂͹0,ɻ
    Ҿ਺͕1PJOUFS&WFOU%BUBͰ΋"YJT&WFOU%BUBͰ΋

    OFX1PJOU&WFOU%BUB &WFOU4ZTUFNDVSSFOU
    ͷΑ͏ʹ࡞ΕΔɻ

    QPTJUJPOϓϩύςΟͳͲ͸ඞཁʹԠͯ͡ઃఆ͢Δ

    View full-size slide

  35. 36
    ૢ࡞͍ͨ͠ΦϒδΣΫτΛ'JOE0CKFDU౳Ͱೖख͢Δ
    ૢ࡞छผʹରԠ͍ͯ͠Δ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ͕Ϣʔβ͔Βૢ࡞Մೳͳ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ΁ͷૢ࡞Λ࣮ߦ

    View full-size slide

  36. 37
    ૢ࡞͍ͨ͠ΦϒδΣΫτΛ'JOE0CKFDU౳Ͱೖख͢Δ
    ૢ࡞छผʹରԠ͍ͯ͠Δ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ͕Ϣʔβ͔Βૢ࡞Մೳͳ͜ͱΛ֬ೝ͢Δ
    ΦϒδΣΫτ΁ͷૢ࡞Λ࣮ߦ
    ͜ΕΛ'JOE0CKFDUT#Z5ZQF.POP#FIBWJPVS /POF
    Ͱ

    ಘͯٙࣅཚ਺͔Βநબͯͭ͠ΛબΜͰૢ࡞͢Δ͚ͩͰ

    ϞϯΩʔϓϩάϥϜΛ࣮૷Ͱ͖Δ

    View full-size slide

  37. ࣗಈૢ࡞ͷ͸·ΓͲ͜Ζ
    38

    View full-size slide

  38. ࣗಈૢ࡞ͷ͸·ΓͲ͜Ζ
    w SBZDBTUΛඈ͹͢఺ΛͲ͜ʹ͢Δ͔
    w *OQVU(FU5PVDIͳͲͰಠࣗ൑ఆ͍ͯ͠Δ6*Λ

    ͲͷΑ͏ʹࣗಈૢ࡞͢Δ͔
    39

    View full-size slide

  39. ࣗಈૢ࡞ͷ͸·ΓͲ͜Ζ
    w SBZDBTUΛඈ͹͢఺ΛͲ͜ʹ͢Δ͔
    w *OQVU(FU5PVDIͳͲͰಠࣗ൑ఆ͍ͯ͠Δ6*Λ

    ͲͷΑ͏ʹࣗಈૢ࡞͢Δ͔
    40

    View full-size slide

  40. SBZDBTUΛͲ͜΁ඈ͹͔͢
    USBOTGPSNQPTJUJPO΁ඈ͹͢ͷ͕࠷΋؆୯ɻ͔͠͠

    ͱ͖Ͳ͖SBZDBTUͷ౰ͨΒͳ͍Ґஔʹઃఆ͞Εͯ

    ͍Δ͜ͱ͕͋Δɻ(BNF0CKFDU͝ͱʹSBZDBTU͢Δ

    ఺Λม͑ΒΕΔΑ͏ʹ͢Δ͔͠ͳ͍ɻϞϯΩʔૢ࡞

    ϥΠϒϥϦUFTUIFMQFSNPOLFZͰ͸ΞϊςʔγϣϯͰ

    ੍ޚͰ͖ΔΑ͏ʹ͍ͯ͠Δ
    41
    IUUQTHJUIVCDPNOPXTQSJOUJOHUFTUIFMQFSNPOLFZ

    View full-size slide

  41. w 8PSME1PTJUJPO"OOPUBUJPOˠϫʔϧυ࠲ඪͰͷࢦఆҐஔ
    w 8PSME0
    ff
    TFU"OOPUBUJPOˠUSBOTGPSNQPTJUJPO͔Βͷ૬ରҐஔ
    w 4DSFFO1PTJUJPO"OOPUBUJPOˠεΫϦʔϯ࠲ඪͰͷࢦఆҐஔ
    w 4DSFFO0
    ff
    TFU"OOPUBUJPOˠUSBOTGPSNQPTJUJPOͷ

    εΫϦʔϯ࠲ඪ͔Βͷ૬ରҐஔ
    42
    UFTUIFMQFSNPOLFZʹ͓͚ΔΞϊςʔγϣϯ༻ͷ
    $PNQPOFOUͱSBZDBTUΛඈ͹͢Ґஔ

    View full-size slide

  42. DPO
    fi
    Hͷ4DSFFO1PTJUJPO4USBUFHZΛσϑΥϧτͷ΋ͷ͔Β

    ಠࣗͷ'VOD(BNF0CKFDU 7FDUPSʹࠩ͠ସ͑Ε͹0,ɻ
    σόοά͢Δࡍʹ͸SBZDBTUҐஔΛ(J[NPͰද͓ࣔͯ͘͠ͱศརɻ

    UFTUIFMQFSNPOLFZͷ*OUFSBDUJWF$PNQPOFOU)JOUΛTDFOF΁

    ௥Ճͯ͠FOBCMFʹ͢Δͱ(J[NPΛදࣔͰ͖Δ
    43
    UFTUIFMQFSNPOLFZͰΑΓߴ౓ʹҐஔΛࢦ͍ࣔͨ͠

    View full-size slide

  43. (J[NPͰSBZDBTUҐஔΛදࣔ
    44

    View full-size slide

  44. ࣗಈૢ࡞ͷ͸·ΓͲ͜Ζ
    w SBZDBTUΛඈ͹͢఺ΛͲ͜ʹ͢Δ͔
    w *OQVU(FU5PVDIͳͲͰಠࣗ൑ఆ͍ͯ͠Δ6*Λ

    ͲͷΑ͏ʹࣗಈૢ࡞͢Δ͔
    45

    View full-size slide

  45. ࣗಈૢ࡞ͷ͸·ΓͲ͜Ζ
    w SBZDBTUΛඈ͹͢఺ΛͲ͜ʹ͢Δ͔
    w *OQVU(FU5PVDIͳͲͰಠࣗ൑ఆ͍ͯ͠Δ6*Λ

    ͲͷΑ͏ʹࣗಈૢ࡞͢Δ͔
    46

    View full-size slide

  46. ಠࣗ൑ఆ͍ͯ͠Δ6*΁ͷରॲ
    ΦʔτύΠϩοτ༗ޮ࣌ͷΈೖྗΛࠩ͠ࠐΊΔΑ͏ʹ

    ର৅ΞϓϦέʔγϣϯΛվमͨ͠
    ಠࣗ൑ఆ͍ͯ͠Δ6*͕දࣔ͞ΕΔಛఆͷঢ়ଶͰ͚ͩ

    ͜ͷ࢓૊Έ͔ΒϞϯΩʔૢ࡞Ͱ͖ΔΑ͏ʹ͍ͯ͠Δ
    47

    View full-size slide

  47. ·ͱΊ
    48
    V(6*͸ϓϩάϥϜ͔Βࣗಈૢ࡞Ͱ͖Δ
    V(6*Λࣗಈૢ࡞ͯ͠௿ίετͰ

    ࠷௿ݶͷಈ࡞֬ೝΛͰ͖ΔΑ͏ʹ͠Α͏

    View full-size slide