Allows to control the lightmapping job.

        private bool?GetBakeMode()
        {
            if (!showBakeMode)
            {
                return(null);
            }

            return(Lightmapping.GetLightingSettingsOrDefaultsFallback().autoGenerate);
        }
Esempio n. 2
0
        private string GetBakeModeString()
        {
            if (!showBakeMode)
            {
                return("");
            }

            return("Auto Generate Lighting " + (Lightmapping.GetLightingSettingsOrDefaultsFallback().autoGenerate ? "On" : "Off"));
        }
Esempio n. 3
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            GUILayout.Label(Styles.precomputedRealtimeGIContent, EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(m_Resolution, Styles.resolutionContent);
            EditorGUILayout.Slider(m_ClusterResolution, 0.1F, 1.0F, Styles.clusterResolutionContent);
            EditorGUILayout.IntSlider(m_IrradianceBudget, 32, 2048, Styles.irradianceBudgetContent);
            EditorGUILayout.IntSlider(m_IrradianceQuality, 512, 131072, Styles.irradianceQualityContent);
            EditorGUILayout.Slider(m_ModellingTolerance, 0.0f, 1.0f, Styles.modellingToleranceContent);
            EditorGUILayout.PropertyField(m_EdgeStitching, Styles.edgeStitchingContent);
            EditorGUILayout.PropertyField(m_IsTransparent, Styles.isTransparent);
            EditorGUILayout.PropertyField(m_SystemTag, Styles.systemTagContent);
            EditorGUILayout.Space();

            bool usesPathTracerBakeBackend = Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper != LightingSettings.Lightmapper.Enlighten;
            bool usesEnlightenBackend      = Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper == LightingSettings.Lightmapper.Enlighten;

            GUILayout.Label(Styles.bakedGIContent, EditorStyles.boldLabel);
            using (new EditorGUI.DisabledScope(usesPathTracerBakeBackend))
            {
                EditorGUILayout.PropertyField(m_BlurRadius, Styles.blurRadiusContent);
            }
            EditorGUILayout.PropertyField(m_AntiAliasingSamples, Styles.antiAliasingSamplesContent);
            using (new EditorGUI.DisabledScope(usesPathTracerBakeBackend))
            {
                EditorGUILayout.PropertyField(m_DirectLightQuality, Styles.directLightQualityContent);
            }
            EditorGUILayout.Slider(m_Pushoff, 0.0f, 1.0f, Styles.pushoffContent);
            EditorGUILayout.PropertyField(m_BakedLightmapTag, Styles.bakedLightmapTagContent);
            using (new EditorGUI.DisabledScope(usesEnlightenBackend))
            {
                m_LimitLightmapCount.boolValue = EditorGUILayout.Toggle(Styles.limitLightmapCount, m_LimitLightmapCount.boolValue);
                if (m_LimitLightmapCount.boolValue)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(m_LightmapMaxCount, Styles.lightmapMaxCount);
                    EditorGUI.indentLevel--;
                }
            }
            EditorGUILayout.Space();

            using (new EditorGUI.DisabledScope(usesPathTracerBakeBackend))
            {
                GUILayout.Label(Styles.bakedAOContent, EditorStyles.boldLabel);
                EditorGUILayout.PropertyField(m_AOQuality, Styles.aoQualityContent);
                EditorGUILayout.PropertyField(m_AOAntiAliasingSamples, Styles.aoAntiAliasingSamplesContent);
            }

            GUILayout.Label(Styles.generalGIContent, EditorStyles.boldLabel);
            EditorGUILayout.Slider(m_BackFaceTolerance, 0.0f, 1.0f, Styles.backFaceToleranceContent);

            serializedObject.ApplyModifiedProperties();
        }
        private void BakeCustomReflectionProbe(ReflectionProbe probe, bool usePreviousAssetPath)
        {
            string path = "";

            if (usePreviousAssetPath)
            {
                path = AssetDatabase.GetAssetPath(probe.customBakedTexture);
            }

            string targetExtension = probe.hdr ? "exr" : "png";

            if (string.IsNullOrEmpty(path) || Path.GetExtension(path) != "." + targetExtension)
            {
                // We use the path of the active scene as the target path
                string targetPath = FileUtil.GetPathWithoutExtension(SceneManager.GetActiveScene().path);
                if (string.IsNullOrEmpty(targetPath))
                {
                    targetPath = "Assets";
                }
                else if (Directory.Exists(targetPath) == false)
                {
                    Directory.CreateDirectory(targetPath);
                }

                string fileName = probe.name + (probe.hdr ? "-reflectionHDR" : "-reflection") + "." + targetExtension;
                fileName = Path.GetFileNameWithoutExtension(AssetDatabase.GenerateUniqueAssetPath(Path.Combine(targetPath, fileName)));

                path = EditorUtility.SaveFilePanelInProject("Save reflection probe's cubemap.", fileName, targetExtension, "", targetPath);
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                ReflectionProbe collidingProbe;
                if (IsCollidingWithOtherProbes(path, probe, out collidingProbe))
                {
                    if (!EditorUtility.DisplayDialog("Cubemap is used by other reflection probe",
                                                     string.Format("'{0}' path is used by the game object '{1}', do you really want to overwrite it?",
                                                                   path, collidingProbe.name), "Yes", "No"))
                    {
                        return;
                    }
                }
            }

            EditorUtility.DisplayProgressBar("Reflection Probes", "Baking " + path, 0.5f);
            if (!Lightmapping.BakeReflectionProbe(probe, path))
            {
                Debug.LogError("Failed to bake reflection probe to " + path);
            }
            EditorUtility.ClearProgressBar();
        }
