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
1
Question by RickLove · Jan 30, 2012 at 05:19 PM · iphonewebplayerinstall

Bug? UnityObject.js shows the Install button on an iPhone 3gs

Whenever a mobile user or other non-player compatible user goes to my unity web player page, I want it to tell the user that the web player does not work on their platform.

Instead, it shows the installation button which of course is confusing for the user.

I see some browser detection in the UnityObject.js code, but I haven't spent the time trying to trace everything down. What is the UnityObject.js code supposed to do in case of an incompatible platform?

My web player is at: http://www.toldpro.com/Games/BashnBlocks

My iPhone is an unlocked 3gs 4.0.2 with User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_2 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A400 Safari/6531.22.7

Comment
Add comment · Show 2
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 Graham-Dunnett ♦♦ · Jan 31, 2012 at 01:05 PM 0
Share

Happy to see that you posted a solution to your own question. A different approach is for your website to detect the client has a iOS device, and display completely different content, perhaps providing a link to the app store where the customer might be able to purchase the iOS version of the game. See, for example http://www.php.net/manual/en/function.get-browser.php.

avatar image RickLove · Feb 01, 2012 at 05:17 AM 0
Share

I will certainly do that once I flesh out the detection of various devices and I have the apps in the different app stores. However, it seems the UnityObject.js ought to at least tell the user it cannot be installed on their platform.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by RickLove · Jan 31, 2012 at 12:46 PM

I could not find an answer, but I made a way around this:

See it in action at: http://www.toldpro.com/Games/BashnBlocks You can see the default message if you look at the code source, even if the web player starts.

 function OnUnityLoaded(params) {
     if (params.success) {
         // Make the missing message go away
         var missingDiv = document.getElementById('missingMessage');
         missingDiv.parentNode.removeChild(missingDiv);
     }
 }
 function GetUnity() {
     if (typeof unityObject != "undefined") {
         return unityObject.getObjectById("unityPlayer");
     }
     return null;
 }
 if (typeof unityObject != "undefined") {
     unityObject.embedUnity("unityPlayer", "GAME.unity3d", 
       800, 600, null, null, OnUnityLoaded);
 
 }

then I defined the "missingMessage" div like so (this is ASP.NET MVP 3 Razor with C#):

 <div id="game">
     <div id="missingMessage">
         @{
                             
             var isMobile = BrowserHelper.IsMobile(Request);
             var canUseUnity = BrowserHelper.CanUseUnityWebPlayer(Request);
 
 
             // TESTING
             //canUseUnity = false;
 
             if (isMobile)
             {
             <p>
                 I'm sorry, the Unity Web Player does not work on mobile devices at this time.
             </p>
             <p>
                 The web player is only compatible with:
             </p>
             <ul>
                 <li>Windows 2000/XP/Vista/7</li>
                 <li>Mac OS X 10.4 or newer</li>
             </ul>
                                 
             <p>
                 However, I am planning to put the game in the relevant app store for iPhone/iPad,
                 Android, and Windows 7 Phones in the future.</p>
             <p>
                 More Information: <a href="http://told.shapado.com/questions/why-can-t-i-play-the-game">
                     Why can't I play the game?</a></p>
             <p>
                 If you think this message is in error, feel free to try to install the Unity Web
                 Player below:
             </p> 
             }
             else if (!canUseUnity.HasValue || !canUseUnity.Value)
             {
             <p>
                 I'm sorry, it appears you may not be able to use the Unity Web Player which is required
                 to play the game in the browser. The web player is only compatible with:
             </p>     
             <ul>
                 <li>Windows 2000/XP/Vista/7</li>
                 <li>Mac OS X 10.4 or newer</li>
             </ul>
                                 
             <p>
                 More Information: <a href="http://told.shapado.com/questions/why-can-t-i-play-the-game">
                     Why can't I play the game?</a></p>
             <p>
                 If you think this message is in error, feel free to try to install the Unity Web
                 Player below:
             </p>
             }
             else
             {
             <p>
                 You need to install the Unity Web Player to play the game.
             </p>
             <p>
                 The web player is compatible with:
             </p>
             <ul>
                 <li>Windows 2000/XP/Vista/7</li>
                 <li>Mac OS X 10.4 or newer</li>
             </ul>
                                 
             }
         }
     </div>
     <div id="unityPlayer">
         <div class="missing">
             <a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
                 <img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png"
                     width="193" height="63" />
             </a>
         </div>
     </div>
 </div>


My BrowserHelper class is defined:

 public static class BrowserHelper
 {
   public static bool IsMobile(HttpRequestBase request)
   {
     // From: detectmobilebrowsers.com
     string u = request.ServerVariables["HTTP_USER_AGENT"];
     Regex b = new Regex("GOTO detectmobilebrowsers.com to get the latest value",
       RegexOptions.IgnoreCase | RegexOptions.Multiline);
     return (b.IsMatch(u) || v.IsMatch(u.Substring(0, 4)));
   }
 
   public static bool? CanUseUnityWebPlayer(HttpRequestBase request)
   {
     // Windows 2000/XP/Vista/7
     // Mac OS X 10.4 or newer
     string u = request.ServerVariables["HTTP_USER_AGENT"];
 
     Regex winVersionRegex = new Regex(@"Windows NT ((?<major>\d+)\.(?<minor>\d+))");
     Regex macVersionRegex = new Regex(@"(?<!like) Mac OS X ((?<major>\d+)_(?<minor>\d+))");
     Regex macVersionUnknownRegex = new Regex(@"(?<!like) Mac OS X");
 
     var isHighEnough = IsHighEnoughVersion(u, winVersionRegex, 5, 0) ||
       IsHighEnoughVersion(u, macVersionRegex, 10, 4);
 
     if (isHighEnough)
     {
       return true;
     }
 
     if (macVersionUnknownRegex.IsMatch(u))
     {
       return null;
     }
     else
     {
       return false;
     }
   }
 
   private static bool IsHighEnoughVersion(string userAgentText, Regex versionRegex, int minMajor, int minMinor)
   {
     var match = versionRegex.Match(userAgentText);
 
     if (match.Success)
     {
       var major = int.Parse(match.Groups["major"].Value);
       var minor = int.Parse(match.Groups["minor"].Value);
 
       if (major > minMajor)
       {
         return true;
       }
       else if (major == minMajor)
       {
         if (minor >= minMinor)
         {
           return true;
         }
       }
     }
 
     return false;
   }
 
 }
Comment
Add comment · 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

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

Install Unity WebPlayer Plugin from Intranet 1 Answer

streaming to iPhone and Android 0 Answers

Web player will not uninstall or install. 0 Answers

Communication iPhone Webplayer 0 Answers

Create a game for both the iPhone and the Web Player 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