GDExtension can't edit properties in the inspector.
Asked Answered
T

3

0

In the inspector, it will show the boxes for the values:

But I can't edit them, instead getting this output:

Set numCol
  core/object/class_db.cpp:1642 - Instantiated Node3D used as default value for HexMap's "numCol" property.
  core/object/class_db.cpp:1642 - Instantiated Node3D used as default value for HexMap's "numCol" property.

Here's the _bind_methods() function:

void HexMap::_bind_methods() {
    ClassDB::bind_method(D_METHOD("setNumCol", "p_numCol"), &HexMap::setCameraRig);
    ClassDB::bind_method(D_METHOD("getNumCol"), &HexMap::getCameraRig);
    ADD_PROPERTY(PropertyInfo(Variant::INT, "numCol"), "setNumCol", "getNumCol");

    ClassDB::bind_method(D_METHOD("setNumRow", "p_numRow"), &HexMap::setCameraRig);
    ClassDB::bind_method(D_METHOD("getNumRow"), &HexMap::getCameraRig);
    ADD_PROPERTY(PropertyInfo(Variant::INT, "numRow"), "setNumRow", "getNumRow");

    ClassDB::bind_method(D_METHOD("setCameraRig", "p_cameraRig"), &HexMap::setCameraRig);
    ClassDB::bind_method(D_METHOD("getCameraRig"), &HexMap::getCameraRig);
    ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "cameraRig"), "setCameraRig", "getCameraRig");
    
    ClassDB::bind_method(D_METHOD("checkAndWrapHex", "hexCell"), &HexMap::checkAndWrapHex);

}

Here''s the implementation of the getters and setters:

public:
    void setCameraRig(Node3D* p_cameraRig) { this->cameraRig = p_cameraRig; } 
    Node3D* getCameraRig() { return cameraRig; }
    
    void setNumCol(int p_numCol) { this->numCol = p_numCol; }
    int getNumCol() { return numCol; }

    void setNumRow(int p_numRow) { this->numRow = p_numRow; }
    int getNumRow() { return numRow; }
Timehonored answered 15/10, 2023 at 0:25 Comment(0)
S
0

Timehonored When calling bind_method(), you're passing camera rig getter/setter for all properties, instead of their corresponding getters and setters.

Surface answered 15/10, 2023 at 0:40 Comment(0)
T
0

Surface Fixed that:

    ClassDB::bind_method(D_METHOD("setNumCol", "p_numCol"), &HexMap::setNumCol);
    ClassDB::bind_method(D_METHOD("getNumCol"), &HexMap::getNumCol);
    ADD_PROPERTY(PropertyInfo(Variant::INT, "numCol"), "setNumCol", "getNumCol");

    ClassDB::bind_method(D_METHOD("setNumRow", "p_numRow"), &HexMap::setNumRow);
    ClassDB::bind_method(D_METHOD("getNumRow"), &HexMap::getNumRow);
    ADD_PROPERTY(PropertyInfo(Variant::INT, "numRow"), "setNumRow", "getNumRow");

    ClassDB::bind_method(D_METHOD("setCameraRig", "p_cameraRig"), &HexMap::setCameraRig);
    ClassDB::bind_method(D_METHOD("getCameraRig"), &HexMap::getCameraRig);
    ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "cameraRig"), "setCameraRig", "getCameraRig");

But the NODE_PATH won't work.

Timehonored answered 15/10, 2023 at 1:4 Comment(0)
S
0

Timehonored If the property is of type NodePath then you probably shouldn't use naked Node3D pointer as the setter argument.

Surface answered 15/10, 2023 at 1:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.