HasClampedResolution() private method

private HasClampedResolution ( Renderer renderer ) : bool
renderer UnityEngine.Renderer
return bool
示例#1
0
        public bool EditRenderers()
        {
            GameObject[] array;
            Renderer[]   selectedObjectsOfType = SceneModeUtility.GetSelectedObjectsOfType <Renderer>(out array, new Type[]
            {
                typeof(MeshRenderer),
                typeof(SkinnedMeshRenderer)
            });
            if (array.Length == 0)
            {
                return(false);
            }
            EditorGUILayout.InspectorTitlebar(selectedObjectsOfType);
            SerializedObject serializedObject = new SerializedObject(array);

            EditorGUI.BeginDisabledGroup(!SceneModeUtility.StaticFlagField("Lightmap Static", serializedObject.FindProperty("m_StaticEditorFlags"), 1));
            SerializedObject serializedObject2 = new SerializedObject(selectedObjectsOfType);
            float            num = LightmapVisualization.GetLightmapLODLevelScale(selectedObjectsOfType[0]);

            for (int i = 1; i < selectedObjectsOfType.Length; i++)
            {
                if (!Mathf.Approximately(num, LightmapVisualization.GetLightmapLODLevelScale(selectedObjectsOfType[i])))
                {
                    num = 1f;
                }
            }
            float lightmapScale     = this.LightmapScaleGUI(serializedObject2, num) * LightmapVisualization.GetLightmapLODLevelScale(selectedObjectsOfType[0]);
            float cachedSurfaceArea = (!(selectedObjectsOfType[0] is MeshRenderer)) ? InternalMeshUtil.GetCachedSkinnedMeshSurfaceArea(selectedObjectsOfType[0] as SkinnedMeshRenderer) : InternalMeshUtil.GetCachedMeshSurfaceArea(selectedObjectsOfType[0] as MeshRenderer);

            this.ShowClampedSizeInLightmapGUI(lightmapScale, cachedSurfaceArea);
            this.RendererUVSettings(serializedObject2);
            LightingWindowObjectTab.LightmapParametersGUI(serializedObject2.FindProperty("m_LightmapParameters"), LightingWindowObjectTab.s_Styles.LightmapParameters);
            this.m_ShowBakedLM = EditorGUILayout.Foldout(this.m_ShowBakedLM, LightingWindowObjectTab.s_Styles.Atlas);
            if (this.m_ShowBakedLM)
            {
                this.ShowAtlasGUI(serializedObject2);
            }
            this.m_ShowRealtimeLM = EditorGUILayout.Foldout(this.m_ShowRealtimeLM, LightingWindowObjectTab.s_Styles.RealtimeLM);
            if (this.m_ShowRealtimeLM)
            {
                this.ShowRealtimeLMGUI(serializedObject2, selectedObjectsOfType[0]);
            }
            if (LightmapEditorSettings.HasZeroAreaMesh(selectedObjectsOfType[0]))
            {
                EditorGUILayout.HelpBox(LightingWindowObjectTab.s_Styles.ZeroAreaPackingMesh.text, MessageType.Warning);
            }
            if (LightmapEditorSettings.HasClampedResolution(selectedObjectsOfType[0]))
            {
                EditorGUILayout.HelpBox(LightingWindowObjectTab.s_Styles.ClampedPackingResolution.text, MessageType.Warning);
            }
            if (!LightingWindowObjectTab.HasNormals(selectedObjectsOfType[0]))
            {
                EditorGUILayout.HelpBox(LightingWindowObjectTab.s_Styles.NoNormalsNoLightmapping.text, MessageType.Warning);
            }
            serializedObject.ApplyModifiedProperties();
            serializedObject2.ApplyModifiedProperties();
            EditorGUI.EndDisabledGroup();
            GUILayout.Space(10f);
            return(true);
        }
        public bool EditRenderers()
        {
            GameObject[]  objArray;
            System.Type[] types = new System.Type[] { typeof(MeshRenderer), typeof(SkinnedMeshRenderer) };
            Renderer[]    selectedObjectsOfType = SceneModeUtility.GetSelectedObjectsOfType <Renderer>(out objArray, types);
            if (objArray.Length == 0)
            {
                return(false);
            }
            EditorGUILayout.InspectorTitlebar(selectedObjectsOfType);
            SerializedObject obj2 = new SerializedObject(objArray);

            using (new EditorGUI.DisabledScope(!SceneModeUtility.StaticFlagField("Lightmap Static", obj2.FindProperty("m_StaticEditorFlags"), 1)))
            {
                SerializedObject so = new SerializedObject(selectedObjectsOfType);
                float            lightmapLODLevelScale = LightmapVisualization.GetLightmapLODLevelScale(selectedObjectsOfType[0]);
                for (int i = 1; i < selectedObjectsOfType.Length; i++)
                {
                    if (!Mathf.Approximately(lightmapLODLevelScale, LightmapVisualization.GetLightmapLODLevelScale(selectedObjectsOfType[i])))
                    {
                        lightmapLODLevelScale = 1f;
                    }
                }
                float lightmapScale     = this.LightmapScaleGUI(so, lightmapLODLevelScale) * LightmapVisualization.GetLightmapLODLevelScale(selectedObjectsOfType[0]);
                float cachedSurfaceArea = !(selectedObjectsOfType[0] is MeshRenderer) ? InternalMeshUtil.GetCachedSkinnedMeshSurfaceArea(selectedObjectsOfType[0] as SkinnedMeshRenderer) : InternalMeshUtil.GetCachedMeshSurfaceArea(selectedObjectsOfType[0] as MeshRenderer);
                this.ShowClampedSizeInLightmapGUI(lightmapScale, cachedSurfaceArea);
                EditorGUILayout.PropertyField(so.FindProperty("m_ImportantGI"), s_Styles.ImportantGI, new GUILayoutOption[0]);
                LightmapParametersGUI(so.FindProperty("m_LightmapParameters"), s_Styles.LightmapParameters, true);
                GUILayout.Space(10f);
                this.RendererUVSettings(so);
                GUILayout.Space(10f);
                this.m_ShowBakedLM = EditorGUILayout.Foldout(this.m_ShowBakedLM, s_Styles.Atlas, true);
                if (this.m_ShowBakedLM)
                {
                    this.ShowAtlasGUI(so);
                }
                this.m_ShowRealtimeLM = EditorGUILayout.Foldout(this.m_ShowRealtimeLM, s_Styles.RealtimeLM, true);
                if (this.m_ShowRealtimeLM)
                {
                    this.ShowRealtimeLMGUI(so, selectedObjectsOfType[0]);
                }
                if (LightmapEditorSettings.HasZeroAreaMesh(selectedObjectsOfType[0]))
                {
                    EditorGUILayout.HelpBox(s_Styles.ZeroAreaPackingMesh.text, MessageType.Warning);
                }
                if (LightmapEditorSettings.HasClampedResolution(selectedObjectsOfType[0]))
                {
                    EditorGUILayout.HelpBox(s_Styles.ClampedPackingResolution.text, MessageType.Warning);
                }
                if (!HasNormals(selectedObjectsOfType[0]))
                {
                    EditorGUILayout.HelpBox(s_Styles.NoNormalsNoLightmapping.text, MessageType.Warning);
                }
                obj2.ApplyModifiedProperties();
                so.ApplyModifiedProperties();
            }
            GUILayout.Space(10f);
            return(true);
        }
示例#3
0
        public void RenderMeshSettings(bool showLightmapSettings)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            if (m_SerializedObject == null || m_GameObjectsSerializedObject == null || m_GameObjectsSerializedObject.targetObjects.Length == 0)
            {
                return;
            }

            m_GameObjectsSerializedObject.Update();
            m_LightmapSettings.Update();

            EditorGUILayout.PropertyField(m_CastShadows, s_Styles.CastShadows, true);
            bool isDeferredRenderingPath = SceneView.IsUsingDeferredRenderingPath();

            if (SupportedRenderingFeatures.active.rendererSupportsReceiveShadows)
            {
                using (new EditorGUI.DisabledScope(isDeferredRenderingPath))
                    EditorGUILayout.PropertyField(m_ReceiveShadows, s_Styles.ReceiveShadows, true);
            }

            if (SupportedRenderingFeatures.active.rendererSupportsMotionVectors)
            {
                EditorGUILayout.PropertyField(m_MotionVectors, s_Styles.MotionVectors, true);
            }

            if (!showLightmapSettings)
            {
                return;
            }

            LightmapStaticSettings();

            if (!(m_EnabledBakedGI.boolValue || m_EnabledRealtimeGI.boolValue) && !isPrefabAsset)
            {
                EditorGUILayout.HelpBox(s_Styles.GINotEnabledInfo.text, MessageType.Info);
                return;
            }

            bool enableSettings = (m_StaticEditorFlags.intValue & (int)StaticEditorFlags.LightmapStatic) != 0;

            // We want to show the lightmap settings if the lightmap static flag is set.
            // Most of the settings apply to both, realtime and baked GI.
            if (enableSettings)
            {
                bool showEnlightenSettings   = isPrefabAsset || m_EnabledRealtimeGI.boolValue || (m_EnabledBakedGI.boolValue && LightmapEditorSettings.lightmapper == LightmapEditorSettings.Lightmapper.Enlighten);
                bool showProgressiveSettings = isPrefabAsset || (m_EnabledBakedGI.boolValue && LightmapEditorSettings.lightmapper != LightmapEditorSettings.Lightmapper.Enlighten);

                if (showEnlightenSettings)
                {
                    m_ShowChartingSettings = EditorGUILayout.Foldout(m_ShowChartingSettings, s_Styles.UVCharting, true);
                    if (m_ShowChartingSettings)
                    {
                        RendererUVSettings();
                    }
                }

                m_ShowLightmapSettings = EditorGUILayout.Foldout(m_ShowLightmapSettings, s_Styles.LightmapSettings, true);

                if (m_ShowLightmapSettings)
                {
                    EditorGUI.indentLevel += 1;

                    float lodScale = LightmapVisualization.GetLightmapLODLevelScale(m_Renderers[0]);
                    for (int i = 1; i < m_Renderers.Length; i++)
                    {
                        if (!Mathf.Approximately(lodScale, LightmapVisualization.GetLightmapLODLevelScale(m_Renderers[i])))
                        {
                            lodScale = 1.0F;
                        }
                    }

                    float lightmapScale = LightmapScaleGUI(lodScale) * LightmapVisualization.GetLightmapLODLevelScale(m_Renderers[0]);

                    // tell the user if the object's size in lightmap has reached the max atlas size
                    float cachedSurfaceArea = InternalMeshUtil.GetCachedMeshSurfaceArea((MeshRenderer)m_Renderers[0]);

                    ShowClampedSizeInLightmapGUI(lightmapScale, cachedSurfaceArea);

                    // Enlighten specific
                    if (showEnlightenSettings)
                    {
                        EditorGUILayout.PropertyField(m_ImportantGI, s_Styles.ImportantGI);
                    }

                    if (showProgressiveSettings)
                    {
                        EditorGUILayout.PropertyField(m_StitchLightmapSeams, s_Styles.StitchLightmapSeams);
                    }

                    LightmapParametersGUI(m_LightmapParameters, s_Styles.LightmapParameters);

                    m_ShowBakedLM = EditorGUILayout.Foldout(m_ShowBakedLM, s_Styles.Atlas, true);
                    if (m_ShowBakedLM)
                    {
                        ShowAtlasGUI(m_Renderers[0].GetInstanceID());
                    }

                    m_ShowRealtimeLM = EditorGUILayout.Foldout(m_ShowRealtimeLM, s_Styles.RealtimeLM, true);
                    if (m_ShowRealtimeLM)
                    {
                        ShowRealtimeLMGUI(m_Renderers[0]);
                    }

                    EditorGUI.indentLevel -= 1;
                }

                if (LightmapEditorSettings.HasZeroAreaMesh(m_Renderers[0]))
                {
                    EditorGUILayout.HelpBox(s_Styles.ZeroAreaPackingMesh.text, MessageType.Warning);
                }

                if (LightmapEditorSettings.HasClampedResolution(m_Renderers[0]))
                {
                    EditorGUILayout.HelpBox(s_Styles.ClampedPackingResolution.text, MessageType.Warning);
                }

                if (!HasNormals(m_Renderers[0]))
                {
                    EditorGUILayout.HelpBox(s_Styles.NoNormalsNoLightmapping.text, MessageType.Warning);
                }

                if (LightmapEditorSettings.HasUVOverlaps(m_Renderers[0]))
                {
                    EditorGUILayout.HelpBox(s_Styles.UVOverlap.text, MessageType.Warning);
                }

                m_SerializedObject.ApplyModifiedProperties();
            }
            else
            {
                EditorGUILayout.HelpBox(s_Styles.LightmapInfoBox.text, MessageType.Info);
            }
        }
示例#4
0
        public void RenderSettings(bool showLightmapSettings, bool showshadowBias)
        {
            if (m_SerializedObject == null || m_GameObjectsSerializedObject == null || m_GameObjectsSerializedObject.targetObjectsCount == 0)
            {
                return;
            }

            m_GameObjectsSerializedObject.Update();
            m_LightmapSettings.Update();

            ReceiveGI receiveGI             = (ReceiveGI)m_ReceiveGI.intValue;
            bool      contributeGI          = (m_StaticEditorFlags.intValue & (int)StaticEditorFlags.ContributeGI) != 0;
            bool      showEnlightenSettings = isPrefabAsset || m_EnabledRealtimeGI.boolValue || (m_EnabledBakedGI.boolValue && LightmapEditorSettings.lightmapper == LightmapEditorSettings.Lightmapper.Enlighten);

            // m_ReceiveGI might still be set to Lightmaps, but LightProbes is shown in the inspector since the contributeGI if off.
            // In this case we still have to mark it as "multiple values" even though both have "Lightmaps" as the value, but one is showing a grayed out "Light Probes" in the UI
            bool showMixedGIValue = m_ReceiveGI.hasMultipleDifferentValues || ((m_StaticEditorFlags.hasMultipleDifferentValuesBitwise & (int)StaticEditorFlags.ContributeGI) != 0);

            m_ShowLightingSettings.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_ShowLightingSettings.value, Styles.LightingSettings);

            if (m_ShowLightingSettings.value)
            {
                EditorGUI.indentLevel += 1;

                EditorGUILayout.PropertyField(m_CastShadows, Styles.CastShadows, true);
                bool isDeferredRenderingPath = SceneView.IsUsingDeferredRenderingPath();

                if (SupportedRenderingFeatures.active.receiveShadows)
                {
                    using (new EditorGUI.DisabledScope(isDeferredRenderingPath))
                        EditorGUILayout.PropertyField(m_ReceiveShadows, Styles.ReceiveShadows, true);
                }

                if (!showLightmapSettings)
                {
                    EditorGUI.indentLevel -= 1;

                    EditorGUILayout.EndFoldoutHeaderGroup();

                    return;
                }

                contributeGI = ContributeGISettings();

                if (!(m_EnabledBakedGI.boolValue || m_EnabledRealtimeGI.boolValue) && !isPrefabAsset && contributeGI)
                {
                    EditorGUILayout.HelpBox(Styles.GINotEnabledInfo.text, MessageType.Info);
                    EditorGUI.indentLevel -= 1;

                    EditorGUILayout.EndFoldoutHeaderGroup();

                    return;
                }

                if (contributeGI)
                {
                    EditorGUI.BeginChangeCheck();

                    EditorGUI.showMixedValue = showMixedGIValue;
                    receiveGI = (ReceiveGI)EditorGUILayout.IntPopup(Styles.ReceiveGITitle, (int)receiveGI, Styles.ReceiveGILightmapStrings, Styles.ReceiveGILightmapValues);
                    EditorGUI.showMixedValue = false;

                    if (EditorGUI.EndChangeCheck())
                    {
                        m_ReceiveGI.intValue = (int)receiveGI;
                    }

                    if (showEnlightenSettings)
                    {
                        EditorGUILayout.PropertyField(m_ImportantGI, Styles.ImportantGI);
                    }

                    if (receiveGI == ReceiveGI.LightProbes && !showMixedGIValue)
                    {
                        LightmapScaleGUI(true, Styles.AlbedoScale, true);
                    }
                }
                else
                {
                    using (new EditorGUI.DisabledScope(true))
                    {
                        EditorGUI.showMixedValue = showMixedGIValue;
                        receiveGI = (ReceiveGI)EditorGUILayout.IntPopup(Styles.ReceiveGITitle, (int)ReceiveGI.LightProbes, Styles.ReceiveGILightmapStrings, Styles.ReceiveGILightmapValues);
                        EditorGUI.showMixedValue = false;
                    }
                }

                EditorGUI.indentLevel -= 1;
            }

            EditorGUILayout.EndFoldoutHeaderGroup();

            if (showLightmapSettings && contributeGI && receiveGI == ReceiveGI.Lightmaps && !showMixedGIValue)
            {
                m_ShowLightmapSettings.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_ShowLightmapSettings.value, Styles.LightmapSettings);

                if (m_ShowLightmapSettings.value)
                {
                    EditorGUI.indentLevel += 1;

                    bool showProgressiveSettings = isPrefabAsset || (m_EnabledBakedGI.boolValue && LightmapEditorSettings.lightmapper != LightmapEditorSettings.Lightmapper.Enlighten);

                    LightmapScaleGUI(true, Styles.ScaleInLightmap, false);

                    if (showProgressiveSettings)
                    {
                        EditorGUILayout.PropertyField(m_StitchLightmapSeams, Styles.StitchLightmapSeams);
                    }

                    LightmapParametersGUI(m_LightmapParameters, Styles.LightmapParameters);

                    if (showEnlightenSettings)
                    {
                        RendererUVSettings();
                    }

                    ShowAtlasGUI(m_Renderers[0].GetInstanceID());
                    ShowRealtimeLMGUI(m_Renderers[0]);

                    if (LightmapEditorSettings.HasZeroAreaMesh(m_Renderers[0]))
                    {
                        EditorGUILayout.HelpBox(Styles.ZeroAreaPackingMesh.text, MessageType.Warning);
                    }

                    DisplayMeshWarning();

                    if (showEnlightenSettings)
                    {
                        if (LightmapEditorSettings.HasClampedResolution(m_Renderers[0]))
                        {
                            EditorGUILayout.HelpBox(Styles.ClampedPackingResolution.text, MessageType.Warning);
                        }
                    }

                    if (showProgressiveSettings)
                    {
                        if (LightmapEditorSettings.HasUVOverlaps(m_Renderers[0]))
                        {
                            EditorGUILayout.HelpBox(Styles.UVOverlap.text, MessageType.Warning);
                        }
                    }

                    EditorGUI.indentLevel -= 1;
                }

                EditorGUILayout.EndFoldoutHeaderGroup();
            }
        }
