Jump to content

Property problem


photo

Recommended Posts

Im sttruggling with custom component syspem. 

When i create some component, i want to change its parameters attributes (such as min, max)

But when i change property file (or inherited from it) of my custom component property (through API or in notepad), this happens.

 

UPD it happens when i add in component. Why it happens?

this->getProperty()->addCallback(Unigine::Property::CALLBACK_PARAMETER_CHANGED, MakeCallback(this, &Wind_control::p_changed));

image.png

Edited by qwert_e
Link to comment
//Wind_control.cpp
#include "Wind_control.h"

REGISTER_COMPONENT(Wind_control);

void Wind_control::init() {	
	getProperty()->addCallback(Unigine::Property::CALLBACK_PARAMETER_CHANGED, MakeCallback(this, &Wind_control::p_changed));
}

void Wind_control::update() {}

void Wind_control::p_changed(Unigine::PropertyPtr property, int num) {}
// Wind_control.h
#pragma once
#include <UnigineGame.h>
  
#include "ComponentSystem/ComponentSystem.h"

class Wind_control : public ComponentBase
{
public:
	COMPONENT(Wind_control, ComponentBase);

	COMPONENT_INIT(init);
	COMPONENT_UPDATE(update);

	PROP_NAME("wind_control");
	PROP_PARAM(Double, wind_angle, 0);
	PROP_PARAM(Double, wind_force, 0);

	PROP_PARAM(Toggle, reload_property_file, 0, "Reload property");
protected:
	void init();
	void update();
private:
	void p_changed(Unigine::PropertyPtr property, int num);
};

Tested this with new project. 

If i locate this prop in Editor, add it to node and reimport it (or change in notepad), there will be crash. 

Edited by qwert_e
Link to comment

Hello qwert_e,

We cannot reproduce this behavior, so I have to ask you some additional questions to make things clear.

Could you walk me through the exact reproduction sequence? What exactly did you do?

I've tried the following:

  1. Created a new C++ project with the Component System checkbox enabled
  2. Added a new Wind_control class inherited from the ComponentBase
  3. Copied your source code from the previous post to the corresponding files
  4. Added the Component System initialization to the AppSystemLogic::init() :
    int AppSystemLogic::init() {
    	// Write here code to be called on engine initialization.
    	// initialize ComponentSystem and register all components
    	ComponentSystem::get()->initialize();
    	return 1;
    }
  5. Compiled and launched my application (the property file was generated)
  6. Opened the default world in the Editor and assigned the generated wind_control.prop property to the material_ball node.
  7. Opened the wind_control.prop property file in the text editor and added min and max attributes to the first and second parameters:
    <?xml version="1.0" encoding="utf-8"?>
    <property version="2.7.3.0" name="wind_control" manual="1" parent_name="node_base">
    	<parameter name="wind_angle" type="double" min="10" max="20">0</parameter>
    	<parameter name="wind_force" type="double" min="20" max="40">0</parameter>
    	<parameter name="reload_property_file" type="toggle" title="Reload property">0</parameter>
    </property>
  8. The was property successfully reimported (no crash)

If the same sequence leads to a crash in your case, I'd ask you to send a small reproduction sample project to figure out what's the problem. And provide some details on the SDK version used.

Thank you!

 

Link to comment

Yes, same sequence.
How can i send you my test project?

UPD: problem is only in debug version 
Here is its config

image.png.21b76bb560d1da04e07684b11243d08f.png

Edited by qwert_e
Link to comment

Hi qwert_e,

This behavior is due to a bug. It was added to our internal bugtracker, and will be fixed in future releases.

Sorry for the inconvenience caused.

Thank you!

Link to comment
×
×
  • Create New...