LxrdKxnny Posted February 13 Share Posted February 13 Hello there, I have followed the official documentation for creating components and getting them to display in the editor but I still can't see the component in the editor. I've created the component under 'Components/Character/CharacterMovement.hpp' and I have also added a 'CharacterMovement.json' file alongside it. I have also registered the component in 'ComponentSystem.h' but the component still won't show in the editor: #pragma once #include "UltraEngine.h" #include "Components/Character/CharacterMovement.hpp" using namespace UltraEngine; inline void RegisterComponents() { RegisterComponent<CharacterMovement>(); } Here is 'CharacterMovement.hpp' file: #pragma once #include "UltraEngine.h" using namespace UltraEngine; class CharacterMovement : public Component { public: CharacterMovement() { name = "CharacterMovement"; } void Update() override { // ... } bool Load(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const LoadFlags flags) override { if (properties["m_WalkSpeed"].is_number()) { m_WalkSpeed = properties["m_WalkSpeed"]; } if (properties["m_SprintSpeed"].is_number()) { m_SprintSpeed = properties["m_SprintSpeed"]; } return true; } bool Save(table& properties, shared_ptr<Stream> binstream, shared_ptr<Map> scene, const SaveFlags flags) override { properties["m_WalkSpeed"] = m_WalkSpeed; properties["m_SprintSpeed"] = m_SprintSpeed; return true; } std::shared_ptr<Component> Copy() override { return std::make_shared<CharacterMovement>(*this); } public: int m_WalkSpeed = 5.0f; int m_SprintSpeed = 10.0f; }; Here is the 'CharacterMovement.json' file: { "component": { "properties": [ { "name": "m_WalkSpeed", "label": "Walk Speed", "value": "5" }, { "name": "m_SprintSpeed", "label": "Sprint Speed", "value": "10" } ] } } I'm not sure what's happening here but if someone knows, I'd really appreciate the help! Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted February 13 Share Posted February 13 Your numeric values should be numbers instead of strings. Not sure if this is why it's not showing up though... maybe try creating one ".h" file and another ".cpp" file for the definitions. I think this changed a while back so it might need both files as well as the json file now. Take a look at the default components to see how they work. { "component": { "properties": [ { "name": "m_WalkSpeed", "label": "Walk Speed", "value": 5.0 }, { "name": "m_SprintSpeed", "label": "Sprint Speed", "value": 10.0 } ] } } Quote Link to comment Share on other sites More sharing options...
LxrdKxnny Posted February 13 Author Share Posted February 13 56 minutes ago, SpiderPig said: Your numeric values should be numbers instead of strings. Not sure if this is why it's not showing up though... maybe try creating one ".h" file and another ".cpp" file for the definitions. I think this changed a while back so it might need both files as well as the json file now. Take a look at the default components to see how they work. { "component": { "properties": [ { "name": "m_WalkSpeed", "label": "Walk Speed", "value": 5.0 }, { "name": "m_SprintSpeed", "label": "Sprint Speed", "value": 10.0 } ] } } I added the changes but it still doesn't seem to have fixed the issue. I'm unsure why this isn't working to be honest. I don't think there's anything else I've missed unless the folder structure I am using is incorrect: Quote Link to comment Share on other sites More sharing options...
Solution Dreikblack Posted February 13 Solution Share Posted February 13 Works for me with original .json from top post. Try to create new component via editor with + button btw maybe some letter is not latin? Like Cyrillic 'C' instead of English one in folder and file name. Quote Link to comment Share on other sites More sharing options...
LxrdKxnny Posted February 13 Author Share Posted February 13 17 minutes ago, Dreikblack said: Works for me with original .json from top post. Try to create new component via editor with + button btw maybe some letter is not latin? Like Cyrillic 'C' instead of English one in folder and file name. I'm not sure why but adding the file manually didn't work, but creating the component from the editor instead did work. Thank you so much! 1 Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted February 13 Share Posted February 13 6 hours ago, LxrdKxnny said: I'm not sure why but adding the file manually didn't work, but creating the component from the editor instead did work. Just curious, did you restart the editor after creating it manually? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.