< Summary

Class:GLTFExportMenu
Assembly:UnityGLTFEditorAssembly
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/UnityGLTF/Scripts/Editor/GLTFExportMenu.cs
Covered lines:0
Uncovered lines:46
Coverable lines:46
Total lines:99
Line coverage:0% (0 of 46)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
RetrieveTexturePath(...)0%2100%
Init()0%2100%
OnGUI()0%2100%
ExportSelected()0%20400%
ExportGLBSelected()0%20400%
ExportScene()0%12300%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/UnityGLTF/Scripts/Editor/GLTFExportMenu.cs

#LineLine coverage
 1using System;
 2using UnityEditor;
 3using UnityEngine.SceneManagement;
 4using UnityGLTF;
 5
 6public class GLTFExportMenu : EditorWindow
 7{
 8    public static string RetrieveTexturePath(UnityEngine.Texture texture)
 9    {
 010        return AssetDatabase.GetAssetPath(texture);
 11    }
 12
 13    [MenuItem("GLTF/Settings")]
 14    static void Init()
 15    {
 016        GLTFExportMenu window = (GLTFExportMenu)EditorWindow.GetWindow(typeof(GLTFExportMenu), false, "GLTF Settings");
 017        window.Show();
 018    }
 19
 20    void OnGUI()
 21    {
 022        EditorGUILayout.LabelField("Exporter", EditorStyles.boldLabel);
 023        GLTFSceneExporter.ExportFullPath = EditorGUILayout.Toggle("Export using original path", GLTFSceneExporter.Export
 024        GLTFSceneExporter.ExportNames = EditorGUILayout.Toggle("Export names of nodes", GLTFSceneExporter.ExportNames);
 025        GLTFSceneExporter.RequireExtensions = EditorGUILayout.Toggle("Require extensions", GLTFSceneExporter.RequireExte
 026        EditorGUILayout.Separator();
 027        EditorGUILayout.LabelField("Importer", EditorStyles.boldLabel);
 028        EditorGUILayout.Separator();
 029        EditorGUILayout.HelpBox("UnityGLTF version 0.1", MessageType.Info);
 030        EditorGUILayout.HelpBox("Supported extensions: KHR_material_pbrSpecularGlossiness, ExtTextureTransform", Message
 031    }
 32
 33    [MenuItem("GLTF/Export Selected")]
 34    static void ExportSelected()
 35    {
 36        string name;
 037        if (Selection.transforms.Length > 1)
 38        {
 039            name = SceneManager.GetActiveScene().name;
 040        }
 041        else if (Selection.transforms.Length == 1)
 42        {
 043            name = Selection.activeGameObject.name;
 044        }
 45        else
 46        {
 047            throw new Exception("No objects selected, cannot export.");
 48        }
 49
 050        var exporter = new GLTFSceneExporter(Selection.transforms, RetrieveTexturePath);
 51
 052        var path = EditorUtility.OpenFolderPanel("glTF Export Path", "", "");
 053        if (!string.IsNullOrEmpty(path))
 54        {
 055            exporter.SaveGLTFandBin(path, name);
 56        }
 057    }
 58
 59    [MenuItem("GLTF/ExportGLB Selected")]
 60    static void ExportGLBSelected()
 61    {
 62        string name;
 063        if (Selection.transforms.Length > 1)
 64        {
 065            name = SceneManager.GetActiveScene().name;
 066        }
 067        else if (Selection.transforms.Length == 1)
 68        {
 069            name = Selection.activeGameObject.name;
 070        }
 71        else
 72        {
 073            throw new Exception("No objects selected, cannot export.");
 74        }
 75
 076        var exporter = new GLTFSceneExporter(Selection.transforms, RetrieveTexturePath);
 77
 078        var path = EditorUtility.OpenFolderPanel("glTF Export Path", "", "");
 079        if (!string.IsNullOrEmpty(path))
 80        {
 081            exporter.SaveGLB(path, name);
 82        }
 083    }
 84
 85    [MenuItem("GLTF/Export Scene")]
 86    static void ExportScene()
 87    {
 088        var scene = SceneManager.GetActiveScene();
 089        var gameObjects = scene.GetRootGameObjects();
 090        var transforms = Array.ConvertAll(gameObjects, gameObject => gameObject.transform);
 91
 092        var exporter = new GLTFSceneExporter(transforms, RetrieveTexturePath);
 093        var path = EditorUtility.OpenFolderPanel("glTF Export Path", "", "");
 094        if (path != "")
 95        {
 096            exporter.SaveGLTFandBin(path, scene.name);
 97        }
 098    }
 99}