GameObject API: spawn, find, hierarchy, activation, name, destroy (#75) #82
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
crowmaki/cinnabar#82
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent
#75
What to build
A Script reaches GameObjects with the names Unity uses. A GameObject reaching Luau is a userdata carrying the GameObject Handle, cached per Handle in a weak table so identity comparison works within a frame. Its metatable exposes
name(read/write),parent(read/write),active(read/write) andactiveInHierarchy(read-only) as properties, andIsAlive,SetActive,GetChildren(children in sibling order) andDestroyas methods.GameObject.new()andGameObject.new(name, parent)create a GameObject in the top Scene.GameObject.Find("scene:Room/Lamp")resolves a Display Path to a GameObject ornil. A globalDestroy(go)matchesgo:Destroy(); both queue removal for the next Structural Flush.self.gameObjectinside a Component method returns the owner.Any access to a dead Handle raises a Luau error that names the operation;
IsAliveis the one exception and never raises, answering false at once after destruction.Acceptance criteria
GameObject.new()andGameObject.new(name, parent)create a GameObject visible to Odin viascene_object_count,gameobject_nameandgameobject_parentgo.namereads and writes the Name;go.parentreads and writes the parent;go:GetChildren()lists children in sibling ordergo.active,go:SetActive(false)andgo.activeInHierarchyagree withgameobject_is_activeandgameobject_is_active_in_hierarchy, including under an inactive ancestorGameObject.Findresolves an authored Display Path and returnsnilfor an unknown oneDestroy(go)andgo:Destroy()leave the GameObject alive until the next Structural Flush and gone after itgo:IsAlive()is false and readinggo.nameraises an error whose message names the operation==self.gameObjectinAwakereturns the owner the Component was added toBlocked by