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

Embedded Unity

Embedded Unity

#potatotips 55

Tatsuya Tanaka

October 09, 2018
Tweet

More Decks by Tatsuya Tanaka

Other Decks in Programming

Transcript

  1. Embedded Unity
    ాதୡ໵ (@tattn)
    #potatotips 55

    View full-size slide

  2. ాத ୡ໵ (@tattn)
    • Yahoo!৐׵Ҋ಺
    • iOSΞϓϦΤϯδχΞ
    @tattn
    @tanakasan2525
    @tattn
    (झຯͰUnity΍ͬͯ·͢)

    View full-size slide

  3. Unityͱ͸
    ԿͰ΋ἧͬͯΔήʔϜΤϯδϯ

    2D/3DͷάϥϑΟοΫεΛ؆୯ʹѻ͑Δɻ

    Mac/Win/Linux/iOS/Android/Web/PS4/Switch...

    ͳͲ͍͍ͩͨͷ؀ڥͰಈ͘ɻ

    View full-size slide

  4. Unity੡ΞϓϦͷಛ௃
    • ωΠςΟϒͷUIͰ͸ͳ͘ɺ

    ಠࣗͷUIͰ࣮૷͢Δ
    • ϑϧεΫϦʔϯ

    View full-size slide

  5. Unityͷ࠾༻͕ਏ͍ྫ
    ωΠςΟϒͷUIͰ͸ͳ͘ɺಠࣗͷUIͰ࣮૷͢Δ
    ͋Δը໘ΛUnityͰඳը͍͕ͨ͠ɺ

    ͦΕҎ֎͸ωΠςΟϒͷUI͕ྑ͍৔߹͸େม

    (͍ۙUIΛࣗલͰ࣮૷͢Δඞཁ͕͋Δ)

    View full-size slide

  6. Embedded Unity

    View full-size slide

  7. UnityΛωΠςΟϒΞϓϦʹຒΊࠐΉ

    View full-size slide

  8. DEMOࣦഊ༻ / PDF༻
    ←ωΠςΟϒͷ

    NavigationBar
    ωΠςΟϒͷ

    ˡTabBar
    ←ωΠςΟϒͷ

    Switch
    ←Unityͷը໘͕

    ϑϧεΫϦʔϯ

    Ͱ͸ͳ͍

    View full-size slide

  9. UnityͷωΠςΟϒϏϧυͷ
    ͘͠Έ

    View full-size slide

  10. UnityͷiOSϏϧυ
    1. C#ͷίʔυΛC#ίϯύΠϥͰϚωʔδυΞηϯϒϦԽ
    2. ࠷దԽ (࢖͍ͬͯͳ͍ඪ४Ϋϥεͷίʔυ࡟আͳͲ)
    3. IL2CPPͰC++ͷίʔυʹม׵
    4. ClangͰiOS༻ͷόΠφϦ΁Ϗϧυ
    IUUQTEPDTVOJUZEDPN%PDVNFOUBUJPO.BOVBM*-$11)PX*U8PSLTIUNM

    View full-size slide

  11. Unityͷը໘ (iOS)
    ࣗಈੜ੒͞ΕͨAppDelegateͰ

    ViewController΍ViewΛ૊Έཱͯͯ

    ϑϧεΫϦʔϯͷը໘Λද͍ࣔͯ͠Δ

    View full-size slide

  12. UnityͷViewΛҾͬுͬͯ͘Ε͹

    ޷͖ͳͱ͜ΖʹUnityͷը໘Λஔ͚Δ

    View full-size slide

  13. UnityΛEmbedded FrameworkԽ͢Δ
    ※Unity 2018.2.11f1ɺXcode 10.0Λ࢖༻

    View full-size slide

  14. Cocoa Touch FrameworkΛͭ͘Δ
    ੜ੒͞ΕͨϓϩδΣΫτΛ։͖ɺ

    frameworkΛλʔήοτʹ௥Ճɻ
    Unity-iPhoneʹ͋Δ.mm΍.hϑΝΠϧΛ

    ΄΅ίϐʔ͢Δ

    View full-size slide

  15. ࢖༻͢ΔHeaderΛPublicʹ͢Δ
    framework֎͔Β࢖༻͢ΔHeaderΛPublicʹ͢Δ

    View full-size slide

  16. ϓϩδΣΫτઃఆΛॻ͖׵͑Δ
    .xcconfigϑΝΠϧΛ࡞ͬͯɺઃఆ͢Δͱָ
    (Ұ෦ൈਮ)
    IUUQTHJTUHJUIVCDPNUBUUOEBDDCDEGGFD

    View full-size slide

  17. ίʔυΛগ͠ॻ͖׵͑Δ
    ύεΛมߋͨ͠Γɺextern "C"ͳͲΛ௥Ճ͢Δ
    ͕࣌ؒͳ͍ͷͰলུ

    View full-size slide

  18. ωΠςΟϒΞϓϦʹ૊ΈࠐΉ
    ࣗಈੜ੒͞Εͨmain.mmΛࢀߟʹ͢Δ

    View full-size slide

  19. UnityͷViewΛऔಘͯ͠දࣔ

    View full-size slide

  20. iOSͱUnityؒͷ΍ΓऔΓ
    (ωΠςΟϒ)

    UnitySendMessageͰ

    UnityʹσʔλΛૹΔ
    (Unity)

    ಉ໊ͷϝιουͰ

    σʔλΛड͚औΔ
    (σϞ༻ͷ࣮૷ͷͨΊϩδοΫ͸ద౰Ͱ͢...)

    View full-size slide

  21. ͢Δͱɺ͜͏ͳΓ·͢

    View full-size slide

  22. Unityͷগ͠લͷϦϦʔεϊʔτ
    IUUQTVOJUZEDPNKQVOJUZXIBUTOFXVOJUZ
    (1068657) - IL2CPP: Prevented a crash in il2cpp::os::Image::Initialize when Unity is embedded in another app on iOS.
    →iOSͰଞͷΞϓϦʹUnityΛຒΊࠐΜͩ࣌ͷΫϥογϡΛ๷͙
    Unityଆ΋EmbeddedΛαϙʔτ͢Δҙࢥ͕͋Δ

    View full-size slide

  23. ωΠςΟϒΞϓϦʹUnityΛ૊ΈࠐΊΔ
    • গ͠मਖ਼͸͍Δ͕Framework / AARԽͰ͖Δ
    • UnityͷPostProcessBuildΛ࢖͏ͱमਖ਼࡞ۀΛ

    ׬શʹࣗಈԽͰ͖Δ
    • Unityͷ๛෋ͳࢿ࢈Λ࢖͑Δ
    ʘSceneKitɾOpenGL͕ਏ͍৔߹͸͋Γ͔΋ʗ

    View full-size slide

  24. ࢀߟจݙ
    • https://github.com/jiulongw/swift-unity
    • https://github.com/blitzagency/ios-unity5
    • https://github.com/samizzo/UnityNativePrototype
    • https://forum.unity.com/threads/build-unity-app-as-framework-then-consumed-
    by-another-app.430068/
    • https://issuetracker.unity3d.com/issues/il2cpp-ios-crash-in-il2cpp-os-image-
    initialize-inlined-il2cpp-os-image-initializemanagedsection-at-image-dot-cpp-81

    View full-size slide