public override string[] ModifyEmbeddedScenes(string[] scenes) { if (!Context.HasComponent <LiveLink>()) { return(scenes); } var nonLiveLinkable = scenes.Where(s => !SceneImporterData.CanLiveLinkScene(s)).ToArray(); if (nonLiveLinkable.Length > 0) { return(nonLiveLinkable); } return(new[] { k_EmptyScenePath }); }
public NativeArray <Hash128> GetInitialScenes(int playerId, Allocator allocator) { var sceneList = _BuildConfiguration.GetComponent <SceneList>(); var nonEmbeddedStartupScenes = new List <string>(); foreach (var path in sceneList.GetScenePathsToLoad()) { if (SceneImporterData.CanLiveLinkScene(path)) { nonEmbeddedStartupScenes.Add(path); } } if (nonEmbeddedStartupScenes.Count > 0) { var sceneIds = new NativeArray <Hash128>(nonEmbeddedStartupScenes.Count, allocator); for (int i = 0; i < nonEmbeddedStartupScenes.Count; i++) { sceneIds[i] = AssetDatabaseCompatibility.PathToGUID(nonEmbeddedStartupScenes[i]); } return(sceneIds); } return(new NativeArray <Hash128>(0, allocator)); }
public void SendInitialScenes(int playerId) { var sceneList = _BuildConfiguration.GetComponent <SceneList>(); var nonEmbeddedStartupScenes = new List <string>(); foreach (var path in sceneList.GetScenePathsToLoad()) { if (SceneImporterData.CanLiveLinkScene(path)) { nonEmbeddedStartupScenes.Add(path); } } if (nonEmbeddedStartupScenes.Count > 0) { var sceneIds = new NativeArray <Hash128>(nonEmbeddedStartupScenes.Count, Allocator.Temp); for (int i = 0; i < nonEmbeddedStartupScenes.Count; i++) { sceneIds[i] = new Hash128(AssetDatabase.AssetPathToGUID(nonEmbeddedStartupScenes[i])); } EditorConnection.instance.SendArray(LiveLinkMsg.ResponseConnectLiveLink, sceneIds, playerId); sceneIds.Dispose(); } }
public override BuildStepResult RunBuildStep(BuildContext context) { m_TempFileTracker = new TemporaryFileTracker(); var generalSettings = GetRequiredComponent <GeneralSettings>(context); var profile = GetRequiredComponent <ClassicBuildProfile>(context); var sceneList = GetRequiredComponent <SceneList>(context); if (profile.Target <= 0) { return(BuildStepResult.Failure(this, $"Invalid build target '{profile.Target.ToString()}'.")); } if (profile.Target != EditorUserBuildSettings.activeBuildTarget) { return(BuildStepResult.Failure(this, $"{nameof(EditorUserBuildSettings.activeBuildTarget)} must be switched before {nameof(BuildStepBuildClassicLiveLink)} step.")); } //any initial scenes that cannot be live linked must be added to the scenes list var embeddedScenes = new List <string>(sceneList.GetScenePathsToLoad().Where(path => !SceneImporterData.CanLiveLinkScene(path))); //if none of the startup scenes are embedded, add empty scene if (embeddedScenes.Count == 0) { embeddedScenes.Add(k_EmptyScenePath); } //add any additional scenes that cannot be live linked foreach (var path in sceneList.GetScenePathsForBuild()) { if (!SceneImporterData.CanLiveLinkScene(path) && !embeddedScenes.Contains(path)) { embeddedScenes.Add(path); } } var outputPath = this.GetOutputBuildDirectory(context); if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } var buildPlayerOptions = new BuildPlayerOptions { scenes = embeddedScenes.ToArray(), target = profile.Target, locationPathName = Path.Combine(outputPath, generalSettings.ProductName + profile.GetExecutableExtension()), targetGroup = UnityEditor.BuildPipeline.GetBuildTargetGroup(profile.Target), options = BuildOptions.Development | BuildOptions.ConnectToHost }; var sourceBuild = GetOptionalComponent <SourceBuildConfiguration>(context); if (sourceBuild.Enabled) { buildPlayerOptions.options |= BuildOptions.InstallInBuildFolder; } if (profile.Configuration == BuildType.Debug) { buildPlayerOptions.options |= BuildOptions.AllowDebugging; } if (UseAutoRunPlayer(context)) { UnityEngine.Debug.Log($"Using BuildOptions.AutoRunPlayer, since RunStep is not provided for {profile.Target}"); buildPlayerOptions.options |= BuildOptions.AutoRunPlayer; } var settings = BuildContextInternals.GetBuildConfiguration(context); if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(settings, out var guid, out long _)) { using (var stream = new StreamWriter(m_TempFileTracker.TrackFile(k_BootstrapPath))) { stream.WriteLine(guid); stream.WriteLine(EditorAnalyticsSessionInfo.id); } } var report = UnityEditor.BuildPipeline.BuildPlayer(buildPlayerOptions); var result = new BuildStepResult(this, report); context.SetValue(report); return(result); }