コード例 #1
0
        /// <summary>
        /// Builds for the given build target.
        /// </summary>
        /// <param name="bt">Build target.</param>
        /// <param name="scenes">Scenes to include.</param>
        /// <param name="bo">Build options.</param>
        private void BuildPlatform(BuildTarget bt, string[] scenes, BuildOptions bo)
        {
            if (BuildPipeline.isBuildingPlayer)
            {
                return;
            }

            var pathToCreate = _buildOutput;

            if (Path.HasExtension(_buildOutput))
            {
                pathToCreate = Path.GetDirectoryName(_buildOutput);
            }

            if (!Directory.Exists(pathToCreate))
            {
                Directory.CreateDirectory(pathToCreate);
            }

            if (_buildSettings.IsCardboard && (bt == BuildTarget.Android || bt == BuildTarget.iOS))
            {
                VRDeviceInfoEditor[] allVRDeviceInfo = VREditor.GetAllVRDeviceInfo(bt == BuildTarget.Android ? BuildTargetGroup.Android : BuildTargetGroup.iOS);
                VREditor.SetVREnabledOnTargetGroup(bt == BuildTarget.Android ? BuildTargetGroup.Android : BuildTargetGroup.iOS, true);
                VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Android, new[] { allVRDeviceInfo.Select(_ => _.deviceNameKey).FirstOrDefault(_ => _.ToLowerInvariant().StartsWith("cardboard")) });
            }
            else if (_buildSettings.IsGearVR && bt == BuildTarget.Android)
            {
                VRDeviceInfoEditor[] allVRDeviceInfo = VREditor.GetAllVRDeviceInfo(BuildTargetGroup.Android);
                VREditor.SetVREnabledOnTargetGroup(BuildTargetGroup.Android, true);
                VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Android, new[] { allVRDeviceInfo.Select(_ => _.deviceNameKey).FirstOrDefault(_ => _.ToLowerInvariant().StartsWith("oculus")) });
            }


            var error = BuildPipeline.BuildPlayer(GetScenes(scenes), _buildOutput, bt, bo);

            if (!string.IsNullOrEmpty(error.ToString()))
            {
                Debug.LogError(error);
            }
        }