Beispiel #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        PrefabSerializer myScript = (PrefabSerializer)target;

        if (GUILayout.Button("Export Json file"))
        {
            myScript.SerializeData();
        }
    }
Beispiel #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public org.terasology.entitySystem.prefab.PrefabData load(org.terasology.engine.module.Module module, java.io.InputStream stream, java.util.List<java.net.URL> urls, java.util.List<java.net.URL> deltas) throws java.io.IOException
        public override PrefabData load(Module module, InputStream stream, IList <URL> urls, IList <URL> deltas)
        {
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream, Charsets.UTF_8));

            EntityData.Prefab prefabData = EntityDataJSONFormat.readPrefab(reader);
            if (prefabData != null)
            {
                EngineEntityManager       entityManager = CoreRegistry.get(typeof(EngineEntityManager));
                IList <EntityData.Prefab> deltaData     = Lists.newArrayListWithCapacity(deltas.Count);
                foreach (URL deltaUrl in deltas)
                {
                    using (BufferedReader deltaReader = new BufferedReader(new InputStreamReader(deltaUrl.openStream(), Charsets.UTF_8)))
                    {
                        EntityData.Prefab delta = EntityDataJSONFormat.readPrefab(deltaReader);
                        deltaData.Add(delta);
                    }
                }
                PrefabSerializer serializer = new PrefabSerializer(entityManager.ComponentLibrary, entityManager.TypeSerializerLibrary);
                return(serializer.deserialize(prefabData, deltaData));
            }
            return(null);
        }