GameObject API: spawn, find, hierarchy, activation, name, destroy (#82) #94
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
crowmaki/cinnabar!94
Loading…
Reference in a new issue
No description provided.
Delete branch "issue-82-gameobject-api"
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?
Closes #82. Part of #75.
What
A Script reaches GameObjects with the names Unity uses, through a userdata carrying the GameObject Handle and cached per Handle in a weak table, so
==is identity within a frame.name(read/write),parent(read/write,nildetaches to the root),active(read/write),activeInHierarchy(read-only).IsAlive,SetActive,GetChildren(sibling order),Destroy.GameObject.new()/GameObject.new(name, parent)create in the top Scene, or the parent's Scene.GameObject.Find(displayPath)resolves a Display Path or answersnil.Destroy(go)matchesgo:Destroy().self.gameObjectinside a Component method is the owner; a Script Schema may not name a fieldgameObject.read name on a destroyed GameObject,GetChildren on a destroyed GameObject).IsAlivenever raises.Userdata_Tagenum between Component instances and GameObjects.One reading to confirm
The issue says Destroy leaves the GameObject "alive until the next Structural Flush and gone after it", and also that
IsAliveanswers "false at once after destruction". Core already makes a destroyed Handle stop validating at once and releases storage at the flush, so this follows Core:IsAliveis false immediately,OnDestroyand storage release wait for the flush. The test observes the flush boundary throughOnDestroy.Tests
tests/luau/gameobject_test.odincovers every acceptance criterion from Luau source strings, checked againstscene_object_count,gameobject_name,gameobject_parent,gameobject_is_activeandgameobject_is_active_in_hierarchy.just checkandjust testpass (437 tests).