swift-unity icon indicating copy to clipboard operation
swift-unity copied to clipboard

UnityGetGLView() doesn't show the UnityView, unity in the background works but doesn't show in the screen

Open unittesting0 opened this issue 6 years ago • 3 comments

Hi Guys,

I'm following the guide to integrate the Unity scene in xcode project but i cant get the unityView.

I can only show only-unity or only-storyboard from the swift-xcode project.

if let unityView = UnityGetGLView() {
            // insert subview at index 0 ensures unity view is behind current UI view
            view?.insertSubview(unityView, at: 0)
            
            unityView.translatesAutoresizingMaskIntoConstraints = false
            let views = ["view": unityView]
            let w = NSLayoutConstraint.constraints(withVisualFormat: "|-0-[view]-0-|", options: [], metrics: nil, views: views)
            let h = NSLayoutConstraint.constraints(withVisualFormat: "V:|-75-[view]-0-|", options: [], metrics: nil, views: views)
            view.addConstraints(w + h)
        }

^This one doesn't work doesn't show anything, just the UI from the storyboard.

When I try window = UIApplication.shared.keyWindow it shows only the unity scene but not the UI from storyboard.

PlayerConnection initialized from /var/containers/Bundle/Application/CD9F382A-FBF4-4C63-8ADD-E36C0CE705CF/App.app/Data (debug = 0)
PlayerConnection initialized network socket : 0.0.0.0 55000
Multi-casting "[IP] 10.243.17.167 [Port] 55000 [Flags] 3 [Guid] 3587021933 [EditorId] 2077207300 [Version] 1048832 [Id] iPhonePlayer(Iphone-6S):56000 [Debug] 1" to [225.0.0.222:54997]...
Waiting for connection from host on [0.0.0.0:55000]...
Timed out. Continuing without host connection.
Started listening to [0.0.0.0:55000]
2018-07-02 15:54:12.171897 App[1300:353180] Metal GPU Frame Capture Enabled
2018-07-02 15:54:12.172293 App[1300:353180] Metal API Validation Enabled
-> applicationDidBecomeActive()
-> applicationDidBecomeActive()
GfxDevice: creating device client; threaded=1
Initializing Metal device caps: Apple A9 GPU
Initialize engine version: 2017.4.2f2 (52d9cb89b362)
WARNING: Shader Unsupported: 'Hidden/BlitToDepth' - Pass '' has no vertex shader
WARNING: Shader Unsupported: 'Hidden/BlitToDepth' - Setting to default shader.
WARNING: Shader Unsupported: 'Hidden/BlitToDepth_MSAA' - Pass '' has no vertex shader
WARNING: Shader Unsupported: 'Hidden/BlitToDepth_MSAA' - Setting to default shader.
SendMessage: object Scene not found!

P.S I went to every step but it doesnt work.

Thank you.

unittesting0 avatar Jul 02 '18 14:07 unittesting0

Are you sure that your code is executing ? let unityView = UnityGetGLView() and also try to remove constraint and set by frame

PrashantKT avatar Jul 03 '18 04:07 PrashantKT

I also have the same problem, it does not show me anything.

The unity print comes out in the console.

let unityView = UnityGetGLView() print(unityView)

Optional(<UnityView: 0x141e6b970; frame = (0 0; 414 736); autoresize = W+H; layer = <CAEAGLLayer: 0x1c022b740>>)

RogerBCA avatar Jul 17 '18 10:07 RogerBCA

Any solution found??

sandeepsmartest avatar Apr 30 '20 07:04 sandeepsmartest