Jump to content

String property parameter not working as expected


photo

Recommended Posts

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

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
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
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

Hi!

You can try this:

if (auto cs_component = ComponentSystem::get()->getComponent<MaterialPaintingController>(igEntity->getNode()))
{
   cs_component->painting_variant = data;
} 

 

Link to comment
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
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
×
×
  • Create New...