banner



How To Get Data From Wordpress Website In Unity

Hullo Krghost,

I am non certain what y'all are trying to reach? When a Unity3D WebGL is running there are function calls which tin interact with the browser and the Spider web. Without knowing more than about the environment and conditions I can not offering any suggestions.

I am new to using webgl on wordpress so sad if the question seems naive.
I wanted to know how to use function like sendMessage() here in this plugin.
Is it callable? If yep, how?. Where do I write information technology?

I am making a level editor where user will create a level for the game and and then upload the level data to firebase database.
Initially, I was thinking of retrieving the level data from unity webgl to the browser and and so pushing it to the database as I demand the user detail present on the website to push it into the database simply I recall there is no way to do and then.

So I was thinking of sending the user details to unity webgl from the browser (through a function similar sendMessage()) and from unity I'll push the game data into the database

So is at that place any manner to do either of those mentioned above
I am using unity 2019.4

Give thanks you for your quick reply

@krghost, I have done very little with Unity3D. I would be happy to work with your equally someone to discuss ideas. I have washed a couple of the demo'due south. I have created one unique game which is simply a simple maze game.
Is your level Editor a split Unity3D application from the game?
Where are the levels from your game stored?
If you tin can help me empathise how levels piece of work I tin can help you figure out how to use them with the plugin.

Peter

Great

And then my level editor is a stand-lonely (i.east a carve up WebGL build apart from the game).
The level will be like a chessboard where the level creator will put predefined NPCs on the squares. There will exist a limited number of NPCs with id 1 to n. 1 of these NPC will be placed on each foursquare on the board.
That is the whole level.

To add together it into the database when the creator submits, I simply create a (two x 2)JSON of the current board with the NPC id equally a value and so push the JSON into the Level creator's account.

Now here, the Level JSON info is in the unity WebGL and the user info is on the web browser.
I somehow take to bring them together and push button them into the database.

Your aid would exist greatly appreciated
Thanks for your prompt answer

@krghost , Did a quick look at Unity3d. The thought that comes to heed if the levels can be stored every bit a JSON file yous. Y'all could employ the UnityWebRequest to read/write the JSON file from the server and load the information into the game.

I can encounter that there would be security issues with the write operations. It should be possible to write to the media folder.

There are also Residuum API functions. For testing the Balance API there is the a tool called POSTMAN. This is a great tool for testing how a Residual API works, what you need to send and what gets sent back.

If yous have a Unity3d test of concept, and a JSON file which describes a level I would exist happy to look at the pattern.

Let me know what you need.
Peter

@pthowe , so is there no mode to get the browser and Unity3d to communicate straight? Rather than going through an API?
I mean like "sendMessage()" role in JS

  • This answer was modified one year, 2 months agone by krghost.

@krghost , Let me run into what I can put together as a examination case.

Hey @pthowe any update?
any feedback (whether possible or non) will be highly appreciated.

Thanks

@krghost ,
My research keeps leading me back to something like:
https://weeklyhow.com/unity-restful-api/
https://hub.packtpub.com/using-rest-api-unity-part-one-what-rest-and-basic-queries/

I do believe that some browser data can be extracted. What type of information are you trying to extract from the browser?

I believe y'all can laissez passer parameters into a Unity3D game.

Let me know what you are trying to accomplish

Pthowe

@pthowe the information I want to pass is simply a cord that is the user Id of the user logged into the website.

@krghost , For the commencement part of the project. I am certain yous are already aware,

wp_get_current_user()->ID

Volition go you the current logged in user. The side by side office is to utilise the parameters which are passed to the Unity3d object as a parameter.

with the plugin I created you have:
[hs_unity3d_web_gl_game src="Scroll-a-brawl" height="500″ width="600″ u3dver="2019.four″]

Nothing prevents you from adding an additional parameter such equally:

[hs_unity3d_web_gl_game src="Roll-a-brawl" peak="500″ width="600″ u3dver="2019.4″ User=wp_get_current_user()->ID]

The fob I have non worked out is how practise you bargain with special symbols and spaces considering this is part of a URL.

I volition accept to get await for the lawmaking, to extract the parameter into a variable in the UNITY code.

Look for update

@pthowe ok so you mean that sending it through shortcode might work?
I'll definitely give information technology a try.
Please update if you discover out something and I'll practise the same also.

Thanks

Hello @krghost ,

I know this is non quite what you are trying to accomplish but it is communication between browser and the Unit3D game using my plugin.

Reference URL From Code Monkey:https://unitycodemonkey.com/video.php?five=3g0N__K7Wlo

For this I created a Unity3D game. The game is very simple and based on the Code Monkey example above. I created a game object of a circle, ii UI Text Elements, and a game object linked to a C# script.

The code in the Script: is the same as in the Code Monkey

The Code Monkey, has buttons which are in the HTML folio that send data into Unity3D game.

Now there is a name change in the game object used by the plugin. The HTML to add the buttons looks like:

          <div style="border: solid 1px blackness; width: 200px; acme: 30px; margin: auto; text-align: center;"  onclick="gameInstance.SendMessage('JavaScriptHook','TintRed')">Reddish</div>        

The Code Monkey used "unityInstance" the plugin you demand to use "gameInstance".

To put the HTML buttons on the game page I added the code below the tag which loads the game.

          <script>  	var testObject = { proper name: "John", age: 34}; 	var jsonString = JSON.stringify(testObject); </script> [hs_unity3d_web_gl_game src="LevelBuild" height="300" width="500" u3dver="2019.4"]  <div style="border: solid 1px black; width: 200px; height: 30px; margin: auto; text-align: center;" onclick="gameInstance.SendMessage('JavaScriptHook','TintRed')">Reddish</div>        

Allow me know if you have questions.

Cheers
Peter

@krghost ,

I think I have worked it out. If you expect at the online documentation
https://docs.unity3d.com/Transmission/webgl-interactingwithbrowserscripting.html

ane. In the Assets create a folder Plugins
two. Create a file in the folder which has the extension ".jslib"
3. This file volition wait similar:

          mergeInto(LibraryManager.library, {   ReturnUserID: function() { 	return current_userID;   }, });        

four. Create a C# Script "AccessJavaScript"

          using Arrangement.Collections; using System.Collections.Generic; using UnityEngine; using Organisation.Runtime.InteropServices;  public form AccessJavaScript : MonoBehaviour {     [DllImport("__Internal")]     private static extern int ReturnUserID();      void Start()      {       int result = ReturnUserID();       Debug.Log(result);     } }                  

Considering this is accessing the browser JavaScript, you can no longer apply the Unity3d Editor Play.
In my test I created in the HTML page:

                      <script>current_userID=1;current_userName=xxxx;</script>                  

From a short code which extracted current user info and placed in the page.

Hope this is helpful.
Please mail them.

How To Get Data From Wordpress Website In Unity,

Source: https://wordpress.org/support/topic/retrieve-data-3/

Posted by: martincalloseven.blogspot.com

0 Response to "How To Get Data From Wordpress Website In Unity"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel