private void MakeSerializable(GameObject go, Table table) { // add table component (plus other data) _tb = go.AddComponent <TableBehavior>(); _tb.SetItem(table); var sidecar = _tb.GetOrCreateSidecar(); foreach (var key in table.TableInfo.Keys) { sidecar.tableInfo[key] = table.TableInfo[key]; } // copy each texture ref into the sidecar's serialized storage foreach (var tex in table.Textures) { sidecar.textures.Add(tex); } // and tell the engine's table to now use the sidecar as its container so we can all operate on the same underlying container table.SetTextureContainer(sidecar.textures); sidecar.customInfoTags = table.CustomInfoTags; sidecar.collections = table.Collections.Values.Select(c => c.Data).ToArray(); sidecar.decals = table.GetAllData <Decal, DecalData>(); sidecar.dispReels = table.GetAllData <DispReel, DispReelData>(); sidecar.flashers = table.GetAllData <Flasher, FlasherData>(); sidecar.lightSeqs = table.GetAllData <LightSeq, LightSeqData>(); sidecar.plungers = table.GetAllData <Plunger, PlungerData>(); sidecar.sounds = table.Sounds.Values.Select(d => d.Data).ToArray(); sidecar.textBoxes = table.GetAllData <TextBox, TextBoxData>(); sidecar.timers = table.GetAllData <Timer, TimerData>(); Logger.Info("Collections saved: [ {0} ] [ {1} ]", string.Join(", ", table.Collections.Keys), string.Join(", ", sidecar.collections.Select(c => c.Name)) ); }