示例#5
0
 public void RenderMeshSettings(bool showLightmapSettings)
 {
     if (LightingSettingsInspector.s_Styles == null)
     {
         LightingSettingsInspector.s_Styles = new LightingSettingsInspector.Styles();
     }
     if (this.m_SerializedObject != null && this.m_GameObjectsSerializedObject != null && this.m_GameObjectsSerializedObject.targetObjects.Length != 0)
     {
         this.m_GameObjectsSerializedObject.Update();
         EditorGUILayout.PropertyField(this.m_CastShadows, LightingSettingsInspector.s_Styles.CastShadows, true, new GUILayoutOption[0]);
         bool disabled = SceneView.IsUsingDeferredRenderingPath();
         using (new EditorGUI.DisabledScope(disabled))
         {
             EditorGUILayout.PropertyField(this.m_ReceiveShadows, LightingSettingsInspector.s_Styles.ReceiveShadows, true, new GUILayoutOption[0]);
         }
         EditorGUILayout.PropertyField(this.m_MotionVectors, LightingSettingsInspector.s_Styles.MotionVectors, true, new GUILayoutOption[0]);
         if (showLightmapSettings)
         {
             this.LightmapStaticSettings();
             if (!LightModeUtil.Get().IsAnyGIEnabled() && !this.isPrefabAsset)
             {
                 EditorGUILayout.HelpBox(LightingSettingsInspector.s_Styles.GINotEnabledInfo.text, MessageType.Info);
             }
             else
             {
                 bool flag = (this.m_StaticEditorFlags.intValue & 1) != 0;
                 if (flag)
                 {
                     this.m_ShowChartingSettings = EditorGUILayout.Foldout(this.m_ShowChartingSettings, LightingSettingsInspector.s_Styles.UVCharting);
                     if (this.m_ShowChartingSettings)
                     {
                         this.RendererUVSettings();
                     }
                     this.m_ShowLightmapSettings = EditorGUILayout.Foldout(this.m_ShowLightmapSettings, LightingSettingsInspector.s_Styles.LightmapSettings);
                     if (this.m_ShowLightmapSettings)
                     {
                         EditorGUI.indentLevel++;
                         float num = LightmapVisualization.GetLightmapLODLevelScale(this.m_Renderers[0]);
                         for (int i = 1; i < this.m_Renderers.Length; i++)
                         {
                             if (!Mathf.Approximately(num, LightmapVisualization.GetLightmapLODLevelScale(this.m_Renderers[i])))
                             {
                                 num = 1f;
                             }
                         }
                         float lightmapScale         = this.LightmapScaleGUI(num) * LightmapVisualization.GetLightmapLODLevelScale(this.m_Renderers[0]);
                         float cachedMeshSurfaceArea = InternalMeshUtil.GetCachedMeshSurfaceArea((MeshRenderer)this.m_Renderers[0]);
                         this.ShowClampedSizeInLightmapGUI(lightmapScale, cachedMeshSurfaceArea);
                         EditorGUILayout.PropertyField(this.m_ImportantGI, LightingSettingsInspector.s_Styles.ImportantGI, new GUILayoutOption[0]);
                         LightingSettingsInspector.LightmapParametersGUI(this.m_LightmapParameters, LightingSettingsInspector.s_Styles.LightmapParameters);
                         this.m_ShowBakedLM = EditorGUILayout.Foldout(this.m_ShowBakedLM, LightingSettingsInspector.s_Styles.Atlas);
                         if (this.m_ShowBakedLM)
                         {
                             this.ShowAtlasGUI(this.m_Renderers[0].GetInstanceID());
                         }
                         this.m_ShowRealtimeLM = EditorGUILayout.Foldout(this.m_ShowRealtimeLM, LightingSettingsInspector.s_Styles.RealtimeLM);
                         if (this.m_ShowRealtimeLM)
                         {
                             this.ShowRealtimeLMGUI(this.m_Renderers[0]);
                         }
                         EditorGUI.indentLevel--;
                     }
                     if (LightmapEditorSettings.HasZeroAreaMesh(this.m_Renderers[0]))
                     {
                         EditorGUILayout.HelpBox(LightingSettingsInspector.s_Styles.ZeroAreaPackingMesh.text, MessageType.Warning);
                     }
                     if (LightmapEditorSettings.HasClampedResolution(this.m_Renderers[0]))
                     {
                         EditorGUILayout.HelpBox(LightingSettingsInspector.s_Styles.ClampedPackingResolution.text, MessageType.Warning);
                     }
                     if (!LightingSettingsInspector.HasNormals(this.m_Renderers[0]))
                     {
                         EditorGUILayout.HelpBox(LightingSettingsInspector.s_Styles.NoNormalsNoLightmapping.text, MessageType.Warning);
                     }
                     this.m_SerializedObject.ApplyModifiedProperties();
                 }
                 else
                 {
                     EditorGUILayout.HelpBox(LightingSettingsInspector.s_Styles.LightmapInfoBox.text, MessageType.Info);
                 }
             }
         }
     }
 }