예제 #1
0
        public void JsonDeserializeSchemaProject()
        {
            TextAsset jsonProject = TestJsonLoader.LoadJson(BASIC_PROJECT);

            Assert.NotNull(jsonProject, "Unsuccessful acquirement of json text asset");

            //attempt deserializing entire project
            LdtkJson project = LdtkJson.FromJson(jsonProject.text);
        }
예제 #2
0
        public void GetLevelBounds()
        {
            const string lvlName = "Level";

            TextAsset     jsonProject = TestJsonLoader.LoadGenericProject();
            LdtkJson      project     = LdtkJson.FromJson(jsonProject.text);
            Level         level       = project.Levels.FirstOrDefault(p => p.Identifier == lvlName);
            LayerInstance layer       = level.LayerInstances.FirstOrDefault(p => p.IsIntGridLayer);
            Rect          levelBounds = level.UnityWorldSpaceBounds((int)layer.GridSize);

            Debug.Log(levelBounds);
        }
예제 #3
0
    static void Main(string[] args)
    {
        string   text     = File.ReadAllText("Entities.ldtk");
        LdtkJson ldtkJson = LdtkJson.FromJson(text);

        LdtkGeneratorContext ctx = new LdtkGeneratorContext();

        ctx.TypeConverter          = new LdtkTypeConverter();
        ctx.CodeSettings.Namespace = "MyNamespace.Test";

        SingleFileOutput fOut = new SingleFileOutput();

        fOut.OutputDir = "src-gen";
        fOut.Filename  = "MyFileCode.cs";

        LdtkCodeGenerator cg = new LdtkCodeGenerator();

        cg.GenerateCode(ldtkJson, ctx, fOut);
    }