Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Philip Whitfield | |
Old Version | Published before Godot 3 was released. |
I’ve create a custom webcam Resource that extends the Texture in a module. Most of the code is hacked together using bits from the theora video player and image texture. Everything works as expected but I can’t serialize any properties. They show up in the resource editor. But won’t get saved. Do I need to add something else?
// header
class AravisStream: public Texture{
OBJ_TYPE(AravisStream, Texture);
RES_BASE_EXTENSION("arv");
protected:
static void _bind_methods();
public:
float getFrameRate() const;
void setFrameRate(float value);
int getExposure() const;
void setExposure(int value);
...
}
//implementation
void AravisStream::_bind_methods(){
ObjectTypeDB::bind_method("start", &AravisStream::start);
ObjectTypeDB::bind_method("stop", &AravisStream::stop);
ObjectTypeDB::bind_method("update", &AravisStream::update);
ObjectTypeDB::bind_method("setExposure", &AravisStream::setExposure);
ObjectTypeDB::bind_method("getExposure", &AravisStream::getExposure);
ObjectTypeDB::bind_method("setFrameRate", &AravisStream::setFrameRate);
ObjectTypeDB::bind_method("getFrameRate", &AravisStream::getFrameRate);
ADD_PROPERTY(PropertyInfo(Variant::INT,"exposure",PROPERTY_HINT_RANGE,"0,33200,1",PROPERTY_USAGE_EDITOR), _SCS("setExposure"), _SCS("getExposure"));
ADD_PROPERTY(PropertyInfo(Variant::REAL,"frameRate",PROPERTY_HINT_RANGE,"0,40,.1",PROPERTY_USAGE_EDITOR), _SCS("setFrameRate"), _SCS("getFrameRate"));
}