static void DoStaticLightingConversion()
        {
            // static lighting report
            if (m_staticConvertableCount > 0)
            {
                if (m_convertableMaterials.Count > 0)
                {
                    StaticLightingConversionHelper();

                    if (EditorUtility.DisplayDialog("Conversion Complete", "Would you like to open Vertex Lighting now?", "Yes", "No"))
                    {
                        DaydreamVertexLightingEditor.OpenWindow();
                    }
                }
            }
        }
Пример #2
0
        void OnGUI()
        {
            if (s_materialHistory == null)
            {
                Configure();
            }

            //---------------------------------------------------------------------//
            // Daydream Material Wizard
            GUILayout.Space(5);
            EditorGUILayout.LabelField(Styles.kTitle, DaydreamRendererImportManager.Styles.sectionLabel, GUILayout.Height(25));
            DaydreamRendererImportManager.DrawSection(500, 1);
            GUILayout.Space(5);

            EditorGUILayout.HelpBox(Styles.kMatierlConversionInfo, MessageType.Info);

            m_UIFade.target = EditorGUILayout.Foldout(m_UIFade.target, "Legend");

            if (EditorGUILayout.BeginFadeGroup(m_UIFade.faded))
            {
                for (int i = 0; i < Styles.matTypeContent.Length; i += 2)
                {
                    EditorGUILayout.BeginHorizontal();

                    // icon
                    EditorGUILayout.LabelField("", Styles.matTypeIcons[i], GUILayout.Width(16));
                    // info
                    EditorGUILayout.LabelField(Styles.matTypeContent[i].tooltip);

                    if (i + 1 < Styles.matTypeContent.Length)
                    {
                        // icon
                        EditorGUILayout.LabelField("", Styles.matTypeIcons[i + 1], GUILayout.Width(16));
                        // info
                        EditorGUILayout.LabelField(Styles.matTypeContent[i + 1].tooltip);
                    }

                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndFadeGroup();


            GUILayout.Space(10);


            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Convert all materials used in the 'Scene'"))
            {
                List <Material> conversionList = new List <Material>();
                var             iter           = m_infoMap.GetEnumerator();
                while (iter.MoveNext())
                {
                    if (iter.Current.Value[0] != null && iter.Current.Value[0].sceneType > 0)
                    {
                        conversionList.Add(iter.Current.Value[0].m_material);
                    }
                }

                ConvertList(conversionList);

                if (EditorUtility.DisplayDialog(Styles.kTitle, "Would you like to bake vertex lighting now?", "Yes", "No"))
                {
                    DaydreamVertexLightingEditor.OpenWindow();
                }
                else
                {
                    // open up conversion dialog again
                    ShowDialog(null);
                }
            }

            if (GUILayout.Button("Convert all materials used in the 'Project'"))
            {
                List <Material> conversionList = new List <Material>();
                var             iter           = m_infoMap.GetEnumerator();
                while (iter.MoveNext())
                {
                    if (iter.Current.Value[0] != null)
                    {
                        conversionList.Add(iter.Current.Value[0].m_material);
                    }
                }

                ConvertList(conversionList);

                if (EditorUtility.DisplayDialog(Styles.kTitle, "Would you like to bake vertex lighting now?", "Yes", "No"))
                {
                    DaydreamVertexLightingEditor.OpenWindow();
                }
                else
                {
                    // open up conversion dialog again
                    ShowDialog(null);
                }
            }
            EditorGUILayout.EndHorizontal();

            DrawAllMaterials();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();
            if (GUILayout.Button("Delete All Backup Data"))
            {
                if (EditorUtility.DisplayDialog(Styles.kTitle, "Delete all backup materials, are you sure?", "yes", "no"))
                {
                    for (int i = 0, c = s_materialHistory.m_backupMaterials.Count; i < c; ++i)
                    {
                        DestroyImmediate(s_materialHistory.m_backupMaterials[i], true);
                    }
                    s_materialHistory.m_backupMaterials.Clear();
                }
            }
            if (GUILayout.Button("Export Backups"))
            {
                List <string> assetPaths = new List <string>();
                if (!Directory.Exists(kAssetPathBackup + "/Export"))
                {
                    Directory.CreateDirectory(kAssetPathBackup + "/Export");
                }
                for (int i = 0, c = s_materialHistory.m_backupMaterials.Count; i < c; ++i)
                {
                    if (s_materialHistory.m_backupMaterials[i] != null)
                    {
                        Material copy = new Material(s_materialHistory.m_backupMaterials[i]);
                        copy.name = copy.name.Replace(kBackupPrefix, "");
                        AssetDatabase.CreateAsset(copy, kAssetPathBackup + "/Export/" + copy.name + ".mat");
                        AssetDatabase.SaveAssets();
                        AssetDatabase.Refresh();
                        assetPaths.Add(kAssetPathBackup + "/" + copy.name + ".mat");
                    }
                }
                if (assetPaths.Count > 0)
                {
                    EditorUtility.DisplayDialog(Styles.kTitle, "Materials written to " + kAssetPathBackup + "/Export", "ok");
                }
                else
                {
                    EditorUtility.DisplayDialog(Styles.kTitle, "Nothing to export", "ok");
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            if (m_repaint)
            {
                List <GameObject> roots = Utilities.GetAllRoots();
                GatherMaterials(roots.ToArray());
                this.Repaint();
            }
        }