Jump to content

LxrdKxnny

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by LxrdKxnny

  1. 17 minutes ago, Dreikblack said:

    Works for me with original .json from top post. Try to create new component via editor with + button

    image.png.249111de9f39822c90b7d51a55c274c0.png
    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! :)

    • Like 1
  2. 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:
    image.png.c55d2f3b8292dfba02c75aa624509cad.png

  3. 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! :)

    image.png

    image.png

×
×
  • Create New...