getnamo / UnrealJs

Unreal.js plugin embedding v8.
Other
52 stars 6 forks source link

Globls.js no longer generated #12

Closed closedsum closed 5 months ago

closedsum commented 5 months ago

Hey, I got the latest Release for UnrealJS (https://github.com/getnamo/UnrealJs/releases/tag/v0.9.1) and it seems that the Globals.js file is no longer generated (Content/Scripts/typings/Globals.js)? Not sure if this is the root of issue, but it seems now none of my previous .js files run correctly.

New issues

Any thoughts?

Edit: Sorry I should add better repro steps

  1. Get Latest Release: https://github.com/getnamo/UnrealJs/releases/tag/v0.9.1
  2. Add to my own projects Plugins Folder: i.e. MyProject/Plugins/UnrealJS
  3. Generate Visual Studio Project Files (I have a c++ project)
  4. Compile
  5. Try running a simple.js file
    • using require
    • trying to cast to Actor (i.e. var test = Actor.C(other);)
getnamo commented 5 months ago

Are you using a JavaScript instance component or the standard one? The instance variant does expose by default unless it's specified. Standard component should still work as in the past.

closedsum commented 5 months ago

Actually, Before I manually created the Isolate and Context and it seemed like I had no problems. This was in 5.1 (and I had been using this technique with no problem even in the 4.20ish days I think)

My previous method (worked in 5.1)

void FLibrary::SetupIsolateAndContext(UObject Owner, UObject& JavascriptIsolate, UObject*& JavascriptContext, const bool& IsEditor) { auto Isolate = NewObject(); TMap<FString, FString> Features; Isolate->Init(IsEditor, Features); auto ContextObject = Isolate->CreateContext();

JavascriptIsolate = Isolate; JavascriptContext = ContextObject;

ContextObject->Expose("Root", Owner); }

I'm guessing this is no longer the right way for 5.3+?

Okay, So, I just tried making dummy Blueprint Actor with a both a JavaScript Component and Instance.

Example .js

function main() { console.log("main(): test");

var Test = null;
var Actor = Actor.C(Test);

}

main();

Update 1:

Update 2:

Would you say it would be better to use the Javascript Component or Instance? In terms of what is being maintained more going forward.

getnamo commented 5 months ago

This fork, which is opinionated, focuses on instances to allow for precise exposure control (+ some perf things like JavaScript multithreading). You may want to use the upstream plugin if you want standard API, I try to make best effort updates to keep upstream API, but as you can see some things may break over time.

closedsum commented 5 months ago

Makes sense! Thanks for the reply and contribution / maintenance to the plugin! I love using it :)