FromXML() public method

Import XML data into this camera path overwriting the current data
public FromXML ( string XMLPath ) : void
XMLPath string An XML file path
return void
Esempio n. 1
0
    public static void InspectorGUI(TrackBuildR track)
    {
        TrackBuildRTrack trackData = track.track;

        const int guiWidth    = 400;
        const int textWidth   = 348;
        const int toggleWidth = 25;
        const int helpWidth   = 20;

        CURRENT_TRANSFORM = track.transform;
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Filename", GUILayout.Width(225));
        track.exportFilename = EditorGUILayout.TextField(track.exportFilename, GUILayout.Width(175));
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Filetype", GUILayout.Width(350));
        track.fileType = (TrackBuildR.fileTypes)EditorGUILayout.EnumPopup(track.fileType, GUILayout.Width(50));
        switch (track.fileType)
        {
        case TrackBuildR.fileTypes.Obj:
            FILE_EXTENTION = ".obj";
            break;

        case TrackBuildR.fileTypes.Fbx:
            FILE_EXTENTION = ".fbx";
            break;
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Copy Textures into Export Folder", GUILayout.Width(textWidth));
        track.copyTexturesIntoExportFolder = EditorGUILayout.Toggle(track.copyTexturesIntoExportFolder, GUILayout.Width(toggleWidth));
        if (GUILayout.Button("?", GUILayout.Width(helpWidth)))
        {
            string helpTitle = "Help - Copy Textures into Export Folder";
            string helpBody  = "Check this box if you want to copy the textures you are using into the export folder." +
                               "\nThis is useful if you plan to use the exported model elsewhere. Having the model and the textures in one folder will allow you to move this model with ease.";
            EditorUtility.DisplayDialog(helpTitle, helpBody, "close");
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Export Collider");
//        track.exportSimpleCollider = EditorGUILayout.Toggle(track.exportSimpleCollider, GUILayout.Width(toggleWidth));
        track.exportCollider = EditorGUILayout.Toggle(track.exportCollider, GUILayout.Width(toggleWidth));
        if (GUILayout.Button("?", GUILayout.Width(helpWidth)))
        {
            string helpTitle = "Help - Export Collider Mesh";
            string helpBody  = "Check this box if you wish to generate a trackCollider mesh for your model." +
                               "\nThis will generate a mesh to be used with colliders.";
            EditorUtility.DisplayDialog(helpTitle, helpBody, "close");
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Export as Prefab", GUILayout.Width(textWidth));
        track.createPrefabOnExport = EditorGUILayout.Toggle(track.createPrefabOnExport, GUILayout.Width(toggleWidth));
        if (GUILayout.Button("?", GUILayout.Width(helpWidth)))
        {
            string helpTitle = "Help - Export as Prefab";
            string helpBody  = "Select this if you wish to create a prefab of your model." +
                               "\nThis is recommended if you're exporting a trackCollider so they will get packaged together.";
            EditorUtility.DisplayDialog(helpTitle, helpBody, "close");
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        bool usingSubstances  = false;
        int  numberOfTextures = trackData.numberOfTextures;

        for (int i = 0; i < numberOfTextures; i++)
        {
            TrackBuildRTexture texture = trackData.Texture(i);
            if (texture.type == TrackBuildRTexture.Types.Substance)
            {
                usingSubstances = true;
                break;
            }
        }
        if (usingSubstances)
        {
            EditorGUILayout.HelpBox("Model uses Substance textures." +
                                    "\nExporting model to " + track.fileType + " will lose references to this texture and it will be rendered white.",
                                    MessageType.Warning);
        }

        if (GUILayout.Button("Export", GUILayout.Width(guiWidth), GUILayout.Height(40)))
        {
            ExportModel(track);
        }

        EditorGUILayout.Space();
        if (GUILayout.Button("Export to XML"))
        {
            string defaultName = track.name;
            defaultName.Replace(" ", "_");
            string filepath = EditorUtility.SaveFilePanel("Export Track BuildR Track to XML", "Assets/TrackBuildR", defaultName, "xml");

            if (filepath != "")
            {
                using (StreamWriter sw = new StreamWriter(filepath))
                {
                    sw.Write(track.ToXML());//write out contents of data to XML
                }
            }
            AssetDatabase.Refresh();
        }
        if (GUILayout.Button("Import from XML"))
        {
            string xmlpath = EditorUtility.OpenFilePanel("Import Track BuildR Track from XML", "Assets/TrackBuildR/", "xml");
            if (xmlpath != "")
            {
                track.FromXML(xmlpath);
            }
        }
        if (GUILayout.Button("Import from KML"))
        {
            string xmlpath = EditorUtility.OpenFilePanel("Import Google Earth KML", "Assets/TrackBuildR/", "kml");
            if (xmlpath != "")
            {
                track.FromKML(xmlpath);
            }
        }

        CURRENT_TRANSFORM = null;
    }
Esempio n. 2
0
    public static void InspectorGUI(TrackBuildR track)
    {
        TrackBuildRTrack trackData = track.track;

        const int guiWidth = 400;
        const int textWidth = 348;
        const int toggleWidth = 25;
        const int helpWidth = 20;

        CURRENT_TRANSFORM = track.transform;
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Filename", GUILayout.Width(225));
        track.exportFilename = EditorGUILayout.TextField(track.exportFilename, GUILayout.Width(175));
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Filetype", GUILayout.Width(350));
        track.fileType = (TrackBuildR.fileTypes)EditorGUILayout.EnumPopup(track.fileType, GUILayout.Width(50));
        switch (track.fileType)
        {
            case TrackBuildR.fileTypes.Obj:
                FILE_EXTENTION = ".obj";
                break;
            case TrackBuildR.fileTypes.Fbx:
                FILE_EXTENTION = ".fbx";
                break;
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Copy Textures into Export Folder", GUILayout.Width(textWidth));
        track.copyTexturesIntoExportFolder = EditorGUILayout.Toggle(track.copyTexturesIntoExportFolder, GUILayout.Width(toggleWidth));
        if (GUILayout.Button("?", GUILayout.Width(helpWidth)))
        {
            string helpTitle = "Help - Copy Textures into Export Folder";
            string helpBody = "Check this box if you want to copy the textures you are using into the export folder." +
                "\nThis is useful if you plan to use the exported model elsewhere. Having the model and the textures in one folder will allow you to move this model with ease.";
            EditorUtility.DisplayDialog(helpTitle, helpBody, "close");
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Export Collider");
//        track.exportSimpleCollider = EditorGUILayout.Toggle(track.exportSimpleCollider, GUILayout.Width(toggleWidth));
        track.exportCollider = EditorGUILayout.Toggle(track.exportCollider, GUILayout.Width(toggleWidth));
        if (GUILayout.Button("?", GUILayout.Width(helpWidth)))
        {
            string helpTitle = "Help - Export Collider Mesh";
            string helpBody = "Check this box if you wish to generate a trackCollider mesh for your model." +
                "\nThis will generate a mesh to be used with colliders.";
            EditorUtility.DisplayDialog(helpTitle, helpBody, "close");
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Export as Prefab", GUILayout.Width(textWidth));
        track.createPrefabOnExport = EditorGUILayout.Toggle(track.createPrefabOnExport, GUILayout.Width(toggleWidth));
        if (GUILayout.Button("?", GUILayout.Width(helpWidth)))
        {
            string helpTitle = "Help - Export as Prefab";
            string helpBody = "Select this if you wish to create a prefab of your model." +
                "\nThis is recommended if you're exporting a trackCollider so they will get packaged together.";
            EditorUtility.DisplayDialog(helpTitle, helpBody, "close");
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        bool usingSubstances = false;
        int numberOfTextures = trackData.numberOfTextures;
        for(int i = 0; i < numberOfTextures; i++)
        {
            TrackBuildRTexture texture = trackData.Texture(i);
            if(texture.type == TrackBuildRTexture.Types.Substance)
            {
                usingSubstances = true;
                break;
            }
        }
        if (usingSubstances)
        {
            EditorGUILayout.HelpBox("Model uses Substance textures." +
                "\nExporting model to " + track.fileType + " will lose references to this texture and it will be rendered white.",
                MessageType.Warning);
        }

        if (GUILayout.Button("Export", GUILayout.Width(guiWidth), GUILayout.Height(40)))
        {
            ExportModel(track);
        }

        EditorGUILayout.Space();
        if(GUILayout.Button("Export to XML"))
        {
            string defaultName = track.name;
            defaultName.Replace(" ", "_");
            string filepath = EditorUtility.SaveFilePanel("Export Track BuildR Track to XML", "Assets/TrackBuildR", defaultName, "xml");

            if (filepath != "")
            {
                using (StreamWriter sw = new StreamWriter(filepath))
                {
                    sw.Write(track.ToXML());//write out contents of data to XML
                }
            }
            AssetDatabase.Refresh();
        }
        if (GUILayout.Button("Import from XML"))
        {
            string xmlpath = EditorUtility.OpenFilePanel("Import Track BuildR Track from XML", "Assets/TrackBuildR/", "xml");
            if (xmlpath != "")
                track.FromXML(xmlpath);
        }
        if (GUILayout.Button("Import from KML"))
        {
            string xmlpath = EditorUtility.OpenFilePanel("Import Google Earth KML", "Assets/TrackBuildR/", "kml");
            if (xmlpath != "")
                track.FromKML(xmlpath);
        }

        CURRENT_TRANSFORM = null;
    }