Search Unity

[OSX Build] The game doesn't work after build

Discussion in 'macOS' started by shiorikanaoka, May 30, 2018.

  1. shiorikanaoka

    shiorikanaoka

    Joined:
    Apr 9, 2018
    Posts:
    3
    Hi,
    My game doesn't work after build, although it works in the Unity Editor.

    Situation:
    The OSX build mostly works correctly, but somehow cannot show the result screen which should be called by OnTriggerEnter2D.
    That OnTriggerEnter2D itself is working as it plays audio clip and stops the time counter.
    I guess "result.SetActive(true)" is somehow not working in the built app?

    Environment:
    Unity 20173.1f1 Personal
    OSX 10.12.16

    I read lots of similar threads and tried console.app (there seems no error) and restarting mac already, I'll try Windows version in bootcamp now, but I need this Mac version ready today.

    project file: uploading
    Windows version: https://drive.google.com/open?id=1pr9LL8TS69NVvCJ-DFdpcwZ9DhdubzAC
    Mac version: https://drive.google.com/open?id=1rfspFSvC19dPaM1dky6Qlg_vwtDy7TWx

    Thanks for your help!!
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    It's very hard to believe that SetActive(true) would not work on Mac. It's probably something else. Perhaps you are getting some exception, which is causing your code to bail out early.

    Of course it's very rare to get an exception on one platform but not the other. Check any code that is dealing with files, platform-specific plugins, etc.

    Also try putting a Debug.Log before and after the SetActive call, and perhaps also in the OnEnable method of some script on your result screen. Find this output in the Player log.

    頑張ってください! ^_^
     
    shiorikanaoka likes this.
  3. shiorikanaoka

    shiorikanaoka

    Joined:
    Apr 9, 2018
    Posts:
    3
    Hi, thank you for your reply!

    I checked the game in Windows as well, and it had the same problem.
    I also debugged and SetActive is actually working, as the activated script is returning a debug log.
    I haven't imported any assets/packages/plugins, and the game is working correctly in the Editor.
    I'll try to debug more but the Editor already has no error so I don't know what to do :(
    Thank you, 頑張ります T T
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    OK, so SetActive is working, but your screen is not showing up.

    Could you be trying to load a scene that is not included in the Build Settings?

    Are you loading a shader by name that isn't referenced directly anywhere? (But in this case, I would expect graphics to show up with the default pink shader.)

    Are you using Lightmapping? If so, perhaps you've run into this issue.

    What exactly is this result screen? Is it a Canvas? Or a hierarchy of Sprites? Or something else? What happens if you activate a simple cube instead — does that show up in the built app?
     
  5. shiorikanaoka

    shiorikanaoka

    Joined:
    Apr 9, 2018
    Posts:
    3
    Hi,
    Thanks for your reply.

    All the scenes are loaded in build setting.

    result screen is a Panel which is parent of GUI Texts.
    it is set inactive in Start() and activated by Gameover(), and it correctly appears in Editor.
    it has no "Editor Only" tag, it has no error on Player.log.
    Today I'll try on another mac but i think it'll be the same
     
  6. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Yes, you've tried on both Mac and Windows with the same result. It must be an editor vs. player issue.

    This Panel is a child of a Canvas, of course. Are there other elements in the same Canvas that do appear?

    What mode is your Canvas using — World Space, Screen Space (Overlay), or Screen Space (Camera)? If it's not Overlay mode, then it will be affected by the camera settings, such as render flags, and the near/far clipping planes. Also the canvas elements in this case could be obscured by other objects closer to the camera.

    Here is what I would do in your situation:
    1. Save a copy of the scene as something else ("TestScene" for example).
    2. Delete everything else in the scene, except for the camera and this troublesome Canvas.
    3. Start that Canvas and Panel out already activated, so no scripts are involved.
    4. Add TestScene to the top of the Build Settings, and build. See if the panel is visible.
    5. If so, then study the differences between TestScene and my real scene — make one more like the other, until I figure out what's causing the problem.
    6. If not, then I have a very simple example to study, and can focus on just the Camera and Canvas until I figure it out.
    I wish I could help more. Hopefully this procedure will lead to a solution.