Search Unity

5.6.2 Native GVR build won't work when built through Command Line

Discussion in 'AR/VR (XR) Discussion' started by SpaceKangaroo, Jul 20, 2017.

  1. SpaceKangaroo

    SpaceKangaroo

    Joined:
    Apr 27, 2015
    Posts:
    14
    I've got a project that supports GVR. Up until Unity's native GVR integration we've had success automatically building the project for all platforms.

    Building the project through default build commands the editor log leaves this as an output (last line specifically):

    This is a follow up to http://answers.unity3d.com/questions/1381195/running-562-via-editor-command-line-leaves-out-vr.html

    I've had little luck finding anything to match the issue. I'm assuming it's such an odd thing I've ran in to for it. We build our apps via command line on an automated build machine yet VR sdk's aren't attaching to the project via command line for this.

    edit:
    Some additional info -

     
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    What are you doing in your PerformAndroidBuild method?

    As an example here is what I use internally and I have no issues:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEditor;
    4.  
    5. public class BuildScript : MonoBehaviour {
    6.  
    7.     static void Android()
    8.     {
    9.         //PlayerSettings.VR.Google.daydreamOnly = true;
    10.  
    11.         BuildPipeline.BuildPlayer(new[] {"Assets/_SCENE.unity"}, "build_temp.apk", BuildTarget.Android,
    12.             BuildOptions.AutoRunPlayer | BuildOptions.Development);
    13.     }
    14. }
    15.  
     
  3. SpaceKangaroo

    SpaceKangaroo

    Joined:
    Apr 27, 2015
    Posts:
    14
    We have a script that basically does that with scene/apk names assemblies based on Jenkins jobs. The only real difference is we use no BuildOptions.

    I've just tried that code exact code (with different scene names) and I get the same issue. This project works perfectly fine built via the editor. Those errors I've quoted above still happen too (in the case of command line with your code).

    Unity version is 5.6.2f1
     
  4. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    What happens if you remove this

    Code (CSharp):
    1. UnityEditorInternal.VR.VREditor.SetVREnabledOnTargetGroup(BuildTargetGroup.Android, true);
    2. UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Android, new string[] { "Cardboard" });
    and just manually add the device to the VR device list in PlayerSettings?
     
  5. SpaceKangaroo

    SpaceKangaroo

    Joined:
    Apr 27, 2015
    Posts:
    14
    I've been testing without any of them today. Realised I wrote a seperate editor script to add the same things thinking it would work on that side. Looks like they were causing the issue for Android!

    Untitled.png

    I think I've gone full circle here to the origin of this issue for us.

    Basically all this started with the iOS builds. I tested various commands (such as the ones you've quoted above) to try get it to work. These are the calls made for the iOS build:


    Code (CSharp):
    1.     static public void PerformIOSBuild()
    2.     {
    3.         MakePaths();
    4.         //
    5.         // Take the build number from the SVN revision number, and use it for the IOS build number
    6.         PlayerSettings.iOS.buildNumber = System.Environment.GetEnvironmentVariable("SVN_REVISION");
    7.         Debug.Log("IOS build version code is:" + PlayerSettings.iOS.buildNumber, null);
    8.  
    9.         BuildPipeline.BuildPlayer(m_scenes, m_finalPath, BuildTarget.iOS, BuildOptions.None);
    10.     }
    Code (CSharp):
    1.     static private void MakePaths()
    2.     {
    3.         // Generic parameters
    4.         m_buildName = System.Environment.GetEnvironmentVariable("BUILD_NAME");  // Name of the final build file/package      
    5.         m_jobName = System.Environment.GetEnvironmentVariable("JOB_NAME");      // Name of the job
    6.         m_workspace = System.Environment.GetEnvironmentVariable("WORKSPACE");   // Workspace directory
    7.         m_home = System.Environment.GetEnvironmentVariable("JENKINS_HOME");     // Jenkins home directory
    8.  
    9.         m_finalPath = m_workspace + "/" + m_jobName + "/";                      // Full path for the build, without the build name
    10.         m_bundleID = System.Environment.GetEnvironmentVariable("BUNDLE_ID");            // Bundle ID, usually 'com.gaia.????'
    11.         m_bundleVersion = System.Environment.GetEnvironmentVariable("BUNDLE_VERSION");  // Bundle version, usually '1.0.0'    
    12.  
    13.         //IOS Settings
    14.         m_teamID = System.Environment.GetEnvironmentVariable("IOS_TEAM_ID");        // iOS Team ID      
    15.         PlayerSettings.iOS.appleDeveloperTeamID = m_teamID;
    16.  
    17.         PlayerSettings.showUnitySplashScreen = false;
    18.         PlayerSettings.productName = m_buildName;                   // Set Unity product name
    19.         // PlayerSettings.bundleIdentifier = m_bundleID;               // Set Unity bundle identifier
    20.         PlayerSettings.bundleVersion = m_bundleVersion;             // Set Unity bundle version
    21.  
    22.         PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, m_bundleID);
    23.         PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Standalone, m_bundleID);
    24.         PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, m_bundleID);
    25.  
    26.  
    27.         Debug.Log("Product name is :" + PlayerSettings.productName);
    28.         Debug.Log("Bundle ID is :" + PlayerSettings.applicationIdentifier);
    29.         Debug.Log("Bundle Version is :" + PlayerSettings.bundleVersion);
    30.     }
    31.  
    I've double checked to make sure PlayerSettings do persist on project loadup. Cardboard as the device SDK for VR is there for iOS/Android.
     
  6. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    What's the problem you are having with the iOS builds? I don't see anything in those scripts for setting VR state. Is that done explicitly through the UI for iOS?
     
  7. SpaceKangaroo

    SpaceKangaroo

    Joined:
    Apr 27, 2015
    Posts:
    14
    The app doesn't load with a stereoscopic view. VR is flagged through player settings.
    vr.png

    If built in editor, I get the scene as intended. Stereoscopic view from Cardboard SDK kicks in.
     
  8. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    So, we are talking specifically iOS here, right? If so, how are you building the Xcode workspace that Unity generates?
     
  9. SpaceKangaroo

    SpaceKangaroo

    Joined:
    Apr 27, 2015
    Posts:
    14
    Yes - seems like Android was fine.

    We use fastlane, the specific job for VR we have listed is:

    Code (CSharp):
    1. desc "Create a VR build"
    2. lane :deployBuildVR do
    3.   cert({ development: true })
    4.   sigh({ development: true, force: true })
    5.   gym ({
    6.       include_bitcode: false,
    7.       export_method: "development",
    8.       xcargs: "ENABLE_BITCODE=FALSE OTHER_LDFLAGS='-framework Security -framework GLKit -ObjC'",
    9.       output_directory: "./xcode.build",
    10.    })
    11.   end
     
  10. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    I have no idea about fastlane but here is a test that will tell you if it is fastlane: Open the .xcworkspace file Unit produced and build the app there. If success then deploys and make sure that VR is working. If that works then the problem is most likely your build system or its configuration.
     
  11. SpaceKangaroo

    SpaceKangaroo

    Joined:
    Apr 27, 2015
    Posts:
    14
    Sorry about slow replies - testing out a few things for it. The .xcworkspace file is not successful when built by itself after running through command line.

    If I build via the editor then build the .xcworkspace, it's fine.

    I can see that there are several things that aren't linked/created in the Unity output for command line build. A lot of linker stuff isn't in the version built via command line.
     
  12. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    > The .xcworkspace file is not successful when built by itself after running through command line.
    Do you that mean that after running a command line build, opening the workspace in Xcode and building in Xcode fails?

    > I can see that there are several things that aren't linked/created in the Unity output for command line build. A lot of linker stuff isn't in the version built via command line.

    This would seem to imply that the issue may be with your build system.
     
  13. SpaceKangaroo

    SpaceKangaroo

    Joined:
    Apr 27, 2015
    Posts:
    14
    XCode doesn't fail - the build just doesn't have GVR functionality.

    Apologies for the confusing route around this, I've been posting stuff and retrying everything.

    I might have worked it out. We only commit Assets+ProjectSettings to SVN. This then gets intercepted by our build machine, checks it out/runs command line build etc.

    I've just checked out the project on the Mac. Opened it in editor, closed it (so Library folder has been assembled). Built via command line - works.
    If I check the project out and build it via command line, without opening in editor then it doesn't work (GVR doesn't link/isn't present in build).
     
  14. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Yeah, I think the Library folder is important for building. It's not important for transferring projects around but I think we do store build/project settings in there that will effect build. What you might want to try is opening the project using command line unity and then killing unity prior to running the rest of the build?
     
  15. SpaceKangaroo

    SpaceKangaroo

    Joined:
    Apr 27, 2015
    Posts:
    14
    Didn't expect the assembly of the Library to differ like that between command line and editor. At least we have a solution! It's only been our VR projects that have been affected.

    Thanks for the help!