#[Solved] Godot 4 show variables of nodes in an array in inspector.

2 messages · Page 1 of 1 (latest)

sweet plank
#

I am working on my first in editor tool but I am having trouble figuring out how to get export variables to show up for items in an array.

Here is my code so far:

@tool
class_name tiletogridmanager
extends Node

@export var ttgs:Array[tiletogrid]

@export var BuildGridmap: bool:
    set(value):
        if Engine.is_editor_hint():
            _copy_tiles()

@export var ClearGridap: bool:
    set(value):
        if Engine.is_editor_hint():
            _clear_tiles()

func _copy_tiles():
    for ttg in ttgs:
        ttg.copy_tiles()

func _clear_tiles():
    for ttg in ttgs:
        ttg.gridmap.clear()
extends Node
class_name tiletogrid

@export var tilemap: TileMapLayer
@export var gridmap: GridMap
@export var grid_hieght: int

func copy_tiles():
    for tile_pos in tilemap.get_used_cells():
        var tiledata = tilemap.get_cell_tile_data(tile_pos)
        var gridmesh = tiledata.get_custom_data("MeshName")
        var grid_pos = Vector3i(tile_pos.x, grid_hieght, tile_pos.y)
        gridmap.set_cell_item(grid_pos, gridmesh)

I have tried the tiletogrid as both a node and a resource and am not getting the result I am looking for.

What I want to see is: if I am looking at the array of ttgs on the manager I would like to be able to see and edit the tilemap, gridmap and grid_height for each element in the array without having to go to each node.

Any advice on how to achieve this?

sweet plank
#

I was able to get this working using @export_node_path with resource.