Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Our response to Improbable’s blog post (and why you can keep working on your SpatialOS game). Read more here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

UnityDog - Wordpress Plugin

Discussion in 'Made With Unity' started by garrynewman, May 15, 2013.

  1. kevinseligmann

    kevinseligmann

    Joined:
    Mar 23, 2011
    Posts:
    68
    Hi everyone, as someone requested via pm I'm posting my modification that doesn't use wordpress and has the context menu disabled. Just open the html and change the Build.unity3d matching your own.

    HTML:
    https://dl.dropboxusercontent.com/u/5636920/unitydog_no_wordpress.rar
    Cheers!
     
    shaneK001 likes this.
  2. pthowe

    pthowe

    Joined:
    Dec 29, 2013
    Posts:
    3
    My UnityDog has stopped working. I have looked at the plugin. I have been successful in updating the parameters but not getting them used.

    unitydog.php
    $width = $atts['w'];
    $height = $atts['h'];

    $url = wp_get_attachment_url( $atts['src'] );
    if ( !$url ) return "(missing unity attachment)";

    return '<unitydog width='.$width.' height='.$height.' src="'.$url.'"></unitydog>';
    }

    page
    [unity src="158" w="600" h="600"]

    Hope this helps
     
  3. Tanel

    Tanel

    Joined:
    Aug 31, 2011
    Posts:
    508
    This pops up just when I needed something like it! Thanks!

    I've made a few additions to the shortcode though so there'd be more control without messing with the source files. It's a bit hacky but addresses some of the features people have been wanting.

    [unity src="4" h="500" w="500" fullscreen="no" preview="img.jpg" class="someClass someOtherClass"]

    h - overrides height (in pixels)
    w - overrides width (in pixels)
    fullscreen - 'no' removes fullscreen controls
    preview - source for preview background image (not the most comfortable way but it gets the job done)
    class - custom classes for extra styles

    Any of these can be left out, in which case defaults will be used.

    https://dl.dropboxusercontent.com/u/38588483/unitydog.zip

     
    Last edited: Apr 10, 2014
    Wolfdog likes this.
  4. KOKOStern

    KOKOStern

    Joined:
    Dec 22, 2013
    Posts:
    13
    This plugin works perfectly and Tanel you just saved me from going in and dealing with it myself. I have a game where fullscreen is ok and another where it isn't so this is just what I need, you rule! Thank you!

    Edit: testing it out a bit more, it kinda breaks the css of my website, and displays the game a bit over to the left instead of being in the center.

    I'm terrible with css and not managing to fix it, any way you could help?
     
    Last edited: Apr 14, 2014
  5. Tanel

    Tanel

    Joined:
    Aug 31, 2011
    Posts:
    508
    Some other stylesheet on your site might be overriding unitydog's styles. Inspect it with Chrome devtools or similar and see if anything floats it to the left and so on.
     
  6. KOKOStern

    KOKOStern

    Joined:
    Dec 22, 2013
    Posts:
    13
    It's right not left. Don't know why I wrote left, sorry.

    As I'm said I'm terrible with Unity, could you check it out:

    http://www.srslygames.com/spooter-2438/

    I published it password protected so it won't pop on the site not ready. Password is: unity
     
  7. Tanel

    Tanel

    Joined:
    Aug 31, 2011
    Posts:
    508
    You set the width of your player 960px but the containing element is 792, so it doesn't fit.

    In style.css you could remove the rule max-width: 45em; from the class 'site-main' but that would widen the content area throughout your site.

    If you leave width out of the shortcode, the player will take up 100% of the containing element, so that's another option.
     
  8. KOKOStern

    KOKOStern

    Joined:
    Dec 22, 2013
    Posts:
    13
    Hmm, so you're saying the max width of my website is 792.

    That's kinda odd as I've never had an issue embedding youtube videos and I always use 853x480.

    The standard unity webplayer size is 960x600, and that's what I used to build the game so that's what I want.

    Thanks for helping out. Other than changing what you said, you see any other option?
     
  9. Tanel

    Tanel

    Joined:
    Aug 31, 2011
    Posts:
    508
    The max width of the content area is 45em, which is a percentage based unit ( 792px for my screen, something a bit different for other sizes).

    As for the Youtube videos, there's a rule in your css that sets iframe width to 100%, so they're actually 792px too.

    Well, another way would be to make a new page template where the content area is wider, so the whole site wouldn't be affected.
     
  10. KOKOStern

    KOKOStern

    Joined:
    Dec 22, 2013
    Posts:
    13
    The theme I'm using is a responsive theme meant to fit any screen and work on tablets and phones.

    This game has to be played at 960x600 (I made it in 48 hours and using the terrible standard GUI).

    I guess it'll be best to try and ask the theme creator for help with a custom page as I have very little knowledge of the inner-working of wordpress and generaly css dealings.

    Thanks for trying to help!
     
  11. joduffy

    joduffy

    Joined:
    Jul 30, 2011
    Posts:
    34
    Hi,

    I am using UnityDog which is awesome, as it saved me a lot of hassle when supplying web demos for people.
    I am having one strange bug though.

    I am using player pref and for some reason the new builds I upload are showing different settings from the Unity3d editor version. I am thinking there is a file stored somewhere with older unity3d player prefs from a previous version. If this is the case, were could I find and delete it?
     
  12. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    2,713
    The web player PlayerPrefs are saved in the folder (windows)

    C:\Users\YOUR USERNAME\AppData\Roaming\Unity\WebPlayerPrefs / %appdata%\Unity\WebPlayerPrefs

    https://docs.unity3d.com/Documentation/ScriptReference/PlayerPrefs.html

     
    Last edited: Apr 30, 2014
  13. zak-reynolds

    zak-reynolds

    Joined:
    May 8, 2013
    Posts:
    5
    Love this plugin! The only thing I needed that it was missing was a way to keep the aspect ratio on resize, so here's a quick hack I did to get it to work (it wouldn't be too hard to configure it in for customizable ratios, but all my games are 16:9 so I just hardcoded it):

    1. Set both width and height to 95% in the CSS file.
    2. In unitydog.php, change
    return '<unitydog width="'.$width.'" height="'.$height.'" src="'.$url.'"></unitydog>';
    to
    return '<div style="width: 100%; height: 0; position: relative; padding-top: 56.25%">
    <div style="position: absolute; top: 0; left: 0; bottom: 0; right: 0;">
    <unitydog width="'.$width.'" height="'.$height.'" src="'.$url.'"></unitydog></div></div>';


    This will add a few container divs that'll resize to fit your site and keep the aspect ratio to what you want. If you want something other than 16:9, just change the 56.25% to another value:
    1:1 = 100%
    2:1 = 50%
    1:2 = 200%
    4:3 = 75%

    This site does a good job of explaining what's going on with the CSS: http://www.mademyday.de/css-height-equals-width-with-pure-css.html
     
  14. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    785
    I've been trying to get this plugin to work but nothing shows up. When I upload the ".unity3d" file it puts ".zip" on the end of it. The plugin mentions in the unitydog.php fie...
    PHP:
    // A lot of webservers can't serve unity3d files by default.
    // So rename it from .unity to .zip
    So I figure that it can still detect what the ".unity3d.zip" is meant to be. I even tried changing ".unity3d" to ".zip" before uploading and the result is still the same. When uploading the media onto a page it puts
    PHP:
    [unity src="434"]
    But previewing the page results in a regular page with no webplayer.

    Info: I use HostGator with the WordPress plugin.
     
    Last edited: May 4, 2014
  15. hing0830

    hing0830

    Joined:
    May 31, 2014
    Posts:
    1
    how to auto play
     
  16. JacobWMills

    JacobWMills

    Joined:
    Jun 22, 2013
    Posts:
    2
    Just posting to give mad props for this, literally the easiest thing in the world to implement, incredible and thank you.
     
  17. kodagames

    kodagames

    Joined:
    Jul 8, 2009
    Posts:
    488
    I use hostgator as well and had the same issues but realized I was naming the page the same as the .unity3d file once I used a totally different name than what the file was I had no issues. Not sure if this help but it solved the issue I had with hostgator.
     
  18. Anderson-Cardoso859

    Anderson-Cardoso859

    Joined:
    Mar 23, 2014
    Posts:
    57
    Amazing! Works very well.
     
  19. shaneK001

    shaneK001

    Joined:
    Dec 15, 2012
    Posts:
    19
    Thank you very much, this worked a charm.
     
  20. Sheriziya

    Sheriziya

    Joined:
    Oct 5, 2011
    Posts:
    241
    Hey all,

    I've installed it in my wordpress installation. Yesterday it worked pefectly. Today it stopped working while I have changed nothing. The webplayer shows up, but the game isn't loaded. I just get the Unity logo with the loading bar, but it it's not being loaded after that.
    I've checked other webplayers here on the site and those I can load without a problem.

    How can I solve this?

    Thanks for the help!
     
  21. victoria_dev

    victoria_dev

    Joined:
    Jul 15, 2014
    Posts:
    8
    Wonderful features - it's certainly worth a try. I use Wordpress an think that embedding Unity files will be great, especially for portfolio - to better showcase Unity works and games.
     
  22. Sheriziya

    Sheriziya

    Joined:
    Oct 5, 2011
    Posts:
    241
    Okay... Next time I've got a webplayer file that stopped working, I'll need to remind myself to reupload it and see if that helps. Apparently somehow my file got corrupted. I reuploaded and now it works perfectly.

    Have fun everyone!
     
  23. rileydabozo

    rileydabozo

    Joined:
    Feb 16, 2014
    Posts:
    8
    The problem with mine is that the borders are messed up on the game, and when I try to upload a new, improved version, it doesn't update. It should be all black, but once uploaded in Unity Dog it doesn't work. Here's a screenshot: AsteroidsOnline.PNG

    EDIT:

    It works now, turns out It's because every update I made, the game had the same name. I made a new name with every update, and it changed on the website.
     
    Last edited: Oct 20, 2014
  24. Lucymation

    Lucymation

    Joined:
    Sep 28, 2014
    Posts:
    2
    Hi!

    So firstly the plugin is amazing. I've got it to work perfectly with a default Wordpress theme.

    However when I switch back to my website's theme the Unity player simply just doesn't appear to exist!

    Please help, I have absolutely no idea how to fix this!!

    [EDIT] It was the theme that didn't support Unity web player apparently! It now works perfectly! Thank you so much!
     
    Last edited: Sep 29, 2014
  25. Lucymation

    Lucymation

    Joined:
    Sep 28, 2014
    Posts:
    2
    Hello!
    Sorry for what probably is an obvious question, but I have absolutely no idea how to disable the fullscreen button.

    Does anyone know how to do this?

    Thank you!!!!!!

    (This plugin is amazing by the way!!!)
     
  26. renegrox

    renegrox

    Joined:
    Nov 24, 2013
    Posts:
    1
    Hi! is there a way I can use this plugin by uploading my game via dropbox?
     
  27. Susanne_Mueller

    Susanne_Mueller

    Joined:
    Nov 21, 2014
    Posts:
    2
    Hey all,

    I used the plugin and it worked as it should when I tested it with small unity-projects. But when I embed a file that is more than 16 MB the plugin crashes and tells me it "failed to download file". Sometimes even the whole bowser crashes. I can only relate it to the size of the unity-files, since everything up to 16 MB works like a charme.


    Can somebody drop a hint what is wrong and what I could do to improve this?
    Can any of you use files with more then 16 MB?
     
  28. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,430
    If memory serves, the default settings for Wordpress limits downloads to less than 16mb. You have to edit the settings to allow larger downloads. Give that a try, I'm pretty sure that's what I did to fix this.
     
  29. shaneK001

    shaneK001

    Joined:
    Dec 15, 2012
    Posts:
    19
    I use filezilla to upload the file to the relevant folder on the wordpress site. Then, i use "add from server" wordpress plugin to add it to the media library. I've put mad big webbuilds up successfully.
     
  30. Susanne_Mueller

    Susanne_Mueller

    Joined:
    Nov 21, 2014
    Posts:
    2
    Thanks for the help, both of you. =)
    I was sick but I will start testing now.
    I already uploaded the files via ftp-upload, but the player crashes while loading, so I guess the error is somewhere else.
     
  31. Krahgnatokz

    Krahgnatokz

    Joined:
    Mar 18, 2014
    Posts:
    5
    Hi all, I'm using FileZilla to upload the plugin by Garry Newman. I did all the wp-content/plugin directory stuff, dropped the unitydog garry version folder, however, when I added my game as media (I had done it with the old version but I guessed I would re-add it to test) it still doesn't use the width and height I set with the w and h variables.
    Thanks for all the help, past and future!
     
  32. sledgeman

    sledgeman

    Joined:
    Jun 23, 2014
    Posts:
    332
    Have a problem with this nice plugin. I can´t get the *.unity3D file as "src" :( .(renaming to a *.zip doesn´t work)

    I mean, WHO uploads any other files than jpg with the intern WP media-file-uploder ??? Therefore you have thousand other better solutions with plugins in WP. So there isn´t any prob with the extention "*.unity3D". Of course you can upload any file extension to your WP content (with a plugin-uploader or a ftp).

    I opened the "unitydog.php" to set *.unity3D as source instead of the attachment-id. But with no success. It would be very kind if anybody can mod the few lines, or post it here in the forum :)
     
  33. sledgeman

    sledgeman

    Joined:
    Jun 23, 2014
    Posts:
    332
    Ok, got it by myself :) . So if anyone else don´t like the "id" solution and prefer the real-name, you can change the code with mine:

    // The unity shortcode , could look like: ... [unity loc="/blabla/test/" src="Buddweisser.unity3d"]
    $upload_dir = wp_upload_dir();
    $uploadbase = $upload_dir['baseurl'];

    function unitydog_unity( $atts ){
    global $uploadbase;

    if ( !$atts['src'] ) return "(missing unity src)";

    $source = $atts['src']; // <--- the one that you put down below into the "return" line
    $location = $atts['loc']; // <--- the one that you put down below into the "return" line
    $width = $atts['w'];
    $height = $atts['h'];

    return "<unitydog width=$width height=$height src=$uploadbase/$location/$source ></unitydog>";
    }
    add_shortcode( 'unity', 'unitydog_unity' );

    Btw. Thx for this great plugin !;)
     
    Sheriziya likes this.
  34. Wolfdog

    Wolfdog

    Joined:
    Jun 22, 2014
    Posts:
    61
    Someone mentioned about inputting real urls instead of IDs. Here's how to have 2 options:

    First of all, delete the
    Code (CSharp):
    1. if ( !$atts['src'] ) return "(missing unity src)";
    line in your unitydog.php.

    Then, add this where the deleted statement used to be:

    Code (CSharp):
    1. if ( !$atts['src'] ) {
    2.             $url = $atts['url'];
    3.         } else {
    4.             $url = wp_get_attachment_url( $atts['src'] );
    5.         }
    Now, when you're adding the shortcode, you can have it like this:
    Code (CSharp):
    1. [unity src="307"]
    or like this:
    Code (CSharp):
    1. [unity url="http://www.googledrive/example/your_hosting_link/whatever/your_game.unity3d"]
    Note that you must have at least one of them. If you have both, then your ID will be the one used, not your manual link.
     
  35. screenracer

    screenracer

    Joined:
    May 9, 2011
    Posts:
    109
    Thank you for creating this plugin. Only question is there a way I can set it to use my own loading image instead of the default unity image? Thanks!
     
  36. Wolfdog

    Wolfdog

    Joined:
    Jun 22, 2014
    Posts:
    61
    Hi, I was playing around with your car models last year. About your question, it's not possible with Unity Free (or personal version, as it's now called). The image is extracted from the .unity3d file, and not the server or anything. I believe that you can change it with Unity Pro?

    However, I'm currently using the Edge browser, which doesn't allow the web player to run. The web player is dying. It is recommended to export to WebGL as all browsers will eventually drop support for the unity web player. This means that the plugin will no longer be developed.
     
  37. sledgeman

    sledgeman

    Joined:
    Jun 23, 2014
    Posts:
    332
    i like the webplayer. small & compact & powerfull. don' t like if it would disappear. WebGL seems like the future, but its to big and not everything is supported
     
  38. Wolfdog

    Wolfdog

    Joined:
    Jun 22, 2014
    Posts:
    61
    I totally agree. Sadly, this is the way things will turn out - unless the web player itself changes (which Unity won't do). :(
     
  39. sledgeman

    sledgeman

    Joined:
    Jun 23, 2014
    Posts:
    332
    Yep... i like this webplayer, bcause published things are sooo tiny and supports the desktop versions. But i guess as you said, unity will focus on WebGL (if they can make it the same, like our lovely webPlayer...why not)
     
    Wolfdog likes this.