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

Async callback from C# to javascript #96

Open
823639792 opened this issue Mar 28, 2017 · 1 comment
Open

Async callback from C# to javascript #96

823639792 opened this issue Mar 28, 2017 · 1 comment
Labels

Comments

@823639792
Copy link

823639792 commented Mar 28, 2017

Now,I am using Jurassic in unity3d。
And I encountered a problem:
C#

        private class Transform
        {
            public int public_value = 789;
            public int Add(int i) {
                return public_value + i;
            }
        }

        XXXX.CallMemberFunction("Update", new Transform());

javascript

Update: function(transform){
		console.log(transform.Add(123));//this line throw exception
	}

and throw error: Cannot convert object of type Transform to an object (from TypeConverter)

And I find engine.SetGlobalValue() use "ClrInstanceWrapper" to wrapper it, use So I edit my code:

var trans = new ClrInstanceWrapper(engine, new Transform());
XXXX.CallMemberFunction("Update", trans);

It's run OK.

So my question is:
1、Is there any problem with this?
2、Why SetGlobalValue use ClrInstanceWrapper but CallMemberFunction not use it?

@paulbartrum @Taritsyn @kpreisser

@paulbartrum
Copy link
Owner

There are known problems with ClrInstanceWrapper and I'm not sure if it'll survive going forward. For that reason, I recommend that people inherit from ObjectInstance instead (documented here: https://github.com/paulbartrum/jurassic/wiki/Exposing-a-.NET-class-to-JavaScript).

On the other hand, what you're doing should work fine right now (especially for simple cases) and my progress on this project has been pretty glacial lately, so it should work for a while yet.

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

No branches or pull requests

2 participants