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 Thom Denick · Nov 02, 2010 at 03:04 AM · iostestingdeployment

How to test if game is currently deployed on iOS?

I am currently working on an iPad/iPhone game, which I frequently deploy test builds to PC and Mac for testing purposes (my testers don't have iPads.) Is there any easy way to do a test in scripting to see if the game is currently running on an iOS device?

Currently I have to comment out all of my iPhone Input-specific lines when I want to make a PC/Mac build, or I get compile errors. I realize that I'll still get compile errors even with an if statement... Is there a way for me to check if the build target is iPhone, and if not ignore all of my iPhoneInput lines?

UPDATE To clarify based on the answer and link below, this is how you actually implement an compile exception based on the device you are currently deployed to. In this example I am creating an exception for the code that automatically flips the screen orientation on iPad:

 void FixedUpdate() {
     #if UNITY_IPHONE
     // screen orientation
     //Source: http://forum.unity3d.com/threads/45747-iPad-Rotation
     if ((iPhoneInput.orientation == iPhoneOrientation.Portrait) && (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.Portrait))
         { iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Portrait; }
 
     if ((iPhoneInput.orientation == iPhoneOrientation.PortraitUpsideDown) && (iPhoneSettings.screenOrientation != iPhoneScreenOrientation.PortraitUpsideDown))
         { iPhoneSettings.screenOrientation = iPhoneScreenOrientation.PortraitUpsideDown; }
     #endif
     }

Hopefully, that's clear - what you are doing is just wrapping the iOS-exclusive code with the #if UNITY_IPHONE statement and ending it with the #endif. When you go to compile on Mac or PC, that bit of code is completely ignored.

As an additional note, the editor DOES compile that code when you execute, but obviously, it is equipped to handle iOS-specific commands.

Comment
Add comment · Show 1
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 cregox · Nov 15, 2014 at 10:47 AM 0
Share

much related: http://answers.unity3d.com/questions/305490/how-to-tell-if-the-device-is-android-or-ios.html

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Jessy · Nov 02, 2010 at 03:25 AM

You're not going about it quite right.

http://unity3d.com/support/documentation/Manual/Platform%20Dependent%20Compilation.html

Comment
Add comment · Show 1 · 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 Thom Denick · Dec 21, 2010 at 07:22 AM 0
Share

This did solve my problem. I've given an example in my question above that shows how I actually implemented this in my code.

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

1 Person is following this question.

avatar image

Related Questions

What iOS device to use/purchase for testing. 2 Answers

free Android and IOS 1 Answer

Advertising Identifier declaration missing? Testflight external testers 0 Answers

mac virtualbox virtual machine not recognising usb device 0 Answers

Can I post a game? 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