Exemplo n.º 1
0
        /// <summary>
        /// Draw the inspector GUI.
        /// </summary>
        public override void OnInspectorGUI()
        {
            GUI.enabled = true;
            var path         = AssetDatabase.GetAssetPath(target);
            var importerData = SceneImporterData.GetAtPath(path);

            GUILayout.Space(10);
            EditorGUI.BeginChangeCheck();
            var liveLinkEnabled = EditorGUILayout.Toggle(new GUIContent("LiveLink Enabled"), !importerData.DisableLiveLink);

            if (EditorGUI.EndChangeCheck())
            {
                SceneImporterData.SetAtPath(path, new SceneImporterData()
                {
                    DisableLiveLink = !liveLinkEnabled
                });
                var scene = UnityEditor.SceneManagement.EditorSceneManager.GetSceneByPath(path);
                if (scene.isLoaded)
                {
                    UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(scene);
                }
                else
                {
                    AssetDatabase.ImportAsset(path);
                }
            }
        }
Exemplo n.º 2
0
        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 });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Draw the inspector GUI.
        /// </summary>
        public override void OnInspectorGUI()
        {
            GUI.enabled = true;
            var path         = AssetDatabase.GetAssetPath(target);
            var importerData = SceneImporterData.GetAtPath(path);

            GUILayout.Space(10);
            EditorGUI.BeginChangeCheck();
            var liveLinkEnabled = EditorGUILayout.Toggle(new GUIContent("LiveLink Enabled"), !importerData.DisableLiveLink);

            if (EditorGUI.EndChangeCheck())
            {
                SceneImporterData.SetAtPath(path, new SceneImporterData()
                {
                    DisableLiveLink = !liveLinkEnabled
                });
            }
        }
        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));
        }
Exemplo n.º 5
0
        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();
            }
        }
Exemplo n.º 6
0
        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);
        }