public void BakeApply() { if (!HasBakeData) { BakeJustApplied = false; return; } if (!BakeApplied) { BakeJustApplied = RuntimeBakedLightmapUtils.InitializeInstance(this); #if UNITY_EDITOR // if (BakeJustApplied) Debug.LogWarning("[PrefabBaker] Addeded prefab lightmap data to current scene " + name); if (!Application.isPlaying) { RuntimeBakedLightmapUtils.UpdateUnityLightMaps(); } #endif } for (var i = 0; i < renderers.Length; ++i) { renderers[i].lightmapScaleOffset = renderersLightmapOffsetScale[i]; } }
private void OnEnable() { // ActionOnEnable(); // uncomment to use textures right away RuntimeBakedLightmapUtils.AddInstanceRef(this); PrefabBakerManager.AddInstance(this); SceneManager.sceneLoaded += OnSceneLoaded; }
public void ActionOnDisable() { if (RuntimeBakedLightmapUtils.CheckInstance(this)) { BakeJustApplied = false; // Debug.LogWarning(" Removing Prefab lightMap " + name); } RefAdded = false; }
private void OnDisable() { // ActionOnDisable(); // uncomment to use textures right away RuntimeBakedLightmapUtils.RemoveInstanceRef(this); // RefAdded = false; PrefabBakerManager.RemoveInstance(this); SceneManager.sceneLoaded -= OnSceneLoaded; }
static void OnBakeComplete() { // 4. Clear progress & events BakeFinished(); // 5. Fetch lightmaps, apply to prefab and save them in selected folder SaveLightmaps(); if (Window.AutoClean) { // 6. Delete scene lightmap data Lightmapping.ClearLightingDataAsset(); Lightmapping.ClearDiskCache(); Lightmapping.Clear(); } // 7. Combine prefab lightmaps with scene lightmaps EditorUtils.GetAllPrefabs().ForEach(x => RuntimeBakedLightmapUtils.InitializeInstance(x)); }
private static IEnumerator WorkingCoroutine() { yield return(null); // Lazy loaded enumerated int count = 0; int adding; RuntimeBakedLightmapUtils.ClearAndAddUnityLightMaps(); foreach (var item in AddOrRemove) { adding = 0; if (item.Key != null) { if (item.Value) { if (!item.Key.RefAdded) { adding = 1; item.Key.ActionOnEnable(); } } else { if (item.Key.RefAdded) { adding = 1; item.Key.ActionOnDisable(); } } if (RuntimeBakedLightmapUtils.IsLightMapsChanged) { RuntimeBakedLightmapUtils.IsLightMapsChanged = false; count += adding; if (count % COUNT_FRAMES == 0) { adding = 0; RuntimeBakedLightmapUtils.UpdateUnityLightMaps(); yield return(null); RuntimeBakedLightmapUtils.ClearAndAddUnityLightMaps(); } } } else { foreach (var lightmapCheckRemove in AddOrRemoveToCheck) { adding = 0; if (RuntimeBakedLightmapUtils.CheckInstance(lightmapCheckRemove.Key)) { adding = 1; // Debug.LogWarning(" Removing Prefab lightMap " + lightmapCheckRemove.Value); } count += adding; if (RuntimeBakedLightmapUtils.IsLightMapsChanged) { RuntimeBakedLightmapUtils.IsLightMapsChanged = false; count += adding; if (count % COUNT_FRAMES == 0) { adding = 0; RuntimeBakedLightmapUtils.UpdateUnityLightMaps(); yield return(null); RuntimeBakedLightmapUtils.ClearAndAddUnityLightMaps(); } } } } } if (count > 0) { RuntimeBakedLightmapUtils.UpdateUnityLightMaps(); } RuntimeBakedLightmapUtils.ClearAndAddUnityLightMaps(false); AddOrRemove.Clear(); toRun = null; }