Object referencing?

This is a hard topic to search.

I’m writing a custom UClass that needs a reference to an object in the scene so it can call a function from the object.

The Unity way of doing this is like this:

public UnityEngine.GameObject gameobject;

gameobject.callMethod();

What’s Unreal’s equivalence? I’ve tried

UPROPERTY(EditAnywhere, Category = Ref)

class UObject *object;

And I don’t see it show up in the details panel.

I still don’t see it.

Am I looking in the right place? I can’t even get simple properties to show line int.

Originally I answered this to say you need to add BlueprintReadWrite, but I’ve just tested it and it works fine for me without it. It’ll only be editable on an instance of the class rather than the class itself, is that the problem?

No the instance is fine because I plan for there to be only one. I can’t see to find it in the details panel of the instance though. Is there some other kind of special refresh I need to do? I’ve been using just the compile button.

It appears right at the top of the properties panel for me. Have you tried typing ‘object’ or ‘ref’ into the search box? What class have you derived from?

I’m deriving from Pawn. I tried searching, didn’t find anything. I tried cleaning out the binaries folder because I though something in there was mucking up the project. I deleted everything there, rebuilt the visual studio stuff, and now my custom classes don’t show up in the editor anymore and my blueprints that derived from them are corrupted.

I’ve been getting error LNK2009 and error LNK2019 constantly whenever I do anything. Does that have anything to do with it? I’ve been ignoring those errors because the second time I compile after getting those errors, it compiles correctly.

Ah yeah, LNK2019 is an unresolved symbol, that’ll stop the build - so none of your changes since that error first appeared have made it to the editor. If you fix that error it should be fine - the text around it in the output from visual studio should tell you exactly what’s going wrong. Copy and paste it here if you still need a hand.