0 votes

I am new to Godot engine, and I'm trying to create a C++ module. Is it possible to have a MeshInstance variable in a class that is exposed to the editor as well (like a property)?

asked Mar 14 in Engine by kovacsur10 (12 points)

1 Answer

0 votes

https://github.com/godotengine/godot/blob/4cb64feae8f118529a5e1108c13d8fe05771857f/scene/audio/audio_player.cpp#L331

https://godot.readthedocs.io/en/3.0/classes/class_animationplayer.html

you add it to bind_methods

DD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE, "-80,24"), "set_volume_db", "get_volume_db");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "pitch_scale", PROPERTY_HINT_RANGE, "0.01,32,0.01"), "set_pitch_scale", "get_pitch_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "is_playing");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_target", PROPERTY_HINT_ENUM, "Stereo,Surround,Center"), "set_mix_target", "get_mix_target");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus");

here is an example for audiostreamplayer

answered Apr 4 by hungrymonkey (357 points)

Ref< MeshInstance > is not valid, since MeshInstance is not a child of Reference (it's a Node). On the other hand AudioStream has Reference as a parent class (Inherits: Resource < Reference < Object). That's why I could not achieve to use the same method you mentioned.

you dont need to wrap it in Ref thou.

You can pass object *

Is your module managing the object? If so, look on how RID works so you will not have object ownership problems.

http://docs.godotengine.org/en/latest/development/cpp/custom_godot_servers.html#custom-managed-resource-data

http://docs.godotengine.org/en/latest/classes/class_rid.html#class-rid

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.