public override void OnGUI()
        {
            ExportLightmapDataPath = (EGLUtility.File("Lightmap导出路径", ExportLightmapDataPath));
            ExportRendererDataPath = (EGLUtility.File("Renderer导出路径", ExportRendererDataPath));

            if (EGLUtility.ObjectField(out m_Target, "导出目标", m_Target, true))
            {
                TargetPath = GF.Common.Utility.ObjectUtility.CalculateTransformPath(m_Target.transform);
            }
            EditorGUILayout.LabelField("导出目标的LocalID", TargetPath);
            IncludeDeactive = EditorGUILayout.Toggle("是否包含隐藏物体", IncludeDeactive);
        }
Esempio n. 2
0
        private void OnGUI_PreprocessShaders()
        {
            ShaderToolsSetting setting = ShaderToolsSetting.GetInstance();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("添加Shader处理"))
            {
                m_PreprocessShadersForGUIs.Add(new PreprocessShadersForGUI());
            }
            if (GUILayout.Button("打包后"))
            {
                PreprocessShadersUtility.OnAfter();
            }
            EditorGUILayout.EndHorizontal();

            for (int iPreprocessShaders = 0; iPreprocessShaders < m_PreprocessShadersForGUIs.Count; iPreprocessShaders++)
            {
                PreprocessShadersForGUI iterPreprocessShadersForGUI = m_PreprocessShadersForGUIs[iPreprocessShaders];
                EditorGUILayout.BeginHorizontal();
                if (EGLUtility.ObjectField(out iterPreprocessShadersForGUI.Script, "处理脚本", iterPreprocessShadersForGUI.Script, true))
                {
                    if (iterPreprocessShadersForGUI.Script != null)
                    {
                        TryGenerateSetting(iPreprocessShaders, iterPreprocessShadersForGUI);
                    }
                }
                if (GUILayout.Button("X", GUILayout.Width(32)))
                {
                    m_PreprocessShadersForGUIs.RemoveAt(iPreprocessShaders);
                    iPreprocessShaders--;
                    continue;
                }
                EditorGUILayout.EndHorizontal();

                if (iterPreprocessShadersForGUI.Setting != null)
                {
                    iterPreprocessShadersForGUI.Setting.OnGUI();
                }
                EditorGUILayout.Space();
            }
        }
Esempio n. 3
0
        protected void OnGUI()
        {
            if (Application.isPlaying)
            {
                EditorGUILayout.HelpBox("只能在编辑器下使用"
                                        , MessageType.Warning);
                return;
            }

            if (!m_ActiveScene.IsValid())
            {
                EditorGUILayout.HelpBox("需要先打开一个场景"
                                        , MessageType.Warning);
                return;
            }

            if (string.IsNullOrEmpty(m_ActiveScene.path))
            {
                EditorGUILayout.HelpBox("只有保存到文件的场景才能使用此功能"
                                        , MessageType.Warning);
                return;
            }

            EditorGUILayout.LabelField("当前的场景", m_ActiveScene.path);

            EditorGUILayout.BeginHorizontal();
            if (EGLUtility.ObjectField(out m_ExporterScript, "导出设置", m_ExporterScript, false))
            {
                if (!m_ExporterScript.GetClass().IsSubclassOf(typeof(BaseExporter)))
                {
                    m_ExporterScript = null;
                }
            }
            if (m_ExporterScript != null &&
                GUILayout.Button("重新创建设置", GUILayout.Width(100)))
            {
                m_Exporter?.OnRelease();
                string exporterPath = ExportUtility.GetExporterPath(m_ActiveScene);
                m_Exporter = CreateInstance(m_ExporterScript.GetClass()) as BaseExporter;
                if (m_Exporter)
                {
                    m_Exporter.OnInitialize();
                    AssetDatabase.CreateAsset(m_Exporter, exporterPath);
                }
            }
            EditorGUILayout.EndHorizontal();

            if (m_Exporter)
            {
                EditorGUILayout.Space();
                EditorGUILayout.Space();

                if (GUILayout.Button("导出"))
                {
                    if (m_Exporter.CanExport(out string errorMessage))
                    {
                        try
                        {
                            m_Exporter.Export(m_ActiveScene);
                            EditorUtility.DisplayDialog("LightmapAttach", "导出完成", "Ok");
                        }
                        catch (Exception e)
                        {
                            MDebug.LogError("Renderer", "导出Lightmap失败,Exception:\n" + e.ToString());
                            EditorUtility.DisplayDialog("LightmapAttach", "导出失败:\n" + e.ToString(), "Ok");
                            MDebug.LogError("Renderer", "导出Lightmap失败,Exception:\n" + e.ToString());
                        }
                        finally
                        {
                            EditorUtility.ClearProgressBar();
                        }
                    }
                    else
                    {
                        MDebug.LogError("Renderer", "不能导出Lightmap:\n" + errorMessage);
                        EditorUtility.DisplayDialog("LightmapAttach"
                                                    , "不能导出:\n" + errorMessage
                                                    , "OK");
                    }
                }

                EditorGUI.BeginChangeCheck();
                m_Exporter.OnGUI();
                if (EditorGUI.EndChangeCheck())
                {
                    EditorUtility.SetDirty(m_Exporter);
                }
            }
        }