michal Posted August 25, 2020 Share Posted August 25, 2020 I have a problem with changing a property parameter that is of string type ____________________________________________________________________________________ #include <UnigineGame.h> #include "UnigineComponentSystem.h" class MaterialPaintingController final : public Unigine::ComponentBase { public: COMPONENT(MaterialPaintingController, Unigine::ComponentBase); COMPONENT_INIT(init); PROP_NAME("MaterialPaintingController"); PROP_PARAM(String, painting_variant, "DEF"); PROP_ARRAY(Node, surfaces); private: void init(); void parameterChanged(Unigine::PropertyPtr property, int propID); ____________________________________________________________________________________ then I use setParameterData in the call Unigine::String str("NewMat"); componentPtr->setParameterData("painting_variant", &str); I did not get a callback for a change and I can't find out what's going on. Is the use of setParameterData correct ? thanks for any help. Michal Link to comment
devrom Posted August 25, 2020 Share Posted August 25, 2020 Hello michal, how are you creating "componentPtr"?SetParameterData is a member of the class IG::Component. MaterialPaintingController inherits from Unigine::ComponentBase. Therefore it should not have setParameterData as member. So apparently you are instantiating the wrong class.This should help you accessing parameters after instantiating the correct class. Best regards Link to comment
michal Posted August 25, 2020 Author Share Posted August 25, 2020 I have this custom component "MaterialPaintingController" , which I added to my EntityObject.node in the Editor . When I want change parameter value , I use this : void set_property_value(EntityID id, Component comp, PropertyName name, Unigine::String const& data) { if (auto igEntity = ig_manager::get().getEntity(id)) { if (auto componentPtr = igEntity->getComponent(static_cast<int>(comp))) { componentPtr->setParameterData(PropertyNamesDefines[static_cast<int>(name)], &data); } } } for Float and Int version it is working , now I am trying to use String as parameter Link to comment
devrom Posted August 25, 2020 Share Posted August 25, 2020 Can you try to use "data.get()" instead of "&data"? Link to comment
michal Posted August 25, 2020 Author Share Posted August 25, 2020 18 minutes ago, ipg_rom said: Can you try to use "data.get()" instead of "&data"? yeah , this not helps. As I sad ,I am not sure if setParameterData function is appropriate for setting String parameter. PROP_PARAM(String, painting_variant, "DEF"), but there are only setParameterData, setParameterFloat, setParameterInt . Link to comment
moroz Posted August 26, 2020 Share Posted August 26, 2020 Hi! You can try this: if (auto cs_component = ComponentSystem::get()->getComponent<MaterialPaintingController>(igEntity->getNode())) { cs_component->painting_variant = data; } Link to comment
michal Posted August 26, 2020 Author Share Posted August 26, 2020 5 hours ago, moroz said: Hi! You can try this: if (auto cs_component = ComponentSystem::get()->getComponent<MaterialPaintingController>(igEntity->getNode())) { cs_component->painting_variant = data; } thanks , this working for me . Actually if (auto cs_component = Unigine::ComponentSystem::get()->getComponent<MaterialPaintingController>(igEntity->getNodeReference()->getReference())) { cs_component->painting_variant = materialName.c_str(); } but I am still curious about usage of "setParameterData" in IGPlugin , respectively how to set parameter different of "Int" and "Float". Anyway thank you for the help. Michal Link to comment
silent Posted August 27, 2020 Share Posted August 27, 2020 michal Unfortunately, it's not possible. IGPlugin was designed with CIGI API limitations in mind (and there is no other data other than int and float). 1 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
michal Posted August 27, 2020 Author Share Posted August 27, 2020 6 hours ago, silent said: michal Unfortunately, it's not possible. IGPlugin was designed with CIGI API limitations in mind (and there is no other data other than int and float). I understand that , thanks you let me know Michal Link to comment
Recommended Posts