Get reference to my plugin?

So I made a plugin and I need to store some variables in it, how do I reference my plugin in code. Where do I get a reference to it?

I want to be able to reference both within the plugin and outside of the plug (users who have the plugin in their project be able to get a reference to it aswell)

You’ll need to add your plugin module name to the PrivateDependencyModuleNames on your project’s .Build.cs file. Then you’ll be able to #import your plugin’s headers as you do with engine ones. So, if your plugin’s module name is “FooPlugin”, the .Build.cs file should contain

PublicDependencyModuleNames.AddRange(new string[] { /* default engine stuff */ });

PrivateDependencyModuleNames.AddRange(new string[] { "FooPlugin" });

So your saying I cannot make a plugin that stores variables locally and c++ files in the plugin cant access them stored variables?? That does not sounds right at all.

I don’t want to release a plugin that requires users to have to manuall add “pluginname” to there build.cs

I want code in my plugin to be able to store and load variables from the plugin module. Surely there is a proper way to do that?

All i want to do is store lets say “int number” inside my main plugin file. Then i want to change that number using C++ also in my plugin, but not in the main plugin file. How can I do that.

I believe we’re not on the same page XD

What I told you is how to access your plugin header files, ie. it’s code and variables, from your project’s C++ code. For that, your project code need to be made aware of the plugin’s module existence.

From Blueprints, your plugin’s functions and variables are automatically accessible if your plugin is inside the plugins folder (and properly set with the UPROPERTY and UFUNCTION macros).

All i want to do is store lets say “int number” inside my main plugin file. Then i want to change that number using C++ also in my plugin, but not in the main plugin file.

Well, to access code from file A.h on another file B.h you need to import “A.h” inside B.h.

If that still doesn’t answer your question I’m not understanding what exactly you’re trying to accomplish.

To add files to your plugin code, besides the main file, create those files inside the appropriate folders: Private for .cpp files and Public for .h files. These folders will be inside your plugin’s Source folder. Then, for VisualStudio (if Windows) to recognize those files as part of the project, right click your project’s .uproject file and select Generate Visual Studio Project Files.

I think he meant a reference to the current plugin object. Like getting a reference to actors of XXX class in the scene at runtime.

I am stuck at the exact same place.

What would the plugin object be? An Actor? A component? Neither?

They won’t simply appear on the scene. They have to be added as components on Blueprints or Spawned in the world.

If you can’t find them on the components or classes lists in Blueprints, maybe they’re missing BlueprintType on their UCLASS macro.

Some code of what you’re trying to accomplish or more detailed explanation of your objectives would help to clarify things. Like “I’ve done this expecting that and it’s not working”.

Here is the code for my plugin, i am trying to get my hands dirty with input devices and even though the Leap Motion plugin is available i am trying to code my own.

This is the “Input Device” H and CPP

#pragma once

#include “IInputInterface.h”
#include “IInputDevice.h”

#include
#include “LeapController.h”
#include “LeapInterface.h”

struct LeapKeys {
static const FKey RightHandPosition;
static const FKey LeftHandPosition;
};

class PIXELLEAP_API FLeapInputDevice : public IInputDevice
{

public:
FLeapInputDevice(const TSharedRef& InMessageHandler);
~FLeapInputDevice();

virtual void Tick(float Delta) override;
virtual void SendControllerEvents() override;

virtual void SetMessageHandler(const TSharedRef<FGenericApplicationMessageHandler>& InMessageHandler) override;
virtual bool Exec(UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar) override;

virtual void SetChannelValue(int32 ControllerId, FForceFeedbackChannelType ChannelType, float Value) override;
virtual void SetChannelValues(int32 ControllerId, const FForceFeedbackValues &values) override;

void OnLeap();

private:
TSharedRef MessageHandler;

Leap::Controller Controller;
Leap::Frame Frame;

};

.CPP

#include “PixelLeapPrivatePCH.h”

#include “LeapInputDevice.h”
#include

#include “LeapBlueprintFunctionLibrary.h”

