rj-action-library/Runtime/Godot/Scenes/SceneFileReader.cs

51 lines
845 B
C#

using Godot;
using System;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass]
public partial class SceneFileReader:Node
{
[Export]
public string path = "";
[Export]
public bool load
{
get => false;
set { if ( value ) LoadScene(); }
}
[Export]
public bool exportJSON = false;
[Export]
public bool exportHTML = false;
void LoadScene()
{
var text = FilesSync.LoadUTF8( path );
var parser = new SceneFileParser();
parser.Parse( text );
if ( exportJSON )
{
FilesSync.SaveJSON( path + ".json", parser.sceneFile.GetSerializableJSONVersion() );
}
if ( exportHTML )
{
var exporter = new SceneFileHTMLExporter();
exporter.ParseAndExport( parser, path );
}
}
}
}