Ethereum Unity3D Boilerplate Questions

@dgoodrich I’m enjoying SDK v1.0.2.

I would like exactly ONE “Hero” subscription to exist and to live as long as the Unity play session. By default, they last longer. Suggestions?

Perhaps I could call RemoveSubscriptions when unity OnDestroy fires, but that is probably too “late” if called as the session ends. I did not try yet.

For code-separation preference I created class MoralisLiveQueryCallbacksForHero : MoralisLiveQueryCallbacks<Hero> which I don’t believe causes any issues.

I tried to call RemoveSubscriptions before AddSubscription as shown…

MoralisLiveQueryCallbacksForHero callbacks = new MoralisLiveQueryCallbacksForHero();
MoralisQuery<Hero> moralisQuery = MoralisInterface.GetClient().Query<Hero>();
MoralisLiveQueryController.RemoveSubscriptions("Hero");
MoralisLiveQueryController.AddSubscription<Hero>("Hero", moralisQuery, callbacks);

But still get the result per image when the Unity play session starts (for the 5th time in this example)

1 Like

Is the “5” above is the Request Id from the MoralisLiveQueryClient instance? I would guess so since this is the Subscription created message. The RequestID is a static var in the MoralisLiveQueryClient that is only used as an application instance identifier to send to the back end.

Q. What build are you running? If WebGL let me know - nothing below may apply.

Q. Are you seeing multiple Subscription Created messages for a single subscription?

Q. Does

Mean that “Play” is froma cold game start or, the game is still running but reset?

The MoralisLiveQueryController is coded so that when the app closes, it automatically unsubscribes all subscriptions. Like wise, when the app (mainly for mobile) goes to sleep it unsubscribes and then re-subscribes on awake. This is to avoid web-socket errors on mobile caused by the app going to sleep.

Please let me know. I will get a chance to re-try this process this afternoon.

Thank you,

David

I use code from the SDK Examples of…

OnSubscribedEvent += ((requestId) => { Debug.Log($"{Title}: Subscription {requestId} created."); });

Now I see that I had misread the Debug log output. I see now that there is no issue. I withdraw my question. Thanks for the prompt help.

To answer your q’s…

  • I’m targeting standalone Windows
  • The output I’m seeing in a play session is completely captured in the screenshot of my related post
  • I’m using the Unity editor’s ‘Play’ to start a play session and the Unity editor’s ‘Stop’ button to end a play session
1 Like

Hey I apologize if this has been answered already, I have not explored it to much yet. But for some reason the Moralis wallet connector is not loading properly. I’m linking from an android build. Any idea why this would be? I got it to work the first time around but now it just goes to a blank page

1 Like

Do you mean a black screen after you authenticate? If this is the case, did you link all of your scenes in Build Settings?

Does the current WalletConnect API allow using local devnets such as Ganache?

1 Like

Not directly, Wallet Connect does not know anything about the RPC connection, it communicates with wallets registered to Wallet Connect.

It may be possible that if you setup GANACHE on your local network, connect your mobile device to use your local network and setup an RPC Node account (using keys from GANACHE) in you mobile wallet that points to your ganache instance, you may be able to do this.

I do not know that this would work, but in theory I do not see why it would not since only the wallet needs the RPC access, not wallet connect.

I do not know what weirdness could occur in you wallet if it could not reach the node at a future time so if you do this be sure to delete the test account from your wallet.

Regards,

David

1 Like

Hi David, thanks for getting back. I actually did not make a build, I just played it from the unity tester. I made a little video showcasing the problem. Again I think i got it to work before because I saw the wallet connect page pop up but since then it has not worked. Again its in Android. https://www.youtube.com/watch?v=O4Ymc1d89-E

its says I connected but then it just freezes until I mess with the VPN

1 Like

You are running from the 1.0.2 release correct? I think I see what is going on. It appears the Moralis Connect page is down. If you look at the console log it indicates it cannot load resources. I need to send a request to the dev team that handles that …

@jlourie, The issue has been identified and fixed in development. It needs to be checked and approved but should be deployed in a couple of hours.

1 Like

Afaik there’s a chain ID field that has to be set on the component. What will this ID read if I connect to a devnet?

1 Like

@jlourie This is fixed an appears to be working now. Please try again and let me know how things work out.

Is this for a Web3Api call? If so I do not think it will be able to access your local instance since the Web3Api runs on the remote server instance run by Moralis. I will ask if there is anyway to do this.

1 Like

I was correct. You can use test-net but not Ganache to test Web3Api calls.

Not sure if this will help but it is easy to use Remix to deploy contracts to Mumbai (or other test nets). Personally I use this method and no longer use Ganache.

No I figured this might be the case.
I’m currently exploring Hardhat. Will add Mumbai Testnet and deploy. Can’t use Remix since I’m using OpenZeppelin Upgradeable contracts.

1 Like

Getting these compile errors straight upon import of package. Any help?

1 Like

I have never seen that error with the package. In Unity IDE open File->Build Settings->Player Settings. Should default to the “Player” view. Scroll down to find “Configuration” and make sure “Api Compatibility Level” is set to .Net Standard 2.0.

If the above is true and you still have the issue please let me know which version of Unity you are using.

It’s set to .Net Standard 2.0 by default. Using version 2020.03.26f1, its the latest LTS version.

1 Like

hi @dgoodrich
Could you share when the version 1.0.3 be released, and does it support webGL build without QR code?

1 Like

1.0.3 will be released this weekend (possibly this evening - I need to change a lot of the readme). This release is several defect fixes and integration of Web3 (Nethereum for contract state change calls).

WebGL without QR code will not be in this release. That is the next big change.

1 Like