Пример #1
0
        public override string GetInfoString()
        {
            string str2;
            Mesh   target = this.target as Mesh;

            object[] objArray1    = new object[] { target.vertexCount, " verts, ", InternalMeshUtil.GetPrimitiveCount(target), " tris" };
            string   str          = string.Concat(objArray1);
            int      subMeshCount = target.subMeshCount;

            if (subMeshCount > 1)
            {
                str2 = str;
                object[] objArray2 = new object[] { str2, ", ", subMeshCount, " submeshes" };
                str = string.Concat(objArray2);
            }
            int blendShapeCount = target.blendShapeCount;

            if (blendShapeCount > 1)
            {
                str2 = str;
                object[] objArray3 = new object[] { str2, ", ", blendShapeCount, " blendShapes" };
                str = string.Concat(objArray3);
            }
            return(str + "\n" + InternalMeshUtil.GetVertexFormat(target));
        }
Пример #2
0
        public bool EditRenderers()
        {
            GameObject[] objArray;
            Type[]       types = new 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);

            EditorGUI.BeginDisabledGroup(!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);
            GUILayout.Space(10f);
            this.RendererUVSettings(so);
            GUILayout.Space(10f);
            this.m_ShowBakedLM = EditorGUILayout.Foldout(this.m_ShowBakedLM, s_Styles.Atlas);
            if (this.m_ShowBakedLM)
            {
                this.ShowAtlasGUI(so);
            }
            this.m_ShowRealtimeLM = EditorGUILayout.Foldout(this.m_ShowRealtimeLM, s_Styles.RealtimeLM);
            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();
            EditorGUI.EndDisabledGroup();
            GUILayout.Space(10f);
            return(true);
        }
Пример #3
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);
        }
        public static void SetPerTriangleUV2(Mesh src, Vector2[] triUV)
        {
            int triCount = InternalMeshUtil.CalcTriangleCount(src);
            int uvCount  = triUV.Length;

            if (uvCount != 3 * triCount)
            {
                Debug.LogError("mesh contains " + triCount + " triangles but " + uvCount + " uvs are provided");
                return;
            }

            SetPerTriangleUV2NoCheck(src, triUV);
        }
Пример #5
0
        /// <summary>
        /// <para>Will insert per-triangle uv2 in mesh and handle vertex splitting etc.</para>
        /// </summary>
        /// <param name="src"></param>
        /// <param name="triUV"></param>
        public static void SetPerTriangleUV2(Mesh src, Vector2[] triUV)
        {
            int num    = InternalMeshUtil.CalcTriangleCount(src);
            int length = triUV.Length;

            if (length != (3 * num))
            {
                Debug.LogError(string.Concat(new object[] { "mesh contains ", num, " triangles but ", length, " uvs are provided" }));
            }
            else
            {
                SetPerTriangleUV2NoCheck(src, triUV);
            }
        }
Пример #6
0
        /// <summary>
        ///   <para>Will insert per-triangle uv2 in mesh and handle vertex splitting etc.</para>
        /// </summary>
        /// <param name="src"></param>
        /// <param name="triUV"></param>
        public static void SetPerTriangleUV2(Mesh src, Vector2[] triUV)
        {
            int num    = InternalMeshUtil.CalcTriangleCount(src);
            int length = triUV.Length;

            if (length != 3 * num)
            {
                Debug.LogError((object)("mesh contains " + (object)num + " triangles but " + (object)length + " uvs are provided"));
            }
            else
            {
                MeshUtility.SetPerTriangleUV2NoCheck(src, triUV);
            }
        }
        public static void SetPerTriangleUV2(Mesh src, Vector2[] triUV)
        {
            if (triUV == null)
            {
                throw new ArgumentNullException("triUV");
            }

            int triCount = InternalMeshUtil.CalcTriangleCount(src), uvCount = triUV.Length;

            if (uvCount != 3 * triCount)
            {
                Debug.LogError("mesh contains " + triCount + " triangles but " + uvCount + " uvs are provided");
                return;
            }
            SetPerTriangleUV2NoCheck(src, triUV);
        }
Пример #8
0
        static bool HasNormals(Renderer renderer)
        {
            Mesh mesh = null;

            if (renderer is MeshRenderer)
            {
                MeshFilter mf = renderer.GetComponent <MeshFilter>();
                if (mf != null)
                {
                    mesh = mf.sharedMesh;
                }
            }
            else if (renderer is SkinnedMeshRenderer)
            {
                mesh = (renderer as SkinnedMeshRenderer).sharedMesh;
            }
            return(mesh != null && InternalMeshUtil.HasNormals(mesh));
        }
Пример #9
0
        public override string GetInfoString()
        {
            Mesh   target       = this.target as Mesh;
            string str          = target.vertexCount.ToString() + " verts, " + (object)InternalMeshUtil.GetPrimitiveCount(target) + " tris";
            int    subMeshCount = target.subMeshCount;

            if (subMeshCount > 1)
            {
                str = str + ", " + (object)subMeshCount + " submeshes";
            }
            int blendShapeCount = target.blendShapeCount;

            if (blendShapeCount > 1)
            {
                str = str + ", " + (object)blendShapeCount + " blendShapes";
            }
            return(str + "\n" + InternalMeshUtil.GetVertexFormat(target));
        }
Пример #10
0
        private static bool HasNormals(Renderer renderer)
        {
            Mesh sharedMesh = null;

            if (renderer is MeshRenderer)
            {
                MeshFilter component = renderer.GetComponent <MeshFilter>();
                if (component != null)
                {
                    sharedMesh = component.sharedMesh;
                }
            }
            else if (renderer is SkinnedMeshRenderer)
            {
                sharedMesh = (renderer as SkinnedMeshRenderer).sharedMesh;
            }
            return(InternalMeshUtil.HasNormals(sharedMesh));
        }
        private static bool HasNormals(Renderer renderer)
        {
            Mesh mesh = (Mesh)null;

            if (renderer is MeshRenderer)
            {
                MeshFilter component = renderer.GetComponent <MeshFilter>();
                if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                {
                    mesh = component.sharedMesh;
                }
            }
            else if (renderer is SkinnedMeshRenderer)
            {
                mesh = (renderer as SkinnedMeshRenderer).sharedMesh;
            }
            return(InternalMeshUtil.HasNormals(mesh));
        }
Пример #12
0
        public static void SetPerTriangleUV2(Mesh src, Vector2[] triUV)
        {
            int num  = InternalMeshUtil.CalcTriangleCount(src);
            int num2 = triUV.Length;

            if (num2 != 3 * num)
            {
                Debug.LogError(string.Concat(new object[]
                {
                    "mesh contains ",
                    num,
                    " triangles but ",
                    num2,
                    " uvs are provided"
                }));
                return;
            }
            MeshUtility.SetPerTriangleUV2NoCheck(src, triUV);
        }
Пример #13
0
        public override string GetInfoString()
        {
            Mesh   mesh      = target as Mesh;
            string info      = mesh.vertexCount + " verts, " + InternalMeshUtil.GetPrimitiveCount(mesh) + " tris";
            int    submeshes = mesh.subMeshCount;

            if (submeshes > 1)
            {
                info += ", " + submeshes + " submeshes";
            }

            int blendShapeCount = mesh.blendShapeCount;

            if (blendShapeCount > 1)
            {
                info += ", " + blendShapeCount + " blendShapes";
            }

            info += "\n" + InternalMeshUtil.GetVertexFormat(mesh);
            return(info);
        }
Пример #14
0
        public override string GetInfoString()
        {
            Mesh   mesh = this.target as Mesh;
            string text = string.Concat(new object[]
            {
                mesh.vertexCount,
                " verts, ",
                InternalMeshUtil.GetPrimitiveCount(mesh),
                " tris"
            });
            int subMeshCount = mesh.subMeshCount;

            if (subMeshCount > 1)
            {
                string text2 = text;
                text = string.Concat(new object[]
                {
                    text2,
                    ", ",
                    subMeshCount,
                    " submeshes"
                });
            }
            int blendShapeCount = mesh.blendShapeCount;

            if (blendShapeCount > 1)
            {
                string text2 = text;
                text = string.Concat(new object[]
                {
                    text2,
                    ", ",
                    blendShapeCount,
                    " blendShapes"
                });
            }
            return(text + "\n" + InternalMeshUtil.GetVertexFormat(mesh));
        }
Пример #15
0
 static bool HasSupportedTopologyForGI(Mesh mesh)
 {
     return(mesh != null && InternalMeshUtil.HasSupportedTopologyForGI(mesh));
 }
Пример #16
0
 static bool HasVertices(Mesh mesh)
 {
     return(mesh != null && InternalMeshUtil.HasVertices(mesh));
 }
