Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unity.VisualScripting shows restricted interface in SampleWebView compared to standard script #1129

Open
chelbergeac opened this issue Jan 10, 2025 · 3 comments

Comments

@chelbergeac
Copy link

I am trying to use Unity.call() in my web page to set a Visual Scripting object variable so I can do something with it on the Unity side. The way I think this should work is something like this:

  1. add using Unity.VisualScripting at the top of the script
  2. in my webViewObject.Init(), for the "cb" callback, add code to get the "Visual Scripts" object and use that with the Variables object to set the value:
GameObject vs = GameObject.Find("Visual Scripts");
Variables.Object(vs).Set("ModelName", msg);

I can use this approach if I do it in a standard C# script on, say, a button, and it works fine. But when I try to modify SampleWebView.cs this way, Visual Studio shows me a very different, much more restricted set of members on Unity.VisualScripting, and doesn't recognize the Variables object. I also tried using Unity.VisualScripting.Variables(... but that doesn't work either.

So, what is different about SampleWebView.cs that gives me a different flavor of Unity.VisualScripting? It's almost as if the script is redefining the Unity.VisualScripting namespace locally or something. Is there a way I can use the full Unity.VisualScripting namespace in the context of this script?

@chelbergeac
Copy link
Author

Additional clue: the interface for Unity.VisualScripting that I see in Visual Studio when editing SampleWebView.cs is this:

image

Of course I'm expecting to see the interface detailed here: https://docs.unity3d.com/Packages/com.unity.visualscripting@1.9/api/Unity.VisualScripting.html

and I do indeed see that if I use this in a newly generated C# script:

image

@KojiNakamaru
Copy link
Member

I uploaded a modified sample app to https://github.com/gree/unity-webview/commits/example-for-1129/ , which can be opened with 2021.3.42f1. Although I'm utilizing Visual Studio on macOS, IntelliSense seems to work correctly.

image

SampleWebView.cs should do nothing about this issue. If IntelliSense works for a newly created cs file, please try to replace the content of the newly created cs file with that of SampleWebView.cs. IntelliSense should continue to work correctly.

@chelbergeac
Copy link
Author

chelbergeac commented Jan 13, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants