Esempio n. 1
0
    static void GenerateLightmapInfo()
    {
        Debug.ClearDeveloperConsole();

        if (Lightmapping.giWorkflowMode != Lightmapping.GIWorkflowMode.OnDemand)
        {
            Debug.LogError("ExtractLightmapData requires that you have baked you lightmaps and Auto mode is disabled.");
            return;
        }

        Lightmapping.Bake();

        string lightMapPath = System.IO.Path.Combine(Directory.GetCurrentDirectory(), LIGHTMAP_RESOURCE_PATH);

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

        sceneLightmaps = new List <Texture2D_Remap>();

        //var scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
        var sceneName    = Path.GetFileNameWithoutExtension(EditorSceneManager.GetActiveScene().path);
        var resourcePath = LIGHTMAP_RESOURCE_PATH + sceneName;
        var scenePath    = System.IO.Path.GetDirectoryName(EditorSceneManager.GetActiveScene().path) + "/" + sceneName + "/";

        PrefabLightmapData[] prefabs = FindObjectsOfType <PrefabLightmapData>();

        foreach (var instance in prefabs)
        {
            var gameObject    = instance.gameObject;
            var rendererInfos = new List <RendererInfo>();
            var lightmaps     = new List <Texture2D>();
            var lightmaps2    = new List <Texture2D>();

            GenerateLightmapInfo(scenePath, resourcePath, gameObject, rendererInfos, lightmaps, lightmaps2);

            instance.m_RendererInfo = rendererInfos.ToArray();
            instance.m_Lightmaps    = lightmaps.ToArray();
            instance.m_Lightmaps2   = lightmaps2.ToArray();

            // var targetPrefab = PrefabUtility.GetCorrespondingObjectFromSource(gameObject);
            var parent     = PrefabUtility.GetCorrespondingObjectFromSource(gameObject);
            var parentPath = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(parent);
            PrefabUtility.SaveAsPrefabAsset(gameObject, parentPath);
            //if (targetPrefab != null)
            //{
            //    //Prefab

            //    //PrefabUtility.ReplacePrefab(gameObject, targetPrefab);
            //}

            ApplyLightmaps(instance.m_RendererInfo, instance.m_Lightmaps, instance.m_Lightmaps2);
        }

        Debug.Log("Update to prefab lightmaps finished");
    }
Esempio n. 2
0
    static private void CreateCubeMap(int px)
    {
        // Set reflection probe.
        GameObject       probeGo = new GameObject("CubeMap Capture Probe");
        ReflectionProbe  probe   = probeGo.AddComponent <ReflectionProbe>();
        SerializedObject probeSo = new SerializedObject(probe);

        probeGo.transform.position = Vector3.zero;
        probeGo.transform.rotation = Quaternion.identity;

        // Some Settings here if you want.
        probe.mode          = UnityEngine.Rendering.ReflectionProbeMode.Custom;
        probe.resolution    = px;
        probe.hdr           = false;
        probe.boxProjection = false;

        probeSo.Update();
        probeSo.FindProperty("m_RenderDynamicObjects").boolValue = true;
        probeSo.ApplyModifiedProperties();

        // Create default path.
        string ext  = probe.hdr ? "exr" : "png";
        string path = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().path;

        if (!string.IsNullOrEmpty(path))
        {
            path = System.IO.Path.GetDirectoryName(path);
        }

        if (string.IsNullOrEmpty(path))
        {
            path = "Assets";
        }
        else if (System.IO.Directory.Exists(path))
        {
            System.IO.Directory.CreateDirectory(path);
        }

        // Show the file saving panel.
        string filename = "name" + ext;

        filename = System.IO.Path.GetFileNameWithoutExtension(AssetDatabase.GenerateUniqueAssetPath(System.IO.Path.Combine(path, filename)));
        path     = EditorUtility.SaveFilePanelInProject("Save CubeMap", filename, ext, "", path);

        if (!string.IsNullOrEmpty(path))
        {
            // Bake
            EditorUtility.DisplayProgressBar("CubeMap", "Baking...", 0.5f);
            if (!Lightmapping.BakeReflectionProbe(probe, path))
            {
                Debug.LogError("Failed to bake cubemap");
            }
            EditorUtility.ClearProgressBar();
        }

        GameObject.DestroyImmediate(probeGo);
    }
Esempio n. 3
0
    public static void bake_light_maps()
    {
        //Bake Lighting settings

        Lightmapping.giWorkflowMode           = Lightmapping.GIWorkflowMode.OnDemand;
        LightmapEditorSettings.bakeResolution = 1f;
        Lightmapping.realtimeGI = false; // Realtime GI does not show up on WebGL build
        Lightmapping.Bake();
    }
Esempio n. 4
0
        public EasyPipeline(bool useSRPBatching, float shadowFadeRange)
        {
            GraphicsSettings.useScriptableRenderPipelineBatching = useSRPBatching;
            GraphicsSettings.lightsUseLinearIntensity            = (QualitySettings.activeColorSpace == ColorSpace.Linear);
#if UNITY_EDITOR
            Lightmapping.SetDelegate(lightmappingLightsDelegate);
#endif
            globalShadowData.y = 1f / shadowFadeRange;
        }
Esempio n. 5
0
    static void BekeCancel()
    {
        if (!Lightmapping.isRunning)
        {
            return;
        }

        Lightmapping.Cancel();
    }
    static void CreateLightmapAllScene()
    {
        string nowSceneName = EditorSceneManager.GetActiveScene().path;

        EditorSceneManager.OpenScene("Assets/Example/Scenes/CompleteScene.unity");
        Lightmapping.Bake();
        EditorSceneManager.OpenScene("Assets/Example/Scenes/Workshop01.unity");
        Lightmapping.Bake();
        EditorSceneManager.OpenScene(nowSceneName);
    }
Esempio n. 7
0
    public void GenerateLighting()
    {
        Ceiling.SetActive(true);

        Lightmapping.BakeAsync();
        Lightmapping.completed = () =>
        {
            Ceiling.SetActive(false);
        };
    }
Esempio n. 8
0
        static void BakeUpdate( )
        {
            var p = Lightmapping.buildProgress;

            if (EditorUtility.DisplayCancelableProgressBar("Boiling Prefabs", "Baking them lights...", p))
            {
                Lightmapping.ForceStop( );

                BakeFinished( );
            }
        }
Esempio n. 9
0
    protected static void SetupLightingSettings()
    {
        LightingSettings lightingSettings = null;

        Lightmapping.TryGetLightingSettings(out lightingSettings);
        Assert.IsTrue(lightingSettings != null, "Lighting settings are available.");
        lightingSettings.lightmapper    = LightingSettings.Lightmapper.ProgressiveGPU;
        lightingSettings.prioritizeView = true;
        Assert.IsTrue(lightingSettings.lightmapper == LightingSettings.Lightmapper.ProgressiveGPU, "Using GPU Lightmapper.");
        Assert.IsTrue(lightingSettings.prioritizeView, "Using Progressive.");
    }
