Ejemplo n.º 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);
        }
 private void DrawTetrahedra()
 {
     if ((Event.current.type == EventType.Repaint) && (SceneView.lastActiveSceneView != null))
     {
         LightmapVisualization.DrawTetrahedra(this.m_ShouldRecalculateTetrahedra, SceneView.lastActiveSceneView.camera.transform.position);
         this.m_ShouldRecalculateTetrahedra = false;
     }
 }
 private void DrawTetrahedra()
 {
     if (Event.current.type != EventType.Repaint || !(bool)((UnityEngine.Object)SceneView.lastActiveSceneView))
     {
         return;
     }
     LightmapVisualization.DrawTetrahedra(this.m_ShouldRecalculateTetrahedra, SceneView.lastActiveSceneView.camera.transform.position);
     this.m_ShouldRecalculateTetrahedra = false;
 }
Ejemplo n.º 5
0
        void LightmapScaleGUI(bool meshRenderer, 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 && LightmapEditorSettings.lightmapper != LightmapEditorSettings.Lightmapper.Enlighten)
            {
                return;
            }

            float lodScale = 1.0f;

            if (meshRenderer)
            {
                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 = 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;

            if (meshRenderer)
            {
                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
                var terrainData = m_Terrains[0].terrainData;
                cachedSurfaceArea = terrainData != null ? terrainData.size.x * terrainData.size.z : 0;
            }

            ShowClampedSizeInLightmapGUI(lightmapScale, cachedSurfaceArea, isSSD);
        }
Ejemplo n.º 6
0
        private float CalcLODScale(bool isMeshRenderer)
        {
            float lodScale = 1.0f;

            if (isMeshRenderer && (m_Renderers != null) && (m_Renderers.Length > 0))
            {
                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;
                    }
                }
            }
            return(lodScale);
        }
 internal static void DrawTetrahedra(bool shouldRecalculateTetrahedra, Vector3 cameraPosition)
 {
     LightmapVisualization.INTERNAL_CALL_DrawTetrahedra(shouldRecalculateTetrahedra, ref cameraPosition);
 }
 internal static void DrawPointCloud(Vector3[] unselectedPositions, Vector3[] selectedPositions, Color baseColor, Color selectedColor, float scale, Transform cloudTransform)
 {
     LightmapVisualization.INTERNAL_CALL_DrawPointCloud(unselectedPositions, selectedPositions, ref baseColor, ref selectedColor, scale, cloudTransform);
 }
Ejemplo n.º 9
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);
            }
        }
Ejemplo n.º 10
0
 public static void Draw(IEditablePoint points, Transform cloudTransform, List <int> selection, bool twoPassDrawing)
 {
     LightmapVisualization.DrawPointCloud(points.GetUnselectedPositions(), points.GetSelectedPositions(), points.GetDefaultColor(), points.GetSelectedColor(), points.GetPointScale(), cloudTransform);
 }
Ejemplo n.º 11
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);
                 }
             }
         }
     }
 }