Esempio n. 5
0
        static public bool LightmapParametersGUI(SerializedProperty prop, GUIContent content)
        {
            EditorGUILayout.BeginHorizontal();

            EditorGUIInternal.AssetPopup <LightmapParameters>(prop, content, "giparams", "Scene Default Parameters");

            string label = "Edit...";

            if (isBuiltIn(prop))
            {
                label = "View";
            }

            bool editClicked = false;

            // If object is null, then get the scene parameter setting and view this instead.
            if (prop.objectReferenceValue == null)
            {
                SerializedObject   so = new SerializedObject(Lightmapping.GetLightingSettingsOrDefaultsFallback());
                SerializedProperty lightmapParameters = so.FindProperty("m_LightmapParameters");

                using (new EditorGUI.DisabledScope(lightmapParameters == null))
                {
                    if (isBuiltIn(lightmapParameters))
                    {
                        label = "View";
                    }
                    else
                    {
                        label = "Edit...";
                    }

                    if (GUILayout.Button(label, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                    {
                        Selection.activeObject = lightmapParameters.objectReferenceValue;
                        editClicked            = true;
                    }
                }
            }
            else
            {
                if (GUILayout.Button(label, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                {
                    Selection.activeObject = prop.objectReferenceValue;
                    editClicked            = true;
                }
            }

            EditorGUILayout.EndHorizontal();

            return(editClicked);
        }
        void DoBakeButton()
        {
            if (reflectionProbeTarget.mode == ReflectionProbeMode.Realtime)
            {
                EditorGUILayout.HelpBox("Baking of this reflection probe should be initiated from the scripting API because the type is 'Realtime'", MessageType.Info);

                if (!QualitySettings.realtimeReflectionProbes)
                {
                    EditorGUILayout.HelpBox("Realtime reflection probes are disabled in Quality Settings", MessageType.Warning);
                }
                return;
            }

            if (reflectionProbeTarget.mode == ReflectionProbeMode.Baked && Lightmapping.giWorkflowMode != Lightmapping.GIWorkflowMode.OnDemand)
            {
                EditorGUILayout.HelpBox("Baking of this reflection probe is automatic because this probe's type is 'Baked' and the Lighting window is using 'Auto Baking'. The cubemap created is stored in the GI cache.", MessageType.Info);
                return;
            }

            GUILayout.BeginHorizontal();

            GUILayout.Space(EditorGUIUtility.labelWidth);
            switch (reflectionProbeMode)
            {
            case ReflectionProbeMode.Custom:
                if (EditorGUI.ButtonWithDropdownList(Styles.bakeCustomButtonText, Styles.bakeCustomOptionText, OnBakeCustomButton))
                {
                    BakeCustomReflectionProbe(reflectionProbeTarget, true);
                    GUIUtility.ExitGUI();
                }
                break;

            case ReflectionProbeMode.Baked:
                using (new EditorGUI.DisabledScope(!reflectionProbeTarget.enabled))
                {
                    // Bake button in non-continous mode
                    if (EditorGUI.ButtonWithDropdownList(Styles.bakeButtonText, Styles.bakeButtonsText, OnBakeButton))
                    {
                        Lightmapping.BakeReflectionProbeSnapshot(reflectionProbeTarget);
                        GUIUtility.ExitGUI();
                    }
                }

                break;

            case ReflectionProbeMode.Realtime:
                // Not showing bake button in realtime
                break;
            }

            GUILayout.EndHorizontal();
        }
Esempio n. 7
0
        void ShowRealtimeLMGUI(Terrain terrain)
        {
            Hash128 inputSystemHash;

            if (terrain == null || !Lightmapping.GetInputSystemHash(terrain.GetInstanceID(), out inputSystemHash) || inputSystemHash == new Hash128())
            {
                return; // early return since we don't have any lightmaps for it
            }
            if (!UpdateRealtimeTexture(inputSystemHash, terrain.GetInstanceID()))
            {
                return;
            }

            m_ShowRealtimeLM.value = EditorGUILayout.Foldout(m_ShowRealtimeLM.value, Styles.realtimeLM, true);

            if (!m_ShowRealtimeLM.value)
            {
                return;
            }

            EditorGUI.indentLevel += 1;

            GUILayout.BeginHorizontal();

            DrawLightmapPreview(m_CachedRealtimeTexture.texture, true, terrain.GetInstanceID());

            GUILayout.BeginVertical();

            // Resolution of the system.
            int width, height;
            int numChunksInX, numChunksInY;

            if (Lightmapping.GetTerrainSystemResolution(terrain, out width, out height, out numChunksInX, out numChunksInY))
            {
                var str = width + "x" + height;
                if (numChunksInX > 1 || numChunksInY > 1)
                {
                    str += string.Format(" ({0}x{1} chunks)", numChunksInX, numChunksInY);
                }
                GUILayout.Label(Styles.realtimeLMResolution.text + ": " + str);
            }

            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            EditorGUI.indentLevel -= 1;

            GUILayout.Space(5);
        }
Esempio n. 8
0
 private void DeveloperBuildEnlightenSettings(SerializedObject so)
 {
     if (!Unsupported.IsDeveloperBuild())
     {
         return;
     }
     this.m_ShowDevOptions = EditorGUILayout.Foldout(this.m_ShowDevOptions, "Debug [internal]");
     if (this.m_ShowDevOptions)
     {
         SerializedProperty property  = so.FindProperty("m_GISettings.m_BounceScale");
         SerializedProperty property2 = so.FindProperty("m_GISettings.m_TemporalCoherenceThreshold");
         EditorGUI.indentLevel++;
         Lightmapping.concurrentJobsType        = (Lightmapping.ConcurrentJobsType)EditorGUILayout.IntPopup(LightingWindow.styles.ConcurrentJobs, (int)Lightmapping.concurrentJobsType, this.kConcurrentJobsTypeStrings, this.kConcurrentJobsTypeValues, new GUILayoutOption[0]);
         Lightmapping.enlightenForceUpdates     = EditorGUILayout.Toggle(LightingWindow.styles.ForceUpdates, Lightmapping.enlightenForceUpdates, new GUILayoutOption[0]);
         Lightmapping.enlightenForceWhiteAlbedo = EditorGUILayout.Toggle(LightingWindow.styles.ForceWhiteAlbedo, Lightmapping.enlightenForceWhiteAlbedo, new GUILayoutOption[0]);
         Lightmapping.filterMode = (FilterMode)EditorGUILayout.EnumPopup(EditorGUIUtility.TempContent("Filter Mode"), Lightmapping.filterMode, new GUILayoutOption[0]);
         EditorGUILayout.Slider(property, 0f, 10f, LightingWindow.styles.BounceScale, new GUILayoutOption[0]);
         EditorGUILayout.Slider(property2, 0f, 1f, LightingWindow.styles.UpdateThreshold, new GUILayoutOption[0]);
         if (GUILayout.Button("Clear disk cache", new GUILayoutOption[]
         {
             GUILayout.Width(this.kButtonWidth)
         }))
         {
             Lightmapping.Clear();
             Lightmapping.ClearDiskCache();
         }
         if (GUILayout.Button("Print state to console", new GUILayoutOption[]
         {
             GUILayout.Width(this.kButtonWidth)
         }))
         {
             Lightmapping.PrintStateToConsole();
         }
         if (GUILayout.Button("Reset albedo/emissive", new GUILayoutOption[]
         {
             GUILayout.Width(this.kButtonWidth)
         }))
         {
             GIDebugVisualisation.ResetRuntimeInputTextures();
         }
         if (GUILayout.Button("Reset environment", new GUILayoutOption[]
         {
             GUILayout.Width(this.kButtonWidth)
         }))
         {
             DynamicGI.UpdateEnvironment();
         }
         EditorGUI.indentLevel--;
     }
 }
        private void LightmapPerformanceStats(int index)
        {
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label("Index: " + index, EditorStyles.miniLabel, new GUILayoutOption[0]);
            LightmapConvergence lightmapConvergence = Lightmapping.GetLightmapConvergence(index);

            if (lightmapConvergence.IsValid())
            {
                GUILayout.Label("Occupied: " + InternalEditorUtility.CountToString((ulong)((long)lightmapConvergence.occupiedTexelCount)), EditorStyles.miniLabel, new GUILayoutOption[0]);
                GUIContent content = EditorGUIUtility.TrTextContent(string.Concat(new object[]
                {
                    "Direct: ",
                    lightmapConvergence.minDirectSamples,
                    " / ",
                    lightmapConvergence.maxDirectSamples,
                    " / ",
                    lightmapConvergence.avgDirectSamples,
                    ""
                }), "min / max / avg samples per texel", null);
                GUILayout.Label(content, EditorStyles.miniLabel, new GUILayoutOption[0]);
                GUIContent content2 = EditorGUIUtility.TrTextContent(string.Concat(new object[]
                {
                    "GI: ",
                    lightmapConvergence.minGISamples,
                    " / ",
                    lightmapConvergence.maxGISamples,
                    " / ",
                    lightmapConvergence.avgGISamples,
                    ""
                }), "min / max / avg samples per texel", null);
                GUILayout.Label(content2, EditorStyles.miniLabel, new GUILayoutOption[0]);
            }
            else
            {
                GUILayout.Label("Occupied: N/A", EditorStyles.miniLabel, new GUILayoutOption[0]);
                GUILayout.Label("Direct: N/A", EditorStyles.miniLabel, new GUILayoutOption[0]);
                GUILayout.Label("GI: N/A", EditorStyles.miniLabel, new GUILayoutOption[0]);
            }
            float lightmapBakePerformance = Lightmapping.GetLightmapBakePerformance(index);

            if ((double)lightmapBakePerformance >= 0.0)
            {
                GUILayout.Label(lightmapBakePerformance.ToString("0.00") + " mrays/sec", EditorStyles.miniLabel, new GUILayoutOption[0]);
            }
            else
            {
                GUILayout.Label("N/A mrays/sec", EditorStyles.miniLabel, new GUILayoutOption[0]);
            }
            GUILayout.EndVertical();
        }
Esempio n. 10
0
        static public void LightmapParametersGUI(SerializedProperty prop, GUIContent content)
        {
            EditorGUILayout.BeginHorizontal();

            var rect = EditorGUILayout.GetControlRect();

            EditorGUI.BeginProperty(rect, content, prop);

            rect = EditorGUI.PrefixLabel(rect, content);

            GUIContent buttonContent = prop.hasMultipleDifferentValues ? EditorGUI.mixedValueContent : (prop.objectReferenceValue != null ? GUIContent.Temp(prop.objectReferenceStringValue) : Styles.lightmapParametersDefault);

            if (EditorGUI.DropdownButton(rect, buttonContent, FocusType.Passive, EditorStyles.popup))
            {
                AssetPopupBackend.ShowAssetsPopupMenu <LightmapParameters>(rect, prop.objectReferenceTypeString, prop, "giparams", Styles.lightmapParametersDefault.text);
            }

            string label = isBuiltIn(prop) ? "View" : "Edit...";

            // If object is null, then get the scene parameter setting and view this instead.
            using (new EditorGUI.DisabledScope(prop.hasMultipleDifferentValues))
            {
                if (prop.objectReferenceValue == null)
                {
                    SerializedObject   so = new SerializedObject(Lightmapping.GetLightingSettingsOrDefaultsFallback());
                    SerializedProperty lightmapParameters = so.FindProperty("m_LightmapParameters");

                    using (new EditorGUI.DisabledScope(lightmapParameters == null))
                    {
                        label = isBuiltIn(lightmapParameters) ? "View" : "Edit...";

                        if (GUILayout.Button(label, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                        {
                            Selection.activeObject = lightmapParameters.objectReferenceValue;
                        }
                    }
                }
                else
                {
                    if (GUILayout.Button(label, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
                    {
                        Selection.activeObject = prop.objectReferenceValue;
                    }
                }
            }

            EditorGUILayout.EndHorizontal();
            EditorGUI.EndProperty();
        }
Esempio n. 11
0
        private void EnlightenBakeSettings()
        {
            SerializedObject   so = new SerializedObject(LightmapEditorSettings.GetLightmapSettings());
            SerializedProperty enableRealtimeGI = so.FindProperty("m_GISettings.m_EnableRealtimeLightmaps");
            SerializedProperty enableBakedGI    = so.FindProperty("m_GISettings.m_EnableBakedLightmaps");
            bool boolValue = enableRealtimeGI.boolValue;

            this.RealtimeGUI(so, enableRealtimeGI);
            this.BakedGUI(so, enableRealtimeGI.boolValue, enableBakedGI);
            this.GeneralSettingsGUI(so, enableRealtimeGI.boolValue, enableBakedGI.boolValue);
            if ((enableBakedGI.boolValue && enableRealtimeGI.boolValue) && !boolValue)
            {
                Lightmapping.ClearPrecompSetIsDone();
            }
            so.ApplyModifiedProperties();
        }
Esempio n. 12
0
        private void EnlightenBakeSettings()
        {
            SerializedObject   serializedObject    = new SerializedObject(LightmapEditorSettings.GetLightmapSettings());
            SerializedProperty serializedProperty  = serializedObject.FindProperty("m_GISettings.m_EnableRealtimeLightmaps");
            SerializedProperty serializedProperty2 = serializedObject.FindProperty("m_GISettings.m_EnableBakedLightmaps");
            bool boolValue = serializedProperty.boolValue;

            this.RealtimeGUI(serializedObject, serializedProperty);
            this.BakedGUI(serializedObject, serializedProperty.boolValue, serializedProperty2);
            this.GeneralSettingsGUI(serializedObject, serializedProperty.boolValue, serializedProperty2.boolValue);
            if (serializedProperty2.boolValue && serializedProperty.boolValue && !boolValue)
            {
                Lightmapping.ClearPrecompSetIsDone();
            }
            serializedObject.ApplyModifiedProperties();
        }
 private void DoBakeButton()
 {
     if (this.reflectionProbeTarget.mode == ReflectionProbeMode.Realtime)
     {
         EditorGUILayout.HelpBox("Baking of this reflection probe should be initiated from the scripting API because the type is 'Realtime'", MessageType.Info);
         if (!QualitySettings.realtimeReflectionProbes)
         {
             EditorGUILayout.HelpBox("Realtime reflection probes are disabled in Quality Settings", MessageType.Warning);
         }
     }
     else if (this.reflectionProbeTarget.mode == ReflectionProbeMode.Baked && Lightmapping.giWorkflowMode != Lightmapping.GIWorkflowMode.OnDemand)
     {
         EditorGUILayout.HelpBox("Baking of this reflection probe is automatic because this probe's type is 'Baked' and the Lighting window is using 'Auto Baking'. The cubemap created is stored in the GI cache.", MessageType.Info);
     }
     else
     {
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         GUILayout.Space(EditorGUIUtility.labelWidth);
         ReflectionProbeMode reflectionProbeMode = this.reflectionProbeMode;
         if (reflectionProbeMode != ReflectionProbeMode.Custom)
         {
             if (reflectionProbeMode != ReflectionProbeMode.Baked)
             {
                 if (reflectionProbeMode != ReflectionProbeMode.Realtime)
                 {
                 }
             }
             else
             {
                 using (new EditorGUI.DisabledScope(!this.reflectionProbeTarget.enabled))
                 {
                     if (EditorGUI.ButtonWithDropdownList(ReflectionProbeEditor.Styles.bakeButtonText, ReflectionProbeEditor.Styles.bakeButtonsText, new GenericMenu.MenuFunction2(this.OnBakeButton), new GUILayoutOption[0]))
                     {
                         Lightmapping.BakeReflectionProbeSnapshot(this.reflectionProbeTarget);
                         GUIUtility.ExitGUI();
                     }
                 }
             }
         }
         else if (EditorGUI.ButtonWithDropdownList(ReflectionProbeEditor.Styles.bakeCustomButtonText, ReflectionProbeEditor.Styles.bakeCustomOptionText, new GenericMenu.MenuFunction2(this.OnBakeCustomButton), new GUILayoutOption[0]))
         {
             this.BakeCustomReflectionProbe(this.reflectionProbeTarget, true);
             GUIUtility.ExitGUI();
         }
         GUILayout.EndHorizontal();
     }
 }
Esempio n. 14
0
        void LightmapScaleGUI(bool isMeshRenderer, GUIContent title, bool isSSD)
        {
            // SSDs (with the exception of those being computed with Enlighten) do not end up in a lightmap,
            // therefore we do not show clamping information.
            if (isSSD && Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper != LightingSettings.Lightmapper.Enlighten)
            {
                return;
            }

            float lodScale      = CalcLODScale(isMeshRenderer);
            float lightmapScale = lodScale * m_LightmapScale.floatValue;

            Rect rect = EditorGUILayout.GetControlRect();

            EditorGUI.BeginProperty(rect, Styles.scaleInLightmap, m_LightmapScale);
            EditorGUI.BeginChangeCheck();
            lightmapScale = EditorGUI.FloatField(rect, title, lightmapScale);
            if (EditorGUI.EndChangeCheck())
            {
                m_LightmapScale.floatValue = Mathf.Max(lightmapScale / Mathf.Max(lodScale, float.Epsilon), 0.0f);
            }
            EditorGUI.EndProperty();

            float cachedSurfaceArea = 0.0f;

            if (isMeshRenderer)
            {
                if ((m_Renderers != null) && (m_Renderers.Length > 0))
                {
                    lightmapScale = lightmapScale * LightmapVisualization.GetLightmapLODLevelScale(m_Renderers[0]);

                    // tell the user if the object's size in lightmap has reached the max atlas size
                    cachedSurfaceArea = InternalMeshUtil.GetCachedMeshSurfaceArea((MeshRenderer)m_Renderers[0]);
                }
            }
            else //terrain
            {
                // tell the user if the object's size in lightmap has reached the max atlas size
                if ((m_Terrains != null) && (m_Terrains.Length > 0))
                {
                    var terrainData = m_Terrains[0].terrainData;
                    cachedSurfaceArea = terrainData != null ? terrainData.size.x * terrainData.size.z : 0.0f;
                }
            }

            ShowClampedSizeInLightmapGUI(lightmapScale, cachedSurfaceArea, isSSD);
        }
        public bool DoubleSidedGIField()
        {
            Rect r = GetControlRectForSingleLine();

            if (isPrefabAsset || Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper != LightingSettings.Lightmapper.Enlighten)
            {
                EditorGUI.PropertyField(r, m_DoubleSidedGI, Styles.doubleSidedGILabel);
                serializedObject.ApplyModifiedProperties();
                return(true);
            }
            else
            {
                using (new EditorGUI.DisabledScope(Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapper == LightingSettings.Lightmapper.Enlighten))
                    EditorGUI.Toggle(r, Styles.doubleSidedGILabel, false);
            }
            return(false);
        }
Esempio n. 16
0
        private void Buttons()
        {
            bool flag = Lightmapping.giWorkflowMode == Lightmapping.GIWorkflowMode.Iterative;

            if (flag)
            {
                EditorGUILayout.HelpBox("Baking of lightmaps is automatic because the workflow mode is set to 'Auto'. The lightmap data is stored in the GI cache.", MessageType.Info);
            }
            if (Lightmapping.lightingDataAsset && !Lightmapping.lightingDataAsset.isValid)
            {
                EditorGUILayout.HelpBox(Lightmapping.lightingDataAsset.validityErrorMessage, MessageType.Error);
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            EditorGUI.BeginChangeCheck();
            flag = GUILayout.Toggle(flag, LightingWindow.styles.ContinuousBakeLabel, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                Lightmapping.giWorkflowMode = ((!flag) ? Lightmapping.GIWorkflowMode.OnDemand : Lightmapping.GIWorkflowMode.Iterative);
                InspectorWindow.RepaintAllInspectors();
            }
            using (new EditorGUI.DisabledScope(flag))
            {
                bool flag2 = flag || !Lightmapping.isRunning;
                if (flag2)
                {
                    if (EditorGUI.ButtonWithDropdownList(LightingWindow.styles.BuildLabel, LightingWindow.s_BakeModeOptions, new GenericMenu.MenuFunction2(this.BakeDropDownCallback), new GUILayoutOption[]
                    {
                        GUILayout.Width(180f)
                    }))
                    {
                        this.DoBake();
                        GUIUtility.ExitGUI();
                    }
                }
                else if (GUILayout.Button("Cancel", new GUILayoutOption[]
                {
                    GUILayout.Width(this.kButtonWidth)
                }))
                {
                    Lightmapping.Cancel();
                    UsabilityAnalytics.Track("/LightMapper/Cancel");
                }
            }
            GUILayout.EndHorizontal();
        }
        private void BakeCustomReflectionProbe(ReflectionProbe probe, bool usePreviousAssetPath)
        {
            string text = "";

            if (usePreviousAssetPath)
            {
                text = AssetDatabase.GetAssetPath(probe.customBakedTexture);
            }
            string text2 = (!probe.hdr) ? "png" : "exr";

            if (string.IsNullOrEmpty(text) || Path.GetExtension(text) != "." + text2)
            {
                string text3 = FileUtil.GetPathWithoutExtension(SceneManager.GetActiveScene().path);
                if (string.IsNullOrEmpty(text3))
                {
                    text3 = "Assets";
                }
                else if (!Directory.Exists(text3))
                {
                    Directory.CreateDirectory(text3);
                }
                string text4 = probe.name + ((!probe.hdr) ? "-reflection" : "-reflectionHDR") + "." + text2;
                text4 = Path.GetFileNameWithoutExtension(AssetDatabase.GenerateUniqueAssetPath(Path.Combine(text3, text4)));
                text  = EditorUtility.SaveFilePanelInProject("Save reflection probe's cubemap.", text4, text2, "", text3);
                if (string.IsNullOrEmpty(text))
                {
                    return;
                }
                ReflectionProbe reflectionProbe;
                if (this.IsCollidingWithOtherProbes(text, probe, out reflectionProbe))
                {
                    if (!EditorUtility.DisplayDialog("Cubemap is used by other reflection probe", string.Format("'{0}' path is used by the game object '{1}', do you really want to overwrite it?", text, reflectionProbe.name), "Yes", "No"))
                    {
                        return;
                    }
                }
            }
            EditorUtility.DisplayProgressBar("Reflection Probes", "Baking " + text, 0.5f);
            if (!Lightmapping.BakeReflectionProbe(probe, text))
            {
                Debug.LogError("Failed to bake reflection probe to " + text);
            }
            EditorUtility.ClearProgressBar();
        }
Esempio n. 18
0
 public static void BakeMultipleScenes(string[] paths)
 {
     if (paths.Length != 0)
     {
         for (int i = 0; i < paths.Length; i++)
         {
             for (int j = i + 1; j < paths.Length; j++)
             {
                 if (paths[i] == paths[j])
                 {
                     throw new Exception("no duplication of scenes is allowed");
                 }
             }
         }
         if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
         {
             SceneSetup[] sceneSetup = EditorSceneManager.GetSceneManagerSetup();
             Lightmapping.OnCompletedFunction OnBakeFinish = null;
             OnBakeFinish = delegate
             {
                 EditorSceneManager.SaveOpenScenes();
                 EditorSceneManager.RestoreSceneManagerSetup(sceneSetup);
                 Lightmapping.completed = (Lightmapping.OnCompletedFunction)Delegate.Remove(Lightmapping.completed, OnBakeFinish);
             };
             EditorSceneManager.SceneOpenedCallback BakeOnAllOpen = null;
             BakeOnAllOpen = delegate(Scene scene, OpenSceneMode loadSceneMode)
             {
                 if (EditorSceneManager.loadedSceneCount == paths.Length)
                 {
                     Lightmapping.BakeAsync();
                     Lightmapping.completed          = (Lightmapping.OnCompletedFunction)Delegate.Combine(Lightmapping.completed, OnBakeFinish);
                     EditorSceneManager.sceneOpened -= BakeOnAllOpen;
                 }
             };
             EditorSceneManager.sceneOpened += BakeOnAllOpen;
             EditorSceneManager.OpenScene(paths[0]);
             for (int k = 1; k < paths.Length; k++)
             {
                 EditorSceneManager.OpenScene(paths[k], OpenSceneMode.Additive);
             }
         }
     }
 }
Esempio n. 19
0
        private void Buttons()
        {
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            EditorGUI.BeginChangeCheck();
            bool flag = Lightmapping.giWorkflowMode == Lightmapping.GIWorkflowMode.Iterative;

            flag = GUILayout.Toggle(flag, LightingWindow.styles.ContinuousBakeLabel, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                Lightmapping.giWorkflowMode = ((!flag) ? Lightmapping.GIWorkflowMode.OnDemand : Lightmapping.GIWorkflowMode.Iterative);
                InspectorWindow.RepaintAllInspectors();
            }
            EditorGUI.BeginDisabledGroup(flag);
            bool flag2 = flag || !Lightmapping.isRunning;

            if (flag2)
            {
                if (EditorGUI.ButtonWithDropdownList(LightingWindow.styles.BuildLabel, LightingWindow.s_BakeModeOptions, new GenericMenu.MenuFunction2(this.BakeDropDownCallback), new GUILayoutOption[]
                {
                    GUILayout.Width(180f)
                }))
                {
                    this.DoBake();
                    GUIUtility.ExitGUI();
                }
            }
            else
            {
                if (GUILayout.Button("Cancel", new GUILayoutOption[]
                {
                    GUILayout.Width(this.kButtonWidth)
                }))
                {
                    Lightmapping.Cancel();
                    Analytics.Track("/LightMapper/Cancel");
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
        }
Esempio n. 20
0
        private void BakeCustomReflectionProbe(ReflectionProbe probe, bool usePreviousAssetPath)
        {
            string assetPath = string.Empty;

            if (usePreviousAssetPath)
            {
                assetPath = AssetDatabase.GetAssetPath(probe.customBakedTexture);
            }
            string extension = !probe.hdr ? "png" : "exr";

            if (string.IsNullOrEmpty(assetPath) || (Path.GetExtension(assetPath) != ("." + extension)))
            {
                ReflectionProbe probe2;
                string          pathWithoutExtension = FileUtil.GetPathWithoutExtension(EditorApplication.currentScene);
                if (string.IsNullOrEmpty(pathWithoutExtension))
                {
                    pathWithoutExtension = "Assets";
                }
                else if (!Directory.Exists(pathWithoutExtension))
                {
                    Directory.CreateDirectory(pathWithoutExtension);
                }
                string fileNameWithoutExtension = probe.name + (!probe.hdr ? "-reflection" : "-reflectionHDR") + "." + extension;
                fileNameWithoutExtension = Path.GetFileNameWithoutExtension(AssetDatabase.GenerateUniqueAssetPath(Path.Combine(pathWithoutExtension, fileNameWithoutExtension)));
                assetPath = EditorUtility.SaveFilePanelInProject("Save reflection probe's cubemap.", fileNameWithoutExtension, extension, string.Empty, pathWithoutExtension);
                if (string.IsNullOrEmpty(assetPath))
                {
                    return;
                }
                if (this.IsCollidingWithOtherProbes(assetPath, probe, out probe2) && !EditorUtility.DisplayDialog("Cubemap is used by other reflection probe", string.Format("'{0}' path is used by the game object '{1}', do you really want to overwrite it?", assetPath, probe2.name), "Yes", "No"))
                {
                    return;
                }
            }
            EditorUtility.DisplayProgressBar("Reflection Probes", "Baking " + assetPath, 0.5f);
            if (!Lightmapping.BakeReflectionProbe(probe, assetPath))
            {
                Debug.LogError("Failed to bake reflection probe to " + assetPath);
            }
            EditorUtility.ClearProgressBar();
        }
 public void DeveloperBuildSettingsGUI()
 {
     if (Unsupported.IsDeveloperBuild())
     {
         Lightmapping.concurrentJobsType        = (Lightmapping.ConcurrentJobsType)EditorGUILayout.IntPopup(LightingWindowBakeSettings.Styles.ConcurrentJobs, (int)Lightmapping.concurrentJobsType, LightingWindowBakeSettings.Styles.ConcurrentJobsTypeStrings, LightingWindowBakeSettings.Styles.ConcurrentJobsTypeValues, new GUILayoutOption[0]);
         Lightmapping.enlightenForceUpdates     = EditorGUILayout.Toggle(LightingWindowBakeSettings.Styles.ForceUpdates, Lightmapping.enlightenForceUpdates, new GUILayoutOption[0]);
         Lightmapping.enlightenForceWhiteAlbedo = EditorGUILayout.Toggle(LightingWindowBakeSettings.Styles.ForceWhiteAlbedo, Lightmapping.enlightenForceWhiteAlbedo, new GUILayoutOption[0]);
         Lightmapping.filterMode = (FilterMode)EditorGUILayout.EnumPopup(EditorGUIUtility.TempContent("Filter Mode"), Lightmapping.filterMode, new GUILayoutOption[0]);
         EditorGUILayout.Slider(this.m_BounceScale, 0f, 10f, LightingWindowBakeSettings.Styles.BounceScale, new GUILayoutOption[0]);
         EditorGUILayout.Slider(this.m_UpdateThreshold, 0f, 1f, LightingWindowBakeSettings.Styles.UpdateThreshold, new GUILayoutOption[0]);
         if (GUILayout.Button("Clear disk cache", new GUILayoutOption[]
         {
             GUILayout.Width(150f)
         }))
         {
             Lightmapping.Clear();
             Lightmapping.ClearDiskCache();
         }
         if (GUILayout.Button("Print state to console", new GUILayoutOption[]
         {
             GUILayout.Width(150f)
         }))
         {
             Lightmapping.PrintStateToConsole();
         }
         if (GUILayout.Button("Reset albedo/emissive", new GUILayoutOption[]
         {
             GUILayout.Width(150f)
         }))
         {
             GIDebugVisualisation.ResetRuntimeInputTextures();
         }
         if (GUILayout.Button("Reset environment", new GUILayoutOption[]
         {
             GUILayout.Width(150f)
         }))
         {
             DynamicGI.UpdateEnvironment();
         }
     }
 }
        private void BakeCustomReflectionProbe(ReflectionProbe probe, bool usePreviousAssetPath)
        {
            string text = string.Empty;

            if (usePreviousAssetPath)
            {
                text = AssetDatabase.GetAssetPath(probe.customBakedTexture);
            }
            string text2 = (!probe.hdr) ? "png" : "exr";

            if (string.IsNullOrEmpty(text) || Path.GetExtension(text) != "." + text2)
            {
                string text3 = FileUtil.GetPathWithoutExtension(EditorApplication.currentScene);
                if (string.IsNullOrEmpty(text3))
                {
                    text3 = "Assets";
                }
                else
                {
                    if (!Directory.Exists(text3))
                    {
                        Directory.CreateDirectory(text3);
                    }
                }
                string text4 = probe.name + ((!probe.hdr) ? "-reflection" : "-reflectionHDR") + "." + text2;
                text4 = Path.GetFileNameWithoutExtension(AssetDatabase.GenerateUniqueAssetPath(Path.Combine(text3, text4)));
                text  = EditorUtility.SaveFilePanelInProject("Save reflection probe's cubemap.", text4, text2, string.Empty, text3);
                if (string.IsNullOrEmpty(text))
                {
                    return;
                }
            }
            EditorUtility.DisplayProgressBar("Reflection Probes", "Baking " + text, 0.5f);
            if (!Lightmapping.BakeReflectionProbe(probe, text))
            {
                Debug.LogError("Failed to bake reflection probe to " + text);
            }
            EditorUtility.ClearProgressBar();
        }
Esempio n. 23
0
        private void Buttons()
        {
            bool flag = Lightmapping.giWorkflowMode == Lightmapping.GIWorkflowMode.Iterative;

            if (flag)
            {
                EditorGUILayout.HelpBox("Baking of lightmaps is automatic because the workflow mode is set to 'Auto'. The lightmap data is stored in the GI cache.", MessageType.Info);
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            EditorGUI.BeginChangeCheck();
            flag = GUILayout.Toggle(flag, styles.ContinuousBakeLabel, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                Lightmapping.giWorkflowMode = !flag ? Lightmapping.GIWorkflowMode.OnDemand : Lightmapping.GIWorkflowMode.Iterative;
                InspectorWindow.RepaintAllInspectors();
            }
            EditorGUI.BeginDisabledGroup(flag);
            if (flag || !Lightmapping.isRunning)
            {
                GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(180f) };
                if (EditorGUI.ButtonWithDropdownList(styles.BuildLabel, s_BakeModeOptions, new GenericMenu.MenuFunction2(this.BakeDropDownCallback), options))
                {
                    this.DoBake();
                    GUIUtility.ExitGUI();
                }
            }
            else
            {
                GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(this.kButtonWidth) };
                if (GUILayout.Button("Cancel", optionArray2))
                {
                    Lightmapping.Cancel();
                    Analytics.Track("/LightMapper/Cancel");
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
        }
Esempio n. 24
0
        private void DisplayMeshWarning()
        {
            if (isPreset)
            {
                return;
            }

            Mesh mesh = GetSharedMesh(m_Renderers[0]);

            var  settings = Lightmapping.GetLightingSettingsOrDefaultsFallback();
            bool showEnlightenSettings = isPrefabAsset || settings.realtimeGI || (settings.bakedGI && settings.lightmapper == LightingSettings.Lightmapper.Enlighten);

            if (!HasSupportedTopologyForGI(mesh))
            {
                EditorGUILayout.HelpBox(Styles.unsupportedTopology.text, MessageType.Warning);
                return;
            }

            if (!HasVertices(mesh))
            {
                EditorGUILayout.HelpBox(Styles.noVerticesNoLightmapping.text, MessageType.Warning);
                return;
            }

            if (!HasNormals(mesh))
            {
                EditorGUILayout.HelpBox(Styles.noNormalsNoLightmapping.text, MessageType.Warning);
                return;
            }

            if (showEnlightenSettings)
            {
                if (Lightmapping.HasZeroAreaMesh(m_Renderers[0]))
                {
                    EditorGUILayout.HelpBox(Styles.zeroAreaPackingMesh.text, MessageType.Warning);
                }
            }
        }
Esempio n. 25
0
        void LightmapMemoryStats(int index)
        {
            GUILayout.BeginVertical();

            GUILayout.Label("Index: " + index, EditorStyles.miniLabel);

            LightmapMemory lightmapMemory = Lightmapping.GetLightmapMemory(index);

            GUILayout.Label("Lightmap data: " + lightmapMemory.lightmapDataSize.ToString("0.0") + " MB", EditorStyles.miniLabel);
            GUIContent lightmapTexturesSizeContent = null;

            if (lightmapMemory.lightmapTexturesSize > 0.0f)
            {
                lightmapTexturesSizeContent = EditorGUIUtility.TrTextContent("Lightmap textures: " + SizeString(lightmapMemory.lightmapTexturesSize));
            }
            else
            {
                lightmapTexturesSizeContent = EditorGUIUtility.TrTextContent("Lightmap textures: N/A", "This lightmap has converged and is not owned by the Progressive Lightmapper anymore.");
            }
            GUILayout.Label(lightmapTexturesSizeContent, EditorStyles.miniLabel);

            GUILayout.EndVertical();
        }
Esempio n. 26
0
        void LightmapPerformanceStats(int index)
        {
            GUILayout.BeginVertical();

            GUILayout.Label("Index: " + index, EditorStyles.miniLabel);

            LightmapConvergence lc = Lightmapping.GetLightmapConvergence(index);

            if (lc.IsValid())
            {
                GUILayout.Label("Occupied: " + InternalEditorUtility.CountToString((ulong)lc.occupiedTexelCount), EditorStyles.miniLabel);

                GUIContent direct = EditorGUIUtility.TrTextContent("Direct: " + lc.minDirectSamples + " / " + lc.maxDirectSamples + " / " + lc.avgDirectSamples + "", "min / max / avg samples per texel");
                GUILayout.Label(direct, EditorStyles.miniLabel);

                GUIContent gi = EditorGUIUtility.TrTextContent("GI: " + lc.minGISamples + " / " + lc.maxGISamples + " / " + lc.avgGISamples + "", "min / max / avg samples per texel");
                GUILayout.Label(gi, EditorStyles.miniLabel);
            }
            else
            {
                GUILayout.Label("Occupied: N/A", EditorStyles.miniLabel);
                GUILayout.Label("Direct: N/A", EditorStyles.miniLabel);
                GUILayout.Label("GI: N/A", EditorStyles.miniLabel);
            }
            float mraysPerSec = Lightmapping.GetLightmapBakePerformance(index);

            if (mraysPerSec >= 0.0)
            {
                GUILayout.Label(mraysPerSec.ToString("0.00") + " mrays/sec", EditorStyles.miniLabel);
            }
            else
            {
                GUILayout.Label("N/A mrays/sec", EditorStyles.miniLabel);
            }

            GUILayout.EndVertical();
        }
Esempio n. 27
0
        private void BakeCustomReflectionProbe(ReflectionProbe probe, bool usePreviousAssetPath)
        {
            string str1 = string.Empty;

            if (usePreviousAssetPath)
            {
                str1 = AssetDatabase.GetAssetPath((UnityEngine.Object)probe.customBakedTexture);
            }
            string extension = !probe.hdr ? "png" : "exr";

            if (string.IsNullOrEmpty(str1) || Path.GetExtension(str1) != "." + extension)
            {
                string str2 = FileUtil.GetPathWithoutExtension(SceneManager.GetActiveScene().path);
                if (string.IsNullOrEmpty(str2))
                {
                    str2 = "Assets";
                }
                else if (!Directory.Exists(str2))
                {
                    Directory.CreateDirectory(str2);
                }
                string path2 = probe.name + (!probe.hdr ? "-reflection" : "-reflectionHDR") + "." + extension;
                str1 = EditorUtility.SaveFilePanelInProject("Save reflection probe's cubemap.", Path.GetFileNameWithoutExtension(AssetDatabase.GenerateUniqueAssetPath(Path.Combine(str2, path2))), extension, string.Empty, str2);
                ReflectionProbe collidingProbe;
                if (string.IsNullOrEmpty(str1) || this.IsCollidingWithOtherProbes(str1, probe, out collidingProbe) && !EditorUtility.DisplayDialog("Cubemap is used by other reflection probe", string.Format("'{0}' path is used by the game object '{1}', do you really want to overwrite it?", (object)str1, (object)collidingProbe.name), "Yes", "No"))
                {
                    return;
                }
            }
            EditorUtility.DisplayProgressBar("Reflection Probes", "Baking " + str1, 0.5f);
            if (!Lightmapping.BakeReflectionProbe(probe, str1))
            {
                Debug.LogError((object)("Failed to bake reflection probe to " + str1));
            }
            EditorUtility.ClearProgressBar();
        }
        private void LightmapMemoryStats(int index)
        {
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label("Index: " + index, EditorStyles.miniLabel, new GUILayoutOption[0]);
            LightmapMemory lightmapMemory = Lightmapping.GetLightmapMemory(index);

            GUILayout.Label("Lightmap data: " + lightmapMemory.lightmapDataSize.ToString("0.0") + " MB", EditorStyles.miniLabel, new GUILayoutOption[0]);
            GUIContent content;

            if (lightmapMemory.lightmapTexturesSize > 0f)
            {
                content = EditorGUIUtility.TrTextContent("Lightmap textures: " + this.SizeString(lightmapMemory.lightmapTexturesSize), null, null);
            }
            else
            {
                content = EditorGUIUtility.TrTextContent("Lightmap textures: N/A", "This lightmap has converged and is not owned by the Progressive Lightmapper anymore.", null);
            }
            GUILayout.Label(content, EditorStyles.miniLabel, new GUILayoutOption[0]);
            GUILayout.Label("Albedo data: " + lightmapMemory.albedoDataSize.ToString("0.0") + " MB", EditorStyles.miniLabel, new GUILayoutOption[0]);
            GUILayout.Label("Albedo texture: " + lightmapMemory.albedoTextureSize.ToString("0.0") + " MB", EditorStyles.miniLabel, new GUILayoutOption[0]);
            GUILayout.Label("Emissive data: " + lightmapMemory.emissiveDataSize.ToString("0.0") + " MB", EditorStyles.miniLabel, new GUILayoutOption[0]);
            GUILayout.Label("Emissive texture: " + lightmapMemory.emissiveTextureSize.ToString("0.0") + " MB", EditorStyles.miniLabel, new GUILayoutOption[0]);
            GUILayout.EndVertical();
        }
        private void UpdateActiveGameObjectSelection()
        {
            MeshRenderer renderer = null;
            Terrain      terrain  = null;

            // if the selected active object (also active in the hierarchy) is a renderer or a terrain, we check its index etc.
            // otherwise bail
            if (Selection.activeGameObject == null || !Selection.activeGameObject.activeInHierarchy ||
                (!Selection.activeGameObject.TryGetComponent(out renderer) &&
                 !Selection.activeGameObject.TryGetComponent(out terrain)))
            {
                m_ActiveGameObjectLightmapIndex = -1;
                m_ActiveGameObjectInstanceId    = -1;
                m_ActiveGameObjectTextureHash   = new Hash128();
                return;
            }

            if (isRealtimeLightmap)
            {
                Hash128 inputSystemHash;
                if ((renderer != null && Lightmapping.GetInputSystemHash(renderer.GetInstanceID(), out inputSystemHash)) ||
                    (terrain != null && Lightmapping.GetInputSystemHash(terrain.GetInstanceID(), out inputSystemHash)))
                {
                    m_ActiveGameObjectTextureHash = inputSystemHash;
                }
                else
                {
                    m_ActiveGameObjectTextureHash = new Hash128();
                }
            }
            else
            {
                m_ActiveGameObjectLightmapIndex = renderer != null ? renderer.lightmapIndex : terrain.lightmapIndex;
                m_ActiveGameObjectInstanceId    = renderer != null?renderer.GetInstanceID() : terrain.GetInstanceID();
            }
        }
Esempio n. 30
0
        void ShowTerrainChunks(Terrain[] terrains)
        {
            int terrainChunksX = 0, terrainChunksY = 0;

            foreach (var terrain in terrains)
            {
                int tmpChunksX = 0, tmpChunksY = 0;
                Lightmapping.GetTerrainGIChunks(terrain, ref tmpChunksX, ref tmpChunksY);
                if (terrainChunksX == 0 && terrainChunksY == 0)
                {
                    terrainChunksX = tmpChunksX;
                    terrainChunksY = tmpChunksY;
                }
                else if (terrainChunksX != tmpChunksX || terrainChunksY != tmpChunksY)
                {
                    terrainChunksX = terrainChunksY = 0;
                    break;
                }
            }
            if (terrainChunksX * terrainChunksY > 1)
            {
                EditorGUILayout.HelpBox(string.Format(L10n.Tr("Terrain is chunked up into {0} instances for baking."), terrainChunksX * terrainChunksY), MessageType.None);
            }
        }