Esempio n. 10
0
        protected void BakeAllScenes()
        {
            // close all open scenes
            CloseOpenScenes();

            SetBakeToManual();
            // force save
            EditorSceneManager.SaveScene(GetSceneManagerScene());
            // start baking everything
            Lightmapping.BakeMultipleScenes(ManagedScenePaths().ToArray());
        }
    public static void saveToNewScene()
    {
        string folderName   = "Autosaved Scenes";
        string newTimestamp = "TS-" + getTimestamp(DateTime.Now, true, true);

        int tsLength = newTimestamp.Length;

        string newSceneName, oldSceneName;
        Scene  newScene;

        int length = EditorSceneManager.GetActiveScene().name.IndexOf("TS-"); // delimiter

        // create the new scene
        // if we are not currently in a scene

        if (EditorSceneManager.GetActiveScene().name == "") // if we are not in a scene
        {
            newSceneName = "Autosaved Scene" + newTimestamp;
            oldSceneName = "";

            newScene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
        }

        else // if we are in a scene
        {
            if (length < 0) // if the scene name does not contain the delimiter
            {
                newSceneName = "Test Scene" + " " + newTimestamp;

                oldSceneName = EditorSceneManager.GetActiveScene().name;
            }
            // if there is an open scene
            else
            {
                // Get the new scene name
                oldSceneName = EditorSceneManager.GetActiveScene().name;

                newSceneName = oldSceneName.Substring(0, length - 1) + " " + newTimestamp;
                // got the new scene name
            }
            // create new scene
            newScene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);

            // copy everything from old scene into new scene
            EditorSceneManager.MergeScenes(EditorSceneManager.GetSceneByName(oldSceneName), newScene);
            // copied everything from old scene into new scene
        }

        string savedScene = currentFolderPath + folderName + "/" + newSceneName + ".unity";

        EditorSceneManager.SaveScene(newScene, savedScene, false);
        Lightmapping.Bake();
    }
    public void Setup()
    {
#if UNITY_EDITOR
        // Search for "InitTestSceneXXXXXXXX" generated by test runner and save the path in the EditorPrefs
        for (int i = 0; i < EditorSceneManagement.EditorSceneManager.sceneCount; ++i)
        {
            Scene scene = EditorSceneManagement.EditorSceneManager.GetSceneAt(i);
            if (scene.name.StartsWith("InitTestScene"))
            {
                EditorPrefs.SetString("InitTestScene", scene.path);
                break;
            }
        }

        string scenesWithAutoLightMap = "";

        // For each scene in the build settings, force build of the lightmaps if it has "DoLightmap" label.
        foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
        {
            SceneAsset sceneAsset = AssetDatabase.LoadAssetAtPath <SceneAsset>(scene.path);
            var        labels     = new System.Collections.Generic.List <string>(AssetDatabase.GetLabels(sceneAsset));

            if (labels.Contains("DoLightmap"))
            {
                EditorSceneManagement.EditorSceneManager.OpenScene(scene.path, EditorSceneManagement.OpenSceneMode.Single);

                Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;
                EditorSceneManagement.EditorSceneManager.SaveOpenScenes();

                Lightmapping.Clear();
                Lightmapping.Bake();

                scenesWithAutoLightMap += scene.path + ";";

                EditorSceneManagement.EditorSceneManager.SaveOpenScenes();

                Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.Iterative;
                EditorSceneManagement.EditorSceneManager.SaveOpenScenes();

                EditorSceneManagement.EditorSceneManager.NewScene(EditorSceneManagement.NewSceneSetup.EmptyScene);
            }
        }

        EditorPrefs.SetString("ScenesWithAutoLightMap", scenesWithAutoLightMap);

        // Re-open testrunner scene
        string initTestSceneString = EditorPrefs.GetString("InitTestScene");
        if (!string.IsNullOrEmpty(initTestSceneString))
        {
            EditorSceneManagement.EditorSceneManager.OpenScene(initTestSceneString, EditorSceneManagement.OpenSceneMode.Single);
        }
#endif
    }
        protected override ActionResult PerformActionImplementation()
        {
            var res = Lightmapping.RebuildMissingLightmapUVs(Object.FindObjectsOfType <ProBuilderMesh>(), true);

            if (res < 1)
            {
                return(new ActionResult(ActionResult.Status.Success, "No Missing Lightmap UVs Found"));
            }

            return(new ActionResult(ActionResult.Status.Success, "Generate Lightmap UVs\n" +
                                    (res > 1 ? string.Format("for {0} objects", res) : "for 1 object")));
        }
Esempio n. 14
0
        public IEnumerator DefaultUnwrapParamsDoNotOverlap()
        {
            var lightmapMode = Lightmapping.giWorkflowMode;

            try
            {
                Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;

                Lightmapping.started += LightmappingStarted;

                if (Lightmapping.completed == null)
                {
                    Lightmapping.completed = LightmappingCompleted;
                }
                else
                {
                    Lightmapping.completed += LightmappingCompleted;
                }

                Setup();

                float x = -10f;

                using (var shapes = new TestUtility.BuiltInPrimitives())
                {
                    SceneModeUtility.SetStaticFlags(shapes.Select(it => it.gameObject).ToArray(), (int)StaticEditorFlags.LightmapStatic, true);

                    foreach (ProBuilderMesh mesh in shapes)
                    {
                        mesh.transform.position = new Vector3(x, 0f, 0f);
                        x += mesh.mesh.bounds.size.x + .5f;
                        mesh.Optimize(true);
                    }

                    Lightmapping.BakeAsync();

                    while (!s_FinishedBaking)
                    {
                        yield return(null);
                    }

                    LogAssert.NoUnexpectedReceived();
                }
            }
            finally
            {
                Lightmapping.started       -= LightmappingStarted;
                Lightmapping.completed     -= LightmappingCompleted;
                Lightmapping.giWorkflowMode = lightmapMode;
                Cleanup();
            }
        }
Esempio n. 15
0
        void ProcessMaps()
        {
            var currentScene = EditorSceneManager.GetActiveScene().path;
            var buildScenes  = new List <EditorBuildSettingsScene>(EditorBuildSettings.scenes);

            buildScenes.Clear();
            try
            {
                foreach (var item in AssetDatabase.FindAssets("t:" + typeof(SceneAsset).Name))
                {
                    EditorUtility.DisplayProgressBar("Loading scenes", string.Empty, 5);
                    var asset = AssetDatabase.GUIDToAssetPath(item);
                    if (string.IsNullOrEmpty(asset))
                    {
                        continue;
                    }
                    buildScenes.Add(new EditorBuildSettingsScene(asset, true));
                }
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
            try
            {
                EditorBuildSettings.scenes = buildScenes.ToArray();
                for (int i = 0; i < buildScenes.Count; i++)
                {
                    EditorUtility.DisplayProgressBar("Processing scene", buildScenes[i].path, Mathf.Clamp01((float)i / buildScenes.Count));
                    var scene = EditorSceneManager.OpenScene(buildScenes[i].path, OpenSceneMode.Single);
                    EditorSceneManager.SetActiveScene(scene);
                    foreach (var actor in FindObjectsOfType <Actor>())
                    {
                        actor.transform.position = actor.Location;
                        EditorUtility.SetDirty(actor);
                    }
                    RenderSettings.skybox                = null;
                    RenderSettings.ambientMode           = UnityEngine.Rendering.AmbientMode.Flat;
                    RenderSettings.defaultReflectionMode = UnityEngine.Rendering.DefaultReflectionMode.Custom;
                    Lightmapping.bakedGI    = false;
                    Lightmapping.realtimeGI = false;
                    Lightmapping.Clear();
                    EditorSceneManager.MarkSceneDirty(scene);
                    EditorSceneManager.SaveScene(scene);
                }
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
            EditorSceneManager.OpenScene(currentScene, OpenSceneMode.Single);
        }
Esempio n. 16
0
    void OnGUI()
    {
        _pathToScenes = EditorGUILayout.TextField("Path To Scenes", _pathToScenes);
        GUILayout.Space(1);
        _lightMapResIndex = EditorGUILayout.Popup("Lightmap resolution", _lightMapResIndex, _lightmapResolution);

        GUILayout.Space(1);

        var paths = new string[] { _pathToScenes };

        var p    = AssetDatabase.FindAssets("t:scene", paths);
        var list = new List <string>();

        _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);
        foreach (var item in p)
        {
            var i = AssetDatabase.GUIDToAssetPath(item);
            list.Add(i);
            if (!_sceneToggle.ContainsKey(i))
            {
                _sceneToggle.Add(i, false);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Toggle(_sceneToggle[i]);
            EditorGUILayout.LabelField(i);
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndScrollView();

        if (GUILayout.Button("BAKE LIGHTS !") && !_baking)
        {
            _baking = true;
            BakeLights(list);
        }

        if (_baking)
        {
            EditorGUILayout.LabelField("Scenes Already Baked and Baking:");
            foreach (var item in _scenesBuilt)
            {
                var splitted = item.Split('/');
                EditorGUILayout.LabelField(splitted[splitted.Length - 1]);
            }
            if (GUILayout.Button("FORCE STOP BAKING !"))
            {
                Lightmapping.ForceStop();
                _baking      = false;
                _sceneToggle = new Dictionary <string, bool>();
            }
        }
    }
Esempio n. 17
0
    static void Bake()
    {
        GameObject[] emissiveObjects = GameObject.FindGameObjectsWithTag("CustomEmissive");

        foreach (GameObject emissiveObject in emissiveObjects)
        {
            Material material = emissiveObject.GetComponent <Renderer>().sharedMaterial;

            material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.BakedEmissive;
        }

        Lightmapping.Bake();
    }
Esempio n. 18
0
 void bakeAllScenes()
 {
     scenesToBake = ReadNames();
     //m_baking = true;
     for (int i = 1; i < scenesToBake.Length; i++)
     {
         EditorApplication.OpenScene(scenesToBake[i]);
         setUpScene();
         Lightmapping.Clear();
         Lightmapping.Bake();
         EditorApplication.SaveScene(scenesToBake[i]);
     }
 }
Esempio n. 19
0
        public static void StopBake()
        {
            if (!Lightmapping.isRunning)
            {
                return;
            }

            Lightmapping.Cancel();
            if (Lightmapping.isRunning)
            {
                Lightmapping.ForceStop();
            }
        }
    public IEnumerator ActivateDirectLighting_DuringABake_DoesNotFallback()
    {
        EditorSceneManager.OpenScene("Assets/Tests/Editor/Tests_Unit_Editmode/BakeRestartScene.unity", OpenSceneMode.Single);
        yield return(null);

        LightingSettings lightingSettings = null;

        Lightmapping.TryGetLightingSettings(out lightingSettings);

        Assert.That(lightingSettings, !Is.EqualTo(null), "LightingSettings is null");

        lightingSettings.lightmapper        = LightingSettings.Lightmapper.ProgressiveGPU;
        lightingSettings.mixedBakeMode      = MixedLightingMode.IndirectOnly;
        lightingSettings.directionalityMode = LightmapsMode.NonDirectional;

        GameObject dirLightGO = GameObject.FindGameObjectsWithTag("TheLight")[0];

        dirLightGO.SetActive(false);
        Light light = dirLightGO.GetComponent(typeof(Light)) as Light;

        light.lightmapBakeType = LightmapBakeType.Baked;

        Lightmapping.Clear();
        Lightmapping.BakeAsync();

        foreach (bool b in RunABake(0.2f))
        {
            yield return(null);
        }

        // Make sure it is still baking before we
        // switch the light on and restart the bake
        Assert.IsTrue(Lightmapping.isBaking);

        // Activate the light, cause the bake to restart
        dirLightGO.SetActive(true);

        foreach (bool b in RunABake(0.2f))
        {
            yield return(null);
        }

        // Check that baking is still running
        Assert.IsTrue(Lightmapping.isBaking);
        // Check that we did not fallback to CPULM
        Assert.AreEqual(lightingSettings.lightmapper, LightingSettings.Lightmapper.ProgressiveGPU);

        Lightmapping.Cancel();
        Lightmapping.Clear();
        Lightmapping.ClearLightingDataAsset();
    }
Esempio n. 21
0
        /// <inheritdoc />
        protected override bool OnStepStart()
        {
            if (ClearDiskCache)
            {
                Lightmapping.ClearDiskCache();
            }

            if (ClearLightingDataAsset)
            {
                Lightmapping.ClearLightingDataAsset();
            }

            return(true);
        }
Esempio n. 22
0
        public static void BakePrefabLightmaps()
        {
            if (Lightmapping.giWorkflowMode != Lightmapping.GIWorkflowMode.OnDemand)
            {
                Debug.LogError("ExtractLightmapData requires that you have baked you lightmaps and Auto mode is disabled.");
                return;
            }

            PrefabLightmapData[] prefabs = Object.FindObjectsOfType <PrefabLightmapData>();
            MakeSureRendererGameObjectIsLightmapStatic(prefabs);

            // Bake lightmap for scene.
            Lightmapping.Bake();
        }
Esempio n. 23
0
    IEnumerator Start()
    {
        yield return(new WaitForSeconds(0.5f));

        foreach (var probe in refProbe)
        {
            Lightmapping.BakeReflectionProbe(probe, "Assets/" + probe.ToString() + ".hdr");
            HDAdditionalReflectionData addRefData = probe.gameObject.GetComponent <HDAdditionalReflectionData>();

            Texture texture = (Texture)AssetDatabase.LoadAssetAtPath("Assets/" + probe.ToString() + ".hdr", typeof(Texture));
            addRefData.bakedTexture = texture;
            yield return(null);
        }
    }
    static void LightmapSaverEditorSimplePasses() {
        LightmapSaver[] dataHolders = GameObject.FindObjectsOfType<LightmapSaver>();
        for(int i = 0; i < dataHolders.Length; i++)
        {
            var holder = dataHolders[i];
            GameObject root = holder.gameObject;
            LightmapSaver pSaver = root.GetComponentInParent<LightmapSaver>();
            if(null != pSaver && pSaver.gameObject != root)
            {
                EditorUtility.DisplayDialog("错误", string.Format("游戏物体{0}的父节点{1}包含有 LightmapSaver 组件,这是不允许的。", root.gameObject.name, pSaver.gameObject.name),"确定");
                return;
            }
            var cSaver = root.GetComponentInChildren<LightmapSaver>();
            if(null != cSaver && cSaver.gameObject != root)
            {
                EditorUtility.DisplayDialog("错误", string.Format("游戏物体{0}的子节点{1}包含有 LightmapSaver 组件,这是不允许的。", root.gameObject.name, cSaver.gameObject.name), "确定");
                return;
            }

            Lightmapping.Clear();
            Lightmapping.Bake();//开始烘焙

            var renderers = root.GetComponentsInChildren<Renderer>(true);

            holder.RendererData = new LightmapSaver.LightmapRendererData[renderers.Length];
            for (int j = 0; j < renderers.Length; j++)
            {
                var renderer = renderers[j];
                holder.RendererData[j] = new LightmapSaver.LightmapRendererData();
                Debug.Log(renderer.gameObject.name);
                if (renderer.lightmapIndex == -1) continue;
                var rendererData = holder.RendererData[j];
                rendererData.renderer = renderer;
                rendererData.lightmapIndex = renderer.lightmapIndex;
                rendererData.lightmapScaleOffset = renderer.lightmapScaleOffset;
            }
            if(LightmapSettings.lightmaps.Length > 0)
            {
                holder.lightmapColor = LightmapSettings.lightmaps[0].lightmapColor;
                holder.lightmapDir = LightmapSettings.lightmaps[0].lightmapDir;
            }
            else
            {
                EditorUtility.DisplayDialog("烘焙失败", "没有成功生成光照贴图。", "确定");
                return;
            }
        }
        EditorUtility.DisplayDialog("烘焙成功", "烘焙已经完成。", "确定");
    }
Esempio n. 25
0
    private IEnumerator BuildLightingAsync(string ScenarioName)
    {
        var newLightmapMode = new LightmapsMode();

        newLightmapMode = LightmapSettings.lightmapsMode;
        Lightmapping.BakeAsync();
        while (Lightmapping.isRunning)
        {
            yield return(null);
        }
        Lightmapping.lightingDataAsset = null;
        EditorSceneManager.SaveScene(EditorSceneManager.GetSceneByPath("Assets/Scenes/" + ScenarioName + ".unity"));
        EditorSceneManager.CloseScene(EditorSceneManager.GetSceneByPath("Assets/Scenes/" + ScenarioName + ".unity"), true);
        LightmapSettings.lightmapsMode = newLightmapMode;
    }
Esempio n. 26
0
    private IEnumerator BuildLightingAsync(Scene lightingScene)
    {
        var newLightmapMode = new LightmapsMode();

        newLightmapMode = LightmapSettings.lightmapsMode;
        Lightmapping.BakeAsync();
        while (Lightmapping.isRunning)
        {
            yield return(null);
        }
        //Lightmapping.lightingDataAsset = null;
        EditorSceneManager.SaveScene(lightingScene);
        EditorSceneManager.CloseScene(lightingScene, true);
        LightmapSettings.lightmapsMode = newLightmapMode;
    }
Esempio n. 27
0
    private IEnumerator BuildLightingAsync(string ScenarioName)
    {
        var newLightmapMode = new LightmapsMode();

        newLightmapMode = LightmapSettings.lightmapsMode;
        Lightmapping.BakeAsync();
        while (Lightmapping.isRunning)
        {
            yield return(null);
        }
        Lightmapping.lightingDataAsset = null;
        EditorSceneManager.SaveScene(EditorSceneManager.GetSceneByPath("Assets/Scenes/MapData_1212/UPBR_daytime001.unity"));
        //   EditorSceneManager.SaveScene(EditorSceneManager.GetSceneByPath("Assets/Scenes/MapData_1122/UPBR001.unity"));
        LightmapSettings.lightmapsMode = newLightmapMode;
    }
Esempio n. 28
0
    // [MenuItem("Tool/BakeLightMap", priority = 1001)]
    public static void BakeLightMap(Lightmapping.OnCompletedFunction complete)
    {
        string tempPath = MapScenePath + "/Map";

        if (Directory.Exists(tempPath))
        {
            Directory.Delete(tempPath, true);
            AssetDatabase.Refresh();
        }
        //Debug.Log("giWorkflowMode :" + Lightmapping.giWorkflowMode);
        Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;
        Lightmapping.completed      = complete;
        Lightmapping.Clear();
        Lightmapping.Bake();
    }
Esempio n. 29
0
 // Loop through scenes to bake and update on progress
 private void BakeNewScene()
 {
     if (sceneIndex < scenes.Length)
     {
         EditorApplication.OpenScene(scenePath[sceneIndex]);
         timeStamp = System.DateTime.Now;
         Lightmapping.BakeAsync();
         UpdateBakeProgress();
         sceneIndex++;
     }
     else
     {
         DoneBaking("done");
     }
 }
Esempio n. 30
0
    public static void BakeAndCall()
    {
        var result = Lightmapping.Bake();

        SendWebHookInternal($"Lightmapping.Bake Complete. result is {result}", (isSuccess, msg) =>
        {
            if (!isSuccess)
            {
                Debug.LogError("Send Fail. Error with  :" + msg);
                return;
            }

            Debug.Log("Sent successfully");
        });
    }