Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Do I have to use pearl?

Discussion in 'Scripting' started by robertseadog, Nov 10, 2005.

  1. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    With the WWW class; can I get the results from a php script instead of pearl? And does any one have any good pearl knowledge to share Im wanting to tackle some easy WWW with Unity..
     
  2. David-Helgason

    David-Helgason

    Moderator

    Joined:
    Mar 29, 2005
    Posts:
    1,104
    It's the web, so the server can be anything you want. There a lot of good resources for Perl out there (and for PHP too).

    What are you trying to achieve?

    d.
     
  3. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    well basicly Im just curious how to send/receive data the easiest way possible!

    For example I would like to use php so I could write a script that checks for version numbering.. would I just go
    Code (csharp):
    1.  download=WWW("http://mysite.com/check.php?version=1.2");
    ? Im confused as you understand, Pearl and cgi are two languages I've never ever though much about and so Im a little lost trying to learn them, I might just be overtired but im still baffled on how cgi works (after reading two tuts!)..

    BTW: I know the PHP syntax and have made some simple file handling scripts but nothing special.. But if I have a choice I want to stick to PHP.
     
  4. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    CGI is a technology - Common Gateway Interface used by, among others, the Perl and PHP interpreter (Perl is interpreted right?). All the client (your UNITY app) needs to know is what the server has to say about its request.

    In short: You can use what ever language you desire to do your server side work - that is handle the url query from the client.
     
  5. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Like AngryAnt said you can use whatever you are comfortable with as all of the server-side languages send and recieve data pretty much the same way, but I would recommend PHP over pearl for what you are doing.

    If you let me know exactly what you want to do with PHP I can probably help you out as I program PHP as part of my day job.

    -Jeremy
     
  6. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    Thanks I still don't understand the consept of CGI yet but I'll get there, hehe.. I guess in my case PHP is the easy solution I was craving for (oops sorry it's "PERL" you are right!).

    Or wait a minute, I know PHP can handle databases but is there any bottlenecks/performance situations for where you should use PERL instead? Im pretty new to databases to as I've never really had to manage one.. Anyway thanks for all help, PHP here I come!

    BTW! while this thread is still active; Is there a way to open a url with safari inside a Unity-widget?
     
  7. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    It really depends on the way the database works, and either way it shouldn't make any difference with what you are doing. What will make the difference is how you write your code and how many times you read/write to the database. You want to talk to the database as little as possible and only get the data you need.

    Again, for what you are doing it shouldn't make any difference anyway. Those type of problems mainly show up on larger projects.

    How that helps,
    -Jeremy
    [edit- I prefer PHP's database handling to anything else I have used]
     
  8. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Very few things you'd be developing indie will require optimal performance sing hardware speeds are so high compared to your tasks. Choose the CGI technology you find is the faster to develop in. If you were going all the way for optimisation, you wouldn't go anywhere near something like unity - you'd code it all in C *hides*.
     
  9. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    hehe, you got me there.. Don't think I'll make my own engine anytime soon no.
     
  10. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    Still one prob though! I can't seem to open a url with safari inside a Unity-widget.. Do I have to compile a plugin to do this or can Unity communicate with JS in the html?
     
  11. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    I have a Carbon bundle with this in the main.c:

    Code (csharp):
    1.  
    2. int main () {
    3.  
    4. system("open http://otee.dk");
    5. }
    6.  
    but for some reason unity wont open!

    This is the C# file:
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Runtime.InteropServices;
    4.  
    5. public class loadPlugin : MonoBehaviour {
    6.  
    7. [DllImport ("openURL")]
    8. static extern int main ();
    9.  
    10. }
    and no I don't know C#.
     
  12. klindeman

    klindeman

    Joined:
    Jun 13, 2005
    Posts:
    295
    Try these:

    In the Carbon bundle source file, put this:

    Code (csharp):
    1. void OpenURL()
    2. {
    3.     system("open http://otee.dk");
    4. }
    Then in the C# script in Unity, put

    Code (csharp):
    1.  using UnityEngine;
    2. using System.Collections;
    3. using System.Runtime.InteropServices;
    4.  
    5. public class loadPlugin : MonoBehaviour
    6. {
    7.     [DllImport ("openURL")]
    8.     static extern void OpenURL();
    9.  
    10.     void Start ()
    11.     {
    12.         OpenURL();
    13.     }
    14. }
    That will open the plugin containing the OpenURL() (as long as the plugin is called openURL.bundle and is in the plugins folder), and then run the OpenURL function in the plguin when the script awakes (starts).
     
  13. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
  14. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    Ah.. Void; of course.. I'll try it though, I do hope it's doable(atleast opening a private html file would be needed.)!