GetInputSystemHash() private method

private GetInputSystemHash ( Renderer renderer, Hash128 &inputSystemHash ) : bool
renderer UnityEngine.Renderer
inputSystemHash UnityEngine.Hash128
return bool
        private void ShowRealtimeLMGUI(SerializedObject so, Renderer renderer)
        {
            Hash128 hash;
            Hash128 hash2;
            int     num;
            int     num2;
            Hash128 hash3;
            int     num3;
            int     num4;

            EditorGUI.indentLevel++;
            if (LightmapEditorSettings.GetInstanceHash(renderer, out hash))
            {
                EditorGUILayout.LabelField(s_Styles.RealtimeLMInstanceHash, new GUIContent(hash.ToString()), new GUILayoutOption[0]);
            }
            if (LightmapEditorSettings.GetGeometryHash(renderer, out hash2))
            {
                EditorGUILayout.LabelField(s_Styles.RealtimeLMGeometryHash, new GUIContent(hash2.ToString()), new GUILayoutOption[0]);
            }
            if (LightmapEditorSettings.GetInstanceResolution(renderer, out num, out num2))
            {
                EditorGUILayout.LabelField(s_Styles.RealtimeLMInstanceResolution, new GUIContent(num.ToString() + "x" + num2.ToString()), new GUILayoutOption[0]);
            }
            if (LightmapEditorSettings.GetInputSystemHash(renderer, out hash3))
            {
                EditorGUILayout.LabelField(s_Styles.RealtimeLMInputSystemHash, new GUIContent(hash3.ToString()), new GUILayoutOption[0]);
            }
            if (LightmapEditorSettings.GetSystemResolution(renderer, out num3, out num4))
            {
                EditorGUILayout.LabelField(s_Styles.RealtimeLMResolution, new GUIContent(num3.ToString() + "x" + num4.ToString()), new GUILayoutOption[0]);
            }
            EditorGUI.indentLevel--;
        }
        private void UpdateActiveGameObjectSelection()
        {
            MeshRenderer renderer;
            Terrain      terrain = null;

            // if the active object in the selection is a renderer or a terrain, we're interested in it's lightmapIndex
            if (Selection.activeGameObject == null ||
                ((renderer = Selection.activeGameObject.GetComponent <MeshRenderer>()) == null &&
                 (terrain = Selection.activeGameObject.GetComponent <Terrain>()) == null))
            {
                m_ActiveGameObjectLightmapIndex = -1;
                m_ActiveGameObjectTextureHash   = new Hash128();
                return;
            }
            if (isRealtimeLightmap)
            {
                Hash128 inputSystemHash;
                if ((renderer != null && LightmapEditorSettings.GetInputSystemHash(renderer.GetInstanceID(), out inputSystemHash)) ||
                    (terrain != null && LightmapEditorSettings.GetInputSystemHash(terrain.GetInstanceID(), out inputSystemHash)))
                {
                    m_ActiveGameObjectTextureHash = inputSystemHash;
                }
                else
                {
                    m_ActiveGameObjectTextureHash = new Hash128();
                }
            }
            else
            {
                m_ActiveGameObjectLightmapIndex = renderer != null ? renderer.lightmapIndex : terrain.lightmapIndex;
            }
        }
        void ShowRealtimeLMGUI(Terrain terrain)
        {
            EditorGUI.indentLevel += 1;

            Hash128 inputSystemHash;

            if (terrain != null && LightmapEditorSettings.GetInputSystemHash(terrain.GetInstanceID(), out inputSystemHash))
            {
                ShowRealtimeLightmapPreview(inputSystemHash);
            }

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

            if (LightmapEditorSettings.GetTerrainSystemResolution(terrain, out width, out height, out numChunksInX, out numChunksInY))
            {
                var str = width.ToString() + "x" + height.ToString();
                if (numChunksInX > 1 || numChunksInY > 1)
                {
                    str += string.Format(" ({0}x{1} chunks)", numChunksInX, numChunksInY);
                }
                EditorGUILayout.LabelField(Styles.RealtimeLMResolution, GUIContent.Temp(str));
            }

            EditorGUI.indentLevel -= 1;
        }
Exemplo n.º 4
0
        void ShowRealtimeLMGUI(Terrain terrain)
        {
            Hash128 inputSystemHash;

            if (terrain == null || !LightmapEditorSettings.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 (LightmapEditorSettings.GetTerrainSystemResolution(terrain, out width, out height, out numChunksInX, out numChunksInY))
            {
                var str = width.ToString() + "x" + height.ToString();
                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);
        }
Exemplo n.º 5
0
        void ShowRealtimeLMGUI(Renderer renderer)
        {
            EditorGUI.indentLevel += 1;

            // The hash of the instance.
            Hash128 instanceHash;

            if (LightmapEditorSettings.GetInstanceHash(renderer, out instanceHash))
            {
                EditorGUILayout.LabelField(s_Styles.RealtimeLMInstanceHash, GUIContent.Temp(instanceHash.ToString()));
            }

            // The hash of the geometry.
            Hash128 geometryHash;

            if (LightmapEditorSettings.GetGeometryHash(renderer, out geometryHash))
            {
                EditorGUILayout.LabelField(s_Styles.RealtimeLMGeometryHash, GUIContent.Temp(geometryHash.ToString()));
            }

            // Resolution of the packed instance.
            int instWidth, instHeight;

            if (LightmapEditorSettings.GetInstanceResolution(renderer, out instWidth, out instHeight))
            {
                EditorGUILayout.LabelField(s_Styles.RealtimeLMInstanceResolution, GUIContent.Temp(instWidth.ToString() + "x" + instHeight.ToString()));
            }

            // The hash of the system.
            Hash128 inputSystemHash;

            if (LightmapEditorSettings.GetInputSystemHash(renderer, out inputSystemHash))
            {
                EditorGUILayout.LabelField(s_Styles.RealtimeLMInputSystemHash, GUIContent.Temp(inputSystemHash.ToString()));
            }

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

            if (LightmapEditorSettings.GetSystemResolution(renderer, out width, out height))
            {
                EditorGUILayout.LabelField(s_Styles.RealtimeLMResolution, GUIContent.Temp(width.ToString() + "x" + height.ToString()));
            }

            EditorGUI.indentLevel -= 1;
        }
        void ShowRealtimeLMGUI(Renderer renderer)
        {
            EditorGUI.indentLevel += 1;

            Hash128 inputSystemHash = new Hash128();

            if (renderer != null && LightmapEditorSettings.GetInputSystemHash(renderer.GetInstanceID(), out inputSystemHash))
            {
                ShowRealtimeLightmapPreview(inputSystemHash);
            }

            int instWidth, instHeight;

            if (LightmapEditorSettings.GetInstanceResolution(renderer, out instWidth, out instHeight))
            {
                EditorGUILayout.LabelField(Styles.RealtimeLMInstanceResolution, GUIContent.Temp(instWidth.ToString() + "x" + instHeight.ToString()));
            }

            int width, height;

            if (LightmapEditorSettings.GetSystemResolution(renderer, out width, out height))
            {
                EditorGUILayout.LabelField(Styles.RealtimeLMResolution, GUIContent.Temp(width.ToString() + "x" + height.ToString()));
            }

            if (Unsupported.IsDeveloperMode())
            {
                Hash128 instanceHash;
                if (LightmapEditorSettings.GetInstanceHash(renderer, out instanceHash))
                {
                    EditorGUILayout.LabelField(Styles.RealtimeLMInstanceHash, GUIContent.Temp(instanceHash.ToString()));
                }

                Hash128 geometryHash;
                if (LightmapEditorSettings.GetGeometryHash(renderer, out geometryHash))
                {
                    EditorGUILayout.LabelField(Styles.RealtimeLMGeometryHash, GUIContent.Temp(geometryHash.ToString()));
                }

                EditorGUILayout.LabelField(Styles.RealtimeLMInputSystemHash, GUIContent.Temp(inputSystemHash.ToString()));
            }

            EditorGUI.indentLevel -= 1;
        }
        private void ShowRealtimeLMGUI(SerializedObject so, Renderer renderer)
        {
            ++EditorGUI.indentLevel;
            Hash128 instanceHash;

            if (LightmapEditorSettings.GetInstanceHash(renderer, out instanceHash))
            {
                EditorGUILayout.LabelField(LightingWindowObjectTab.s_Styles.RealtimeLMInstanceHash, new GUIContent(instanceHash.ToString()), new GUILayoutOption[0]);
            }
            Hash128 geometryHash;

            if (LightmapEditorSettings.GetGeometryHash(renderer, out geometryHash))
            {
                EditorGUILayout.LabelField(LightingWindowObjectTab.s_Styles.RealtimeLMGeometryHash, new GUIContent(geometryHash.ToString()), new GUILayoutOption[0]);
            }
            int width1;
            int height1;

            if (LightmapEditorSettings.GetInstanceResolution(renderer, out width1, out height1))
            {
                EditorGUILayout.LabelField(LightingWindowObjectTab.s_Styles.RealtimeLMInstanceResolution, new GUIContent(width1.ToString() + "x" + height1.ToString()), new GUILayoutOption[0]);
            }
            Hash128 inputSystemHash;

            if (LightmapEditorSettings.GetInputSystemHash(renderer, out inputSystemHash))
            {
                EditorGUILayout.LabelField(LightingWindowObjectTab.s_Styles.RealtimeLMInputSystemHash, new GUIContent(inputSystemHash.ToString()), new GUILayoutOption[0]);
            }
            int width2;
            int height2;

            if (LightmapEditorSettings.GetSystemResolution(renderer, out width2, out height2))
            {
                EditorGUILayout.LabelField(LightingWindowObjectTab.s_Styles.RealtimeLMResolution, new GUIContent(width2.ToString() + "x" + height2.ToString()), new GUILayoutOption[0]);
            }
            --EditorGUI.indentLevel;
        }
Exemplo n.º 8
0
        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 && LightmapEditorSettings.GetInputSystemHash(renderer.GetInstanceID(), out inputSystemHash)) ||
                    (terrain != null && LightmapEditorSettings.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();
            }
        }
        private void UpdateCachedTexture(GITextureType textureType)
        {
            if (isIndexBased)
            {
                if (isRealtimeLightmap)
                {
                    Hash128[] mainHashes = LightmapEditorSettings.GetMainSystemHashes();

                    if (!m_RealtimeTextureHash.isValid || !mainHashes.Contains(m_RealtimeTextureHash))
                    {
                        m_RealtimeTextureHash = mainHashes.ElementAtOrDefault(m_LightmapIndex);
                    }
                }
            }
            else
            {
                if (isRealtimeLightmap)
                {
                    Hash128 systemHash;

                    if (!LightmapEditorSettings.GetInputSystemHash(instanceID, out systemHash))
                    {
                        return;
                    }

                    m_RealtimeTextureHash = systemHash;
                }
                else
                {
                    int lightmapIndex;

                    if (!LightmapEditorSettings.GetLightmapIndex(instanceID, out lightmapIndex))
                    {
                        return;
                    }

                    m_LightmapIndex = lightmapIndex;
                }
            }

            Hash128 contentHash = isRealtimeLightmap ? LightmapVisualizationUtility.GetRealtimeGITextureHash(m_RealtimeTextureHash, textureType) :
                                  LightmapVisualizationUtility.GetBakedGITextureHash(m_LightmapIndex, 0, textureType);

            // if we need to fetch a new texture
            if (m_CachedTexture.texture == null || m_CachedTexture.type != textureType || m_CachedTexture.contentHash != contentHash || m_CachedTexture.contentHash == new Hash128())
            {
                m_CachedTexture = isRealtimeLightmap ?
                                  LightmapVisualizationUtility.GetRealtimeGITexture(m_RealtimeTextureHash, textureType) :
                                  LightmapVisualizationUtility.GetBakedGITexture(m_LightmapIndex, 0, textureType);
            }

            if (!m_ShowUVOverlay)
            {
                return; // if we don't wanna show any overlay
            }
            if (m_CachedTexture.texture == null || m_CachedTexture.textureAvailability == GITextureAvailability.GITextureNotAvailable || m_CachedTexture.textureAvailability == GITextureAvailability.GITextureUnknown)
            {
                return; // if we dont have a texture
            }
            // fetch Renderers

            if (isRealtimeLightmap)
            {
                m_CachedTextureObjects = LightmapVisualizationUtility.GetRealtimeGITextureRenderers(m_RealtimeTextureHash);
            }
            else
            {
                m_CachedTextureObjects = LightmapVisualizationUtility.GetBakedGITextureRenderers(m_LightmapIndex);
            }
        }
