Skip to content

Update gameobject tools #347

@msanatan

Description

@msanatan

LLMs tend to get tripped up by some basic functions, and I believe a re-org of the tools could help make the LLMs select the right things more quickly, and we can give the users more capabilities:

manage_gameobject currently:

Retrieves:

  • GameObject Basic Info
    • Instance ID, name, tag, layer
    • Active state, static flags
    • Transform data (position, rotation, scale)
    • Parent/child hierarchy relationships
    • Prefab status and connections
  • Component Data
    • All components on a GameObject (get_components)
    • Single component data (get_component)
    • Serialized component properties (public + [SerializeField] private fields)
    • Component instance IDs and type names
  • Search/Find Results
    • Find by: ID, name, path, tag, layer, component type
    • Support for finding in children, inactive objects
    • Returns full GameObject data for found objects

Updates:

  • GameObject CRUD
    • Create: Empty, primitives, or prefab instances
    • Modify: Name, parent, tag, layer, active state, transform
    • Delete: Single or multiple GameObjects
  • Component Management
    • Add: Components with optional initial properties
    • Remove: Components by type name
    • Set Properties: Nested property support (e.g., material.color, materials[0].color)
  • Special Features
    • Prefab creation and instantiation
    • Undo/Redo support throughout
    • Physics component conflict detection (2D vs 3D)
    • Tag/Layer auto-creation
    • GameObject/Component reference resolution

There are many problems with how it's structured, here are some of the important ones:

  • LLMs trip themselves up with parameters, there's literally too much for this tool.
    • These are pretty basic operations and it annoys me that it hast to make 2/3 calls to get things right
  • We can't see what components are in the GameObject w/o serializing everything
  • The ManageGameObject.cs is 2.5K lines long, and really hard to test and maintain
  • There's a lot of redundant serializing in ManageGameObject's logic, and it happens twice because of how we list the scene hierarchy

So I have a solution for this:

  • Tools
    • manage_gameobject - GameObject lifecycle (create, modify, delete)
    • manage_components - Component lifecycle (add, remove, set_property)
    • manage_scene - Scene lifecycle (create, load, save)
    • find_gameobjects - Search operations (returns IDs only)
  • Resources
    • unity://scene/active - Active scene info
    • unity://scene/active/hierarchy - Scene hierarchy with component type lists
    • unity://scene/build-settings - Build settings scenes
    • unity://gameobject/{instanceID} - Single GameObject info (no components)
    • unity://gameobject/{instanceID}/components - All components with full data
    • unity://gameobject/{instanceID}/component/{name} - Single component data
      • There's a possibility a component can have the same name, so we may do index number

Benefits:

  • Less confusion for the LLMs using the tools
  • Easier to manage development wise
  • More data of how this plugin is actually used

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions