Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by missypooh · Mar 27, 2012 at 02:09 AM · databasemysql

Finish setup php, how to communicate with mySQL and unity

I have already set up the php (using WAMPServer) and now my problem is how am i going to make my php communicate with unity? Would appreciate if there is people who can help out.

http://www.unifycommunity.com/wiki/index.php?title=Server_Side_Highscores

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by ByteSheep · Mar 27, 2012 at 03:04 AM

PHP doesn't communicate with unity, but unity can change the url of the page and PHP can then pick up variables stored in the url using the $_GET[] function.

The link you posted is well documented - Basically HSController.js is the script that sets and gets the highscores; display.php is the script that gets the data from the database; and addscore.php adds data (scores, playername, etc) to the database.

Everything that you need is explained and provided in the tutorial, but let me know if there is a specific problem you are encountering ;)

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image missypooh · Mar 27, 2012 at 03:12 AM 0
Share

Actually like i mention, i have already setup the php file. Now what i want to do is store my data from Unity to mySQL. I am not storing score, thatwise i find it rather hard to continue from there. I want to store the click that the player have click on. For example, player click on APE, i will need to store 'APE' into the column. Something like that.

avatar image ByteSheep · Mar 27, 2012 at 03:30 AM 0
Share

The file that you'd need to edit is the HSController.js script. The function that you need to edit is the postScore() function, which is currently taking two parameters: name and score. You will basically have to edit this to reflect your purpose.. You then will also have to change the mysql table structure etc (if you haven't already) and make some edits to the given php files. The process is the same but you just need to edit change the variables that are sent to and taken from the server. It's not easy to explain..

avatar image
2

Answer by rutter · Mar 27, 2012 at 03:09 AM

The examples you're linking to use Unity's WWW class to communicate with a high score server.

Unity can use WWW to send an HTTP GET request with a special URL containing some data.

The server can read parameters from the GET request, update internal state as needed, and reply with relevant information. In this case, it looks like you're using a webserver set up with PHP and MySQL.

Back in Unity, you can parse the returned information and display it for your end user.

Is there a specific part of this process that you're having trouble with?

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image missypooh · Mar 27, 2012 at 03:15 AM 0
Share

Yes. So basically what i want is, Unity capture all the data player have clicked(for instance, player click on 'APE'), then i want all the click to be store into the database. I not very sure do i need WWW class. Because from my research, it is shown that php-> Server-> Unity. Sorry if i am wrong. I am still quite confused.

avatar image rutter · Mar 27, 2012 at 03:27 AM 1
Share

You need a client (Unity) and a server (PHP). These are completely separate applications, but they need to be able to talk to each other.

You can collect as much data as you want, in Unity, but it won't do you much good if you don't eventually push it up to your server. Likewise, your server won't be much use unless it's able to send data back to your Unity clients.

You're welcome to implement client-server communication in any way you please. Unity's WWW class is a simple and relatively straightforward method of doing so, on the client-side.

Ultimately, you're dealing with a very large problem that some people study for years. If you want a silver bullet solution that you can build in a matter of $$anonymous$$utes, you're just not going to find one. That's why I'm asking if you're having trouble with a specific, actionable item.

avatar image ByteSheep · Mar 27, 2012 at 03:32 AM 0
Share

well said ;D

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Setup mySQL, insert value to mySQL, retrieve data from mySQL 0 Answers

c# database connection on debian server 0 Answers

mySQL : Values not inserting to my database 0 Answers

How to use php to update mySQL 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges