Search Unity

Spent a while working on something, it works, but thanks to a "quirk" in Unity I get to start over.

Discussion in 'Scripting' started by Master-Frog, Jun 30, 2015.

  1. Master-Frog

    Master-Frog

    Joined:
    Jun 22, 2015
    Posts:
    2,302
    So I built a high score system that pulls the high scores of a database and all that, displays it, etc.
    Then I go to deploy to the web player and I'm met with "Not Supported!" I find out that Unity web player doesn't support the web client. I google further and find "you'll have to write your own using tcp-ip" or something like that. Today I was trying to take JSON and turn it into objects and arrays and only to find that the best way is through Newtonsoft's Json.NET, but not really per se because Json.NET has actually had several major releases beyond what I was able to get working within Mono... so it's really a matter of using deprecated code to transmogrify strings into objects through some kind of generic monstrosity that frankly scares the bejeesus out of me. It was cleaner to just rewrite the server and cut out the JSON altogether.

    I guess my biggest gripe is that... obviously I can write my own *blank* from scratch, or pay somebody to write it for me. Obviously I can download *blank* and use that library... but why should I even have to? I shouldn't have to fight uphill, scouring documentation just to do little things like get the text content from an http request, and then do it only to find out that it's kind of not supported, sort of. Maybe I'm just spoiled from writing code that works in systems that aren't riddled with deprecation and lack-of-support landmines. Honestly makes me averse to trying anything else. Who knows what will spring up and cut my knees out from under me, then I'll google it and find out that oh... there's a post from 2009 where somebody had this same issue. Unfortunately, you'd have to have this issue to know what to google... so it's a bit of a conundrum.

    Ultimately, I think things work best when they work as expected.

    But the biggest issue is just the time. Who has the time to just constantly discover bugs and quirks and find clever ways to work around them?

    So now I'll probably just create a web page for the high scores. You know... a little good old PHP in a web browser.

    Doing the "impossible"... with notepad.
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
  3. Master-Frog

    Master-Frog

    Joined:
    Jun 22, 2015
    Posts:
    2,302
    No.

    As proof, I got it to work with the WWW class in the web player. Post high score, server-side save to database, get sorted high scores in string format with delimiters, parse, populate text field.

    WebClient seems useless by comparison. It should have a warning label: "Do not use."
     
    Last edited: Jul 1, 2015
  4. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Well, you could use my port of JSON .NET which would solve those issues. There are also several free JSON libraries that may work with WebPlayer such as JsonFX, miniJSON or JsonObject.

    As for WWW, it is supported just fine in WebPlayer but is restricted to domain of origin (same domain) unless you properly setup your crossdomain.xml file to allow access from another origin. That xml file needs to be in the root of the domain you're trying to access via WWW.
     
    Master-Frog likes this.
  5. Korno

    Korno

    Joined:
    Oct 26, 2014
    Posts:
    518
    This.

    To the OP - instead of getting all OMGTHISISNTWORKOMGUNITYSUCKS ..... Why don't you RTFM first and then if you have issues, ask constructively for help? Moaning gets you nowhere.
     
  6. Master-Frog

    Master-Frog

    Joined:
    Jun 22, 2015
    Posts:
    2,302
    At least I'm working on something.
     
  7. Master-Frog

    Master-Frog

    Joined:
    Jun 22, 2015
    Posts:
    2,302
    Thanks for the replies.

    If my games require JSON in the future, I'll check out your suggestions. For now, I am content with just pushing strings back and forth with delimiters. We'll see.
     
    Dustin-Horne likes this.