
An object’s VisualUI document is part of its data ("VisualUI": {"Document": {...}, "Placement": {...}} in getJSON()), but spawnObjectData() doesn’t spawn it. Given the document as a Lua table, the copy stores an empty one, which TTS then rejects. Given it as a JSON string, the spawn fails. Since getData() crashes on such objects (separate report), there is no data-table way to copy an object that has a VisualUI document.
Environment: TTS 2.0 public beta (Steam build 27134291, 2026-12-04); Unity 6000.7.0b9; Linux desktop; singleplayer host.
Reproduce (Global; card is any object with a VisualUI document):
local d = JSON.decode(card.getJSON(false)) -- getData() would crash
d.GUID = nil; d.Transform.posX = d.Transform.posX + 3
local copy = spawnObjectData({data = d})
-- a few frames later:
print(copy.getJSON(false):match('"VisualUI":(%b{})')) --> {"Document":{},"Placement":{}}
print(pcall(copy.VisualUI.getProperty, "c1", "label")) --> false Attach a Visual UI document first.
d.VisualUI.Document = JSON.encode(d.VisualUI.Document) -- as a JSON string instead
print(spawnObjectData({data = d})) --> nilExpected: the copy has the same document and placement, as with spawnObjectJSON.
Actual: with a table, Document and Placement are stored empty, and setDocument with them fails with “This document revision is not supported.” With a string, nothing spawns and chat shows: Error converting Table entry Document to Type Newtonsoft.Json.Linq.JObject on Class CustomUIState … Object of type ‘System.String’ cannot be converted to type ‘Newtonsoft.Json.Linq.JObject’. So the field is a JObject, and a Lua table doesn’t convert into one.
Why it matters: copy-modify-respawn with getData()/spawnObjectData() is the common way mods change an object’s images, clean its script or clone it. Every such path silently drops VisualUI documents, including those of cards inside a respawned deck.
Workaround: for a single live object, spawn without the VisualUI field and call setDocument on the new object with getDocument() from the old one. For containers, edit the getJSON() text and use spawnObjectJSON, which keeps every document.
Found while moving our card controls to VisualUI.