Пример #17
0
 static bool HasNormals(Mesh mesh)
 {
     return(mesh != null && InternalMeshUtil.HasNormals(mesh));
 }
Пример #18
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);
                 }
             }
         }
     }
 }
Пример #19
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);
            }
        }
        public bool EditRenderers()
        {
            GameObject[] gameObjects;
            Renderer[]   selectedObjectsOfType = SceneModeUtility.GetSelectedObjectsOfType <Renderer>(out gameObjects, typeof(MeshRenderer), typeof(SkinnedMeshRenderer));
            if (gameObjects.Length == 0)
            {
                return(false);
            }
            EditorGUILayout.InspectorTitlebar((UnityEngine.Object[])selectedObjectsOfType);
            SerializedObject serializedObject = new SerializedObject((UnityEngine.Object[])gameObjects);

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

            for (int index = 1; index < selectedObjectsOfType.Length; ++index)
            {
                if (!Mathf.Approximately(num, LightmapVisualization.GetLightmapLODLevelScale(selectedObjectsOfType[index])))
                {
                    num = 1f;
                }
            }
            this.ShowClampedSizeInLightmapGUI(this.LightmapScaleGUI(so, num) * LightmapVisualization.GetLightmapLODLevelScale(selectedObjectsOfType[0]), !(selectedObjectsOfType[0] is MeshRenderer) ? InternalMeshUtil.GetCachedSkinnedMeshSurfaceArea(selectedObjectsOfType[0] as SkinnedMeshRenderer) : InternalMeshUtil.GetCachedMeshSurfaceArea(selectedObjectsOfType[0] as MeshRenderer));
            EditorGUILayout.PropertyField(so.FindProperty("m_ImportantGI"), LightingWindowObjectTab.s_Styles.ImportantGI, new GUILayoutOption[0]);
            LightingWindowObjectTab.LightmapParametersGUI(so.FindProperty("m_LightmapParameters"), LightingWindowObjectTab.s_Styles.LightmapParameters);
            GUILayout.Space(10f);
            this.RendererUVSettings(so);
            GUILayout.Space(10f);
            this.m_ShowBakedLM = EditorGUILayout.Foldout(this.m_ShowBakedLM, LightingWindowObjectTab.s_Styles.Atlas);
            if (this.m_ShowBakedLM)
            {
                this.ShowAtlasGUI(so);
            }
            this.m_ShowRealtimeLM = EditorGUILayout.Foldout(this.m_ShowRealtimeLM, LightingWindowObjectTab.s_Styles.RealtimeLM);
            if (this.m_ShowRealtimeLM)
            {
                this.ShowRealtimeLMGUI(so, 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();
            so.ApplyModifiedProperties();
            EditorGUI.EndDisabledGroup();
            GUILayout.Space(10f);
            return(true);
        }
Пример #21
0
        public bool EditRenderers()
        {
            GameObject[] array;
            Renderer[]   selectedObjectsOfType = SceneModeUtility.GetSelectedObjectsOfType <Renderer>(out array, new Type[]
            {
                typeof(MeshRenderer),
                typeof(SkinnedMeshRenderer)
            });
            bool result;

            if (array.Length == 0)
            {
                result = false;
            }
            else
            {
                EditorGUILayout.InspectorTitlebar(selectedObjectsOfType);
                SerializedObject serializedObject = new SerializedObject(array);
                using (new EditorGUI.DisabledScope(!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);
                    EditorGUILayout.PropertyField(serializedObject2.FindProperty("m_ImportantGI"), LightingWindowObjectTab.s_Styles.ImportantGI, new GUILayoutOption[0]);
                    LightingWindowObjectTab.LightmapParametersGUI(serializedObject2.FindProperty("m_LightmapParameters"), LightingWindowObjectTab.s_Styles.LightmapParameters, true);
                    GUILayout.Space(10f);
                    this.RendererUVSettings(serializedObject2);
                    GUILayout.Space(10f);
                    this.m_ShowBakedLM = EditorGUILayout.Foldout(this.m_ShowBakedLM, LightingWindowObjectTab.s_Styles.Atlas, true);
                    if (this.m_ShowBakedLM)
                    {
                        this.ShowAtlasGUI(serializedObject2);
                    }
                    this.m_ShowRealtimeLM = EditorGUILayout.Foldout(this.m_ShowRealtimeLM, LightingWindowObjectTab.s_Styles.RealtimeLM, true);
                    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();
                }
                GUILayout.Space(10f);
                result = true;
            }
            return(result);
        }