Exemplo n.º 10
0
        void ShowRealtimeLMGUI(Renderer renderer)
        {
            Hash128 inputSystemHash;

            if (renderer == null || !LightmapEditorSettings.GetInputSystemHash(renderer.GetInstanceID(), out inputSystemHash) || inputSystemHash == new Hash128())
            {
                return; // early return since we don't have any lightmaps for it
            }
            if (!UpdateRealtimeTexture(inputSystemHash, renderer.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, renderer.GetInstanceID());

            GUILayout.BeginVertical();

            int instWidth, instHeight;

            if (LightmapEditorSettings.GetInstanceResolution(renderer, out instWidth, out instHeight))
            {
                GUILayout.Label(Styles.RealtimeLMInstanceResolution.text + ": " + instWidth.ToString() + "x" + instHeight.ToString());
            }

            int width, height;

            if (LightmapEditorSettings.GetSystemResolution(renderer, out width, out height))
            {
                GUILayout.Label(Styles.RealtimeLMResolution.text + ": " + width.ToString() + "x" + height.ToString());
            }

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

            if (Unsupported.IsDeveloperMode())
            {
                Hash128 instanceHash;
                if (LightmapEditorSettings.GetInstanceHash(renderer, out instanceHash))
                {
                    EditorGUILayout.LabelField(Styles.RealtimeLMInstanceHash, GUIContent.Temp(instanceHash.ToString()));
                }

                Hash128 geometryHash;
                if (LightmapEditorSettings.GetGeometryHash(renderer, out geometryHash))
                {
                    EditorGUILayout.LabelField(Styles.RealtimeLMGeometryHash, GUIContent.Temp(geometryHash.ToString()));
                }

                EditorGUILayout.LabelField(Styles.RealtimeLMInputSystemHash, GUIContent.Temp(inputSystemHash.ToString()));
            }

            EditorGUI.indentLevel -= 1;

            GUILayout.Space(5);
        }