#define LOCTEXT_NAMESPACE “PixelLeap”

const FKey LeapKeys::RightHandPosition(“Right Hand Position”);
const FKey LeapKeys::LeftHandPosition(“Left Hand Position”);

FLeapInputDevice::FLeapInputDevice(const TSharedRef& InMessageHandler) : MessageHandler(InMessageHandler)
{
EKeys::AddKey(FKeyDetails(LeapKeys::RightHandPosition, LOCTEXT(“RightHandPosition”, “RightHandPosition”), FKeyDetails::EKeyFlags::VectorAxis));

EKeys::AddKey(FKeyDetails(LeapKeys::LeftHandPosition, LOCTEXT("LeftHandPosition", "LeftHandPosition"), FKeyDetails::EKeyFlags::VectorAxis));

}

FLeapInputDevice::~FLeapInputDevice()
{
}

void FLeapInputDevice::SendControllerEvents()
{
}

void FLeapInputDevice::SetMessageHandler(const TSharedRef& InMessageHandler)
{
MessageHandler = InMessageHandler;
}

void FLeapInputDevice::Tick(float DeltaTime)
{
Frame = Controller.frame();

Leap::HandList HandList = Frame.hands();

for (int h = 0; h < HandList.count(); h++) {
	GEngine->AddOnScreenDebugMessage(h, 2, FColor::Yellow, FVector(HandList[h].palmPosition().x, HandList[h].palmPosition().y, HandList[h].palmPosition().z).ToString());
}

OnLeap();

}

void FLeapInputDevice::OnLeap()
{
ULeapBlueprintFunctionLibrary::OnLeap(Frame.hands().count());
}

bool FLeapInputDevice::Exec(UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar)
{
return true;
}

void FLeapInputDevice::SetChannelValue(int32 ControllerId, FForceFeedbackChannelType ChannlType, float Value)
{
}

void FLeapInputDevice::SetChannelValues(int32 ControllerId, const FForceFeedbackValues &values)
{
}

So essentially, i want to be able to get the Frame data which contains all the information for the hands, fingers to the Game.

The Controller.frame() retrives the data for the frame, and now i need to pass the vector position, vector rotation and other data to the game that I cannot pass through the Input Axis Keys which support only float and button Pressed, Released.

Let me know if you need more information

i can send the out through email as well, if you need. i have never gotten to grips with code formatting on any forum. let me know … thanks

That would be a lot to talk about and, honestly, somethings I don’t remember how I did. Instead, I’m sending you something similar I did to get Wii controller inputs in a game. Here’s the zip

Basically, I add a lot of inputs to the engine input list. Then, for having more control (as you mentioned, axis are a bit limited) I created a component that could be added to blueprints and would read the WiiMote on every Refresh() call. I made those calls on Tick. Now I think I should have overriden Tick directly inside the component. That component had functions to return sensor orientation, detected IR dots locations etc. Something like you need to do with the Frame Data. Create your own USTRUCT(BlueprintType) with the variables Blueprints need to read and make some function that return that data updated.

I didn’t send you the whole plugin folder because there’s a lot of useless stuff (Resource, .Build.cs etc). But the core of getting Blueprints to read the WiiMote inputs is all there. Hope it helps you!

“The component had functions to return sensor orientation”. some code would be helpful. did you query the interface for data ?

So i have a public float variable in my “Input device” class, which i update every Tick of the IInputDevice. How can that variable be accessed. Sorry for my completely noobish state of mind :expressionless:

Welcome to the biggest overkill of the programming history. I do not know why I was after the InputDevice non sense. I just had to make an actor / component and link the Leap libraries to the plugin, and use Leap API inside the components. hahaha… i feel so brilliant :smiley:

Hahahahaha

Sorry for the delay. Well, you don’t need it anymore, but if anyone else does, the code I talked about is all in that zip, on my previous answer.

Hey it turns out that IInputDevice is needed as it works on a seperated thread from the main thread, so its better i go down the Input Device path. So it would be better if i use it to make sense of a series of inputs and send a analog controller event to the game e.g gesture detection.