How to Send Data to Unity WebGL from Javascript or PHP

  Рет қаралды 59,346

Code Monkey

Code Monkey

Күн бұрын

Пікірлер: 126
@rafaelcorrea7959
@rafaelcorrea7959 5 жыл бұрын
As a web dev, I loved the video!
@MikeMinneman
@MikeMinneman 4 жыл бұрын
This is fantastic and should be part of the official unity documentation since it's a bit hard to follow.
@flynnwells2713
@flynnwells2713 3 жыл бұрын
I know Im kind of off topic but do anybody know a good website to stream newly released series online ?
@emiliozahir3427
@emiliozahir3427 3 жыл бұрын
@Flynn Wells Flixportal :D
@flynnwells2713
@flynnwells2713 3 жыл бұрын
@Emilio Zahir Thanks, I went there and it seems like they got a lot of movies there :D Appreciate it !!
@emiliozahir3427
@emiliozahir3427 3 жыл бұрын
@Flynn Wells Happy to help :D
@haachamachama7
@haachamachama7 3 жыл бұрын
Man, Unity always does this... They make these amazing, powerful features... That are at times both, difficult to use and clunky haha. Like the localization, it's amazingly powerful and useful, but there's so many weird aspects about it, and it's very difficult to understand at first... Sometimes... it feels like they rely on tutorial writers to help people out lol
@chrisstrauss7288
@chrisstrauss7288 3 жыл бұрын
I was looking for a solution to this problem ...and I came across this video. Many thanks ! God bless
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
I'm glad the video helped you! Thanks!
@ShawnRay
@ShawnRay Жыл бұрын
Can you make a tutorial on how to send javascript functions through an ? I'm using simmer to host my games and I would like to click a button and send this into the
@mohamedmostafa-ri8fn
@mohamedmostafa-ri8fn 7 ай бұрын
thank you very much, I always find the solution to my problem in your channel
@CodeMonkeyUnity
@CodeMonkeyUnity 7 ай бұрын
Nice! I'm glad my videos have helped you!
@F3ND1MUS
@F3ND1MUS 5 жыл бұрын
merry christmas, ty for this
@SowedCastelli
@SowedCastelli 5 жыл бұрын
You are the realest MVP 🙏. Thank you.
@vortexgames744
@vortexgames744 5 жыл бұрын
Can you do user generated content with uploading
@subramanyam2699
@subramanyam2699 3 жыл бұрын
Very useful tutorial indeed.
@nathanrona3560
@nathanrona3560 3 жыл бұрын
Thank you, I'll use this to get data from BLE (Bluetooth low energy) sensor to unity game using the Javascript WEB-BLE API.
@giuseppemastrolonardo6100
@giuseppemastrolonardo6100 2 жыл бұрын
Hello. Congratulations on your videos are great. I tried to redo this example in my game but I noticed that in the INDEX they changed the string of var = unityInstance ..... they deleted it. How can I do now? Thanks
@GameDevDave
@GameDevDave 4 ай бұрын
This dude types fast man, holy sh*t
@peny1981
@peny1981 5 жыл бұрын
WebVR, WebXR will be better supported ?
@nicolasportu
@nicolasportu 2 жыл бұрын
Hey! How to sync float range slider from js to to Unity? Thanks
@Javascript1
@Javascript1 5 жыл бұрын
Thanks for this video. I was expecting you to give some examples how to call js from our C# script... I'm using Application.ExternalCall now, but it is absolete in the most recent unity version.
@CodeMonkeyUnity
@CodeMonkeyUnity 5 жыл бұрын
According to the manual the recommended way is to add your js file in your plugins folder docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
@josimarakpomudia193
@josimarakpomudia193 Жыл бұрын
Is there a way i can communicate from flutter webview application?
@melisaozen4897
@melisaozen4897 3 жыл бұрын
Amazing tutorial, but unfortunately "unityInstance" creates an error in my project. Can't get the work done, thanks anyway!
@rikiahmad2
@rikiahmad2 3 жыл бұрын
How to send data on Scene Loaded trigger, not by button ?
@danielconde001
@danielconde001 3 жыл бұрын
saved my skin! thank you!
@davidoshin8708
@davidoshin8708 Жыл бұрын
thanks so much that worked
@jatingoel4820
@jatingoel4820 2 жыл бұрын
Hi, I want to pass userId in webgl build whenever user login in website so Unity WebGL get that userid string value in my unity code?
@jackgunderson870
@jackgunderson870 2 жыл бұрын
Awesome video --I'm able to make the changes to the colors no problem, but when I try to pass a number or a string with the function I get "Cannot read properties of null (reading 'Send Message'). Any suggestions? I've tried on my own project, and then used your exact project files.
@dariogarcia5163
@dariogarcia5163 3 жыл бұрын
how would it be the inverse, receive data from javascript to unity?
@se5d
@se5d Жыл бұрын
can you post that index.html final file? for some reason buttons is not working
@armandocomellas9639
@armandocomellas9639 2 жыл бұрын
Hello bro, thank for the tutorial, l have a question and how do you do viceversa? from Unity yo JavaScript?
@TheRobochicken5494
@TheRobochicken5494 3 жыл бұрын
omg thank you so much for this
@DaElfer
@DaElfer 3 жыл бұрын
the PHP one is messing me up. Im trying to pull information from a mysql database with PHP and need to POST to the PHP. Normally this is no problem in anything except WebGL. None of the sites i have been to seem to have a good concise answer
@julianbergeret9823
@julianbergeret9823 Жыл бұрын
where do you open the java script?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
What do you mean by "open"? Javascript runs in the browser
@apubetico
@apubetico 5 жыл бұрын
finally heree!
@rathodketan5551
@rathodketan5551 2 жыл бұрын
how to save file into player local machine ? in webgl
@돌림정
@돌림정 4 жыл бұрын
is it possible with c# winform program without java/php?
@RobertGercia
@RobertGercia 2 жыл бұрын
Hi, I am new to game development. Just wondering, between Unity and Unreal, which is possible to do such task as this: User input email address, on submit button, the game capture screen shot and send the image to the email. If there such beginner friendly tutorial on this, please take us there. By the way, great content as always. Everyday I learnt something new.
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
I covered how to do an HTTP call here kzbin.info/www/bejne/fZyTXpSjm9Noeq8 And a screenshot here kzbin.info/www/bejne/mmbRdoGlhrNnitk Combine both of those and you can take a screenshot and send that data through HTTP to whatever server you have
@RobertGercia
@RobertGercia 2 жыл бұрын
@@CodeMonkeyUnity thanks for the reply. really a great help!!
@granadaburak3508
@granadaburak3508 4 жыл бұрын
I used Application external call call js html from unity how can i do now ?
@unityDev2024
@unityDev2024 2 ай бұрын
I have a question, Can I display adsense ads in unity webgl games? if I want to show rewarded ad
@CodeMonkeyUnity
@CodeMonkeyUnity 2 ай бұрын
Yes you can use Unity Ads or Admob, same as for mobile
@unityDev2024
@unityDev2024 2 ай бұрын
@@CodeMonkeyUnity search this "admob in webgl" and click on first link which is , from google help Can I use Admob for monetization in WebGL based Game? the answer is no in this blog , so if you know the correct answer please reply
@yogesh00parihar
@yogesh00parihar Жыл бұрын
Can we do this - pass a string from unity to javascript
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
You can define and call the functions directly docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html Or you can do an HTTP request unitycodemonkey.com/video.php?v=Gk0-amfn5DM
@merabet.faycal
@merabet.faycal Жыл бұрын
Can you please explain if any have an idea about this error am getting in the log console SendMessage: object JavascriptHook does not have receiver for function "function Name" even tho the function names are identical in both c# and js scripts AND am passing string value
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Sounds like you're passing in the string "function Name", perhaps you're passing in a javascript object and not a string
@merabet.faycal
@merabet.faycal Жыл бұрын
@@CodeMonkeyUnity you are correct, that was happening to me thank you for your reply ! i have got it figured out, now am struggling on how to call a function that is out in my script by pressing a button UI so that function can get data from a server and them SendMessage back to unity player with the fetched data. The part am stuck with is calling a javascript function. can you please explain or set an example if possible ?
@thaboseane502
@thaboseane502 4 жыл бұрын
Is it possible to call a webpage into webgl
@StefanLopuszanski
@StefanLopuszanski 3 жыл бұрын
What about sending data to Unity WebGL from a Unity desktop build running on the same computer?
@jondyason336
@jondyason336 2 жыл бұрын
Thank you!!
@mayankkashyap4059
@mayankkashyap4059 4 жыл бұрын
Inside the SendMessage, when we type in the function name, how do I write a function name which accepts 2 parameters, like - Func(string s1, string s2) ??
@omaramen5855
@omaramen5855 3 жыл бұрын
you can pass Json object that contain any amount of data
@FPChris
@FPChris 3 жыл бұрын
Can you remove the Unity logo stuff below the game window and position and resize the game window in the page?
@atharvasawarkar9086
@atharvasawarkar9086 3 жыл бұрын
yes change the index.html accordingly
@lamloy9507
@lamloy9507 5 жыл бұрын
Can you make 2D foot ık? Like the 3D.
@CodeMonkeyUnity
@CodeMonkeyUnity 5 жыл бұрын
I'm not familiar with any specific tool but yes I'm sure there are IK solutions in 2D
@sarathnookala9018
@sarathnookala9018 2 жыл бұрын
Hello, Can you explain about payment gateway integration for webgl platform. That could be helpful
@RiderForge
@RiderForge 4 жыл бұрын
Can I send data back to the website from Unity? I want two-way communication so I can ultimately access a MySQL database and save data. I know how to do the database stuff in PHP but we need two-way communication. Can we send json back?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Sure, you just do a Web Request on the website as if accessing a normal link kzbin.info/www/bejne/fZyTXpSjm9Noeq8
@jabrailchumakov
@jabrailchumakov Жыл бұрын
Hi! Thanks for the tutorial. I have an error saying that "caught ReferenceError: unityInstance is not defined". How can I fix it? After I build my project I also don't have unityInstance var as you. It only appears at the end like this " var script = document.createElement("script"); script.src = loaderUrl; script.onload = () => { createUnityInstance(canvas, config, (progress) => { progressBarFull.style.width = 100 * progress + "%"; }).then((unityInstance) => { loadingBar.style.display = "none"; fullscreenButton.onclick = () => { unityInstance.SetFullscreen(1); }; }).catch((message) => { alert(message); }); };" I will appreciate any assistance!
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
It's possible they changed the name in the generated javascript code in recent Unity versions, look in the source code to see what name they used
@pianosouls_yt
@pianosouls_yt Жыл бұрын
did you fixed it :v i need your help thanks
@jabrailchumakov
@jabrailchumakov Жыл бұрын
@@pianosouls_yt Hi! Yes, you just need to redefine the unity instance to your custom name and then refer to your custom instance.
@aqibahmed340
@aqibahmed340 Жыл бұрын
Reference code plz??@@jabrailchumakov
@kpm25
@kpm25 Жыл бұрын
@@jabrailchumakov Yep I had the same issue.. I defined like this if anyone comes across the same error: script.onload = () => { createUnityInstance(canvas, config, (progress) => { progressBarFull.style.width = 100 * progress + "%"; }).then((unityInstance) => { myGameInstance = unityInstance; loadingBar.style.display = "none"; fullscreenButton.onclick = () => { unityInstance.SetFullscreen(1); }; }).catch((message) => { alert(message); });
@LouieLu-pz9bj
@LouieLu-pz9bj Жыл бұрын
I'm currently trying to create a project using this method. However, I can't understand how you manage to run Unity and html on local host, especially on the same web page. So I don't really know how to test the codes like the video described. Can you provide a video or a link to this kind of tutorial?
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Not sure what you mean, you just open the .html file as usual, only thing that doesnt work like that is some server code like php, fir that you need a webserver
@LouieLu-pz9bj
@LouieLu-pz9bj Жыл бұрын
@@CodeMonkeyUnity Thanks for replying! I'm using XAMPP to run html on local host, so I was wondering if you are using the same or different way to test your html file. If so, do you put the Unity folder (index.html) under the same folder in XAMPP? I think it may be a small and simple step, but it's crucial for me that I need to know it so that I can test this code. Currently I couldn't any other video tutorial relating to SendMessage(), lol.
@shalsa07
@shalsa07 4 жыл бұрын
Wow. Great tutorial as always, serious fun. I learn a lot from your tutorials. How would u go about opening a website within a webgl build without opening it in a new tab
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
For that you need some complex way of rendering a webpage inside Unity, I think there are some assets on the Asset Store that do that
@shalsa07
@shalsa07 4 жыл бұрын
@@CodeMonkeyUnity wow. Thanks for the prompt response. I realized that how complicated it might get through my research. Can't seem to find any that support webgl. Could please share any recommendations? I keep finding for other platforms but webgl
@WoodCat-k3b
@WoodCat-k3b Жыл бұрын
"I used your method, but the button I wrote in the HTML cannot trigger my Unity function. I have tried many times but still cannot make it work. Can you please tell me what I did wrong?"
@DutchyChannel
@DutchyChannel 2 жыл бұрын
Am I right to understand that with php/mysqli I could only store and retrieve data on command? I have a webserver online somewhere which only allows me to use php/mysqli as far as I get it (not experienced with this stuff at all). I figured out how to store and retrieve data with php/mysqli through Unity already. However, I am trying to see if I can do some sort of multiplayer with this as well. For example a chat, or say a live 'voting' system for something (bit of latency not being a problem). I found NodeJS is often used for this but it seems my webserver doesn't allow for this and now I'm trying to find an alternative. Any tips or advice for me, please?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
For any serverside logic you can just do a regular HTTP request from Unity. unitycodemonkey.com/video.php?v=Gk0-amfn5DM So for a chat system your Unity build would do a HTTP request every X amount of seconds, then in your server the PHP would go to the database, grab the last chat messages and return that.
@giblotskii659
@giblotskii659 5 жыл бұрын
I opened the video and your ad appeared 3 times😂
@Neltor411
@Neltor411 4 жыл бұрын
Thanks for the Video! Very helpful. When trying to use the PHP code, I get an "Unexpected token '
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Is the file saved as .php? Do you have PHP installed in your webserver? Try both the short hand
@EGL-P
@EGL-P 3 ай бұрын
Please create a video for setting up and using Firebase services (Auth, Realtime Database, Firestore, etc) with Unity for WebGL. The Firebase SDK for Unity doesn't support WebGL however there are old videos (uNicoDev) that show how it can be achieved, that are now outdated and no longer work.
@GiantsOnTheHorizon
@GiantsOnTheHorizon 3 ай бұрын
The Coco3D channel has some videos on Firebase Authentication.
@I_SeriouSaM_I
@I_SeriouSaM_I 2 жыл бұрын
Hi, I m making a WebGL game and i want to host the game in a sever and would need to be able to webgl to connect to that server. How can i do that? TY
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Pretty sure you can do a regular HTTP request unitycodemonkey.com/video.php?v=Gk0-amfn5DM
@I_SeriouSaM_I
@I_SeriouSaM_I 2 жыл бұрын
@@CodeMonkeyUnity Thank you man 😍
@tsunderenekokun
@tsunderenekokun 5 жыл бұрын
Do you take requests?
@sutharsanny1805
@sutharsanny1805 4 жыл бұрын
Will this work even if we hosted the game container on remote CDN server?
@smileychess
@smileychess 3 жыл бұрын
Since the game container is running in the browser, it shouldn't matter where it's hosted.
@TaninoMiao
@TaninoMiao 4 жыл бұрын
Every time I re-build the project the index.html file is deleted and replaced with a new one. Is there a way to maintain the index file with all the modified content?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Don't think so, that's why normally I don't build directly into the server folder.
@mmartomacgaming1939
@mmartomacgaming1939 3 жыл бұрын
@@CodeMonkeyUnity So how do you do it??
@CodeMonkeyUnity
@CodeMonkeyUnity 3 жыл бұрын
@@mmartomacgaming1939 Build it onto a folder then copy just the assembly files. index.html just contains the interface, all the unity stuff is inside the folder.
@mmartomacgaming1939
@mmartomacgaming1939 3 жыл бұрын
@@CodeMonkeyUnity Idk what you mean. The only html file i have is the index one which i can't edit?
@emanueltejadacoste2250
@emanueltejadacoste2250 5 жыл бұрын
Please make a course about how to create a complete game in unity on udemy 😊 pleaseeeee i think your subs will love to buy it
@CodeMonkeyUnity
@CodeMonkeyUnity 5 жыл бұрын
I would like to one day do some complete premium courses but they take a long time to make right so not sure when
@ruanxun9454
@ruanxun9454 4 жыл бұрын
I think code monkey is a god of making short tutorials. There are different types of KZbinrs and I am sure you will find one who loves making long tutorials.
@emanueltejadacoste2250
@emanueltejadacoste2250 4 жыл бұрын
ruan xun yey 😢
@joshreaver604
@joshreaver604 2 жыл бұрын
Sorry to ruin the '69' comments by adding another but do you have an updated version of this that would work with the new way Unity creates WebGL builds as it now creates 4 files instead of 6 and instead of Build.json its a .wasm and using the script in this video says 'cannot find unity loader'. So I assume there must be a way its just not whats in this video.
@superciasadmin
@superciasadmin Жыл бұрын
Josh. Did you find a way to work with the Unity 2020 build or higher?
@loldude8238
@loldude8238 2 жыл бұрын
Is it possible to embed my unity game to my website?
@CodeMonkeyUnity
@CodeMonkeyUnity 2 жыл бұрын
Yes you can make a WebGL build
@rapcostard8155
@rapcostard8155 4 жыл бұрын
Hi ! i'm trying to put a video inside of a game on web gl on Itch.io... could you make a video about this ? thanks a lot!
@CodeMonkeyUnity
@CodeMonkeyUnity 4 жыл бұрын
Check out the VideoPlayer component
@tigransahakyan2840
@tigransahakyan2840 5 жыл бұрын
Still waiting for archer video :)
@tomekipro1687
@tomekipro1687 Жыл бұрын
i hope you show in another direction too.
@CodeMonkeyUnity
@CodeMonkeyUnity Жыл бұрын
Send from Unity to a webserver? That's just a HTTP request unitycodemonkey.com/video.php?v=Gk0-amfn5DM
@adwaithks
@adwaithks 4 жыл бұрын
Can values be returned from unity c sharp file, to html, for JavaScript to modify it??
@nathanrona3560
@nathanrona3560 3 жыл бұрын
See "Calling JavaScript functions from Unity scripts" in manual docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
@Michal005
@Michal005 5 жыл бұрын
First
@danieldeleon5459
@danieldeleon5459 4 жыл бұрын
No aprendió porque todavía dice: "Couch", lo correcto es "Entrenador".
@Sampza12
@Sampza12 5 жыл бұрын
Why couldn't you just make the buttons in Unity
@CodeMonkeyUnity
@CodeMonkeyUnity 5 жыл бұрын
Because the whole point is to pass data from Javascript into Unity. So for example you can make a SQL query, grab some data from your database and send it to Unity to visualize it.
@Sampza12
@Sampza12 5 жыл бұрын
Thanks I think i understand it now a little better
@GardenOverflow
@GardenOverflow 3 жыл бұрын
Really useful , Thank you so much. i don't any web programming skill, but recently, I participate an art project and it need to submit a website with my unity webgl embeded in, so I upload my game on itchl.io and embed it on website I built by WIX. I hope to ask, is there any possible to send message like your tutorial in these website which built by wix? any helps will so appreciate, Thank you
Download Data/Images from inside Unity (HTTP WebRequest)
16:05
Code Monkey
Рет қаралды 39 М.
TOP 10 NEW Systems and Tools DECEMBER 2024! | Unity Asset Store
7:22
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
Simple Drag Drop (Unity Tutorial for Beginners)
10:31
Code Monkey
Рет қаралды 335 М.
How To Build An Event System in Unity
8:01
Game Dev Guide
Рет қаралды 418 М.
Good Time to BUY Rocket Lab? Rocket Lab vs SpaceX
5:11
Stock Reports & Discussions
Рет қаралды 8
WebGL Export in Unity 2020
11:52
UGuruz
Рет қаралды 79 М.
GENIUS Solution for HUGE WORLDS!
5:50
Code Monkey
Рет қаралды 17 М.
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН