As anticipated, I’m having issues now with getting AngelScript to recognize my new component. Here’s what I’ve done:
- I’ve created a new component MeshSmooth that inherits from Component:
#pragma once
#include "Precompiled.h"
#include "Scene\Component.h"
namespace Urho3D
{
class URHO3D_API MeshSmooth : public Component
{
OBJECT(MeshSmooth);
public:
/// Construct.
MeshSmooth(Context* context);
/// Destruct. Free the rigid body and geometries.
virtual ~MeshSmooth();
/// Register object factory.
static void RegisterObject(Context* context);
//main function
void SmoothMesh();
};
}
I’ve created a GeometryAPI class (similar to the other API’s that implements the various registering functions):
#include "Precompiled.h"
#include "../Script/APITemplates.h"
#include "../Geometry/MeshSmooth.h"
namespace Urho3D
{
static void RegisterMeshSmooth(asIScriptEngine* engine)
{
RegisterComponent<MeshSmooth>(engine, "MeshSmooth");
engine->RegisterObjectMethod("MeshSmooth", "void SmoothMesh()", asMETHOD(MeshSmooth, SmoothMesh), asCALL_THISCALL);
}
void RegisterGeometryAPI(asIScriptEngine* engine)
{
RegisterMeshSmooth(engine);
}
}
And I’ve hooked up the RegisterGeometryAPI with the rest of them in ScriptAPI.h. The whole things compiles fine and I’ve made sure that the new source files are included where the UrhoPlayer can see them (i.e. when editing the Urho lib directly, I’m editing the files in /Source/Urho, but the player depends on /my_build_tree/include/Urho3D).
In a simple script, I call
//test new script component
Node@ testNode = editorScene.CreateChild("Test");
MeshSmooth@ test = testNode.CreateComponent("MeshSmooth");
This throws the error: “MeshSmooth is not a Data Type”. So clearly, the player is not registering my new component - but I’m at a loss as to why. Any thoughts?
EDIT I modifed Script.cpp so that the lib actually calls RegisterGeometryAPI. Now, I don’t get the error above, but I still can’t add the component to a game object (or call any of the component’s methods).