[Unity]禁用Unity-Lighting中的Auto Generate选项

2020/01 11 00:01

以Unity2018.4为例,每次新建场景,这个Auto Generate总是勾着的
Unity后台的自动烘焙线程就一直在进行,然后电脑就卡卡卡,这真是一个悲(失)伤(败)的设计

如何禁用这个功能(勾)呢?把这段代码放进工程就OK了:

using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;

[InitializeOnLoad]
public static class EditorDisableAutoGenerateLighting
{
    static EditorDisableAutoGenerateLighting()
    {
        EditorSceneManager.sceneOpened += OnSceneOpend;
        EditorSceneManager.newSceneCreated += OnSceneNewCreate;
    }

    private static void DisableAutoGenerateLighting()
    {
        Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;
    }

    public static void OnSceneOpend(Scene scene, OpenSceneMode mode)
    {
        DisableAutoGenerateLighting();
    }

    public static void OnSceneNewCreate(Scene scene, NewSceneSetup setup, NewSceneMode mode)
    {
        DisableAutoGenerateLighting();
    }
}

--转载请注明: http://blog.coolcoding.cn/?p=930