playMaker

Author Topic: Detect iOS Generation/Model?  (Read 2814 times)

blazingriver

  • Playmaker Newbie
  • *
  • Posts: 26
    • View Profile
Detect iOS Generation/Model?
« on: July 22, 2014, 06:52:52 AM »
How would I detect the generation/model of an iOS device. I believe that I would use the "Get iPhone Settings" action, but I am not sure how I would use it to run a script depending on the generation/model. I am using the 2D Toolkit.

The scripts I would run would vary on the generation of the iOS device/model.
If the device is the iPhone 3GS or older, it would run this script
Code: [Select]
tk2dSystem.CurrentPlatform = "1x";
If the device is an iPhone 4, 4S, iPod Touch 4g, iPhone 5, 5C, 5S, iPod Touch 5g, iPad, iPad 2, iPad Mini (or any other devices other than retina iPads beyond the iPhone 3gs), it would run this script:
Code: [Select]
tk2dSystem.CurrentPlatform = "2x";
If the device is an iPad 3, iPad Mini Retina, iPad Air (or any iPad device beyond the iPad 3), it would run this script:
Code: [Select]
tk2dSystem.CurrentPlatform = "4x";
If someone could help me in creating such an FSM I would be very grateful!
Thanks! :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
  • Official Playmaker Support
    • View Profile
Re: Detect iOS Generation/Model?
« Reply #1 on: July 23, 2014, 05:47:16 AM »
Hi,

 I created an action for this:
 http://hutonggames.com/playmakerforum/index.php?topic=7927.0

now, you can then compare the result with the versions you want to fall into certain categories and setup tk2d like that.

Can you access the CurrentPlatform setting already with PlayMaker?

 Bye,

 Jean

blazingriver

  • Playmaker Newbie
  • *
  • Posts: 26
    • View Profile
Re: Detect iOS Generation/Model?
« Reply #2 on: July 24, 2014, 08:09:01 AM »
Hi, thanks for your response.
I couldn't already access the currentplatform setting with playmaker (at least I don't think I could). Also, what are the output strings from the Get iPhone generation action, and does it recognise all iOS devices (or just iPhones).

Would you also use the string compare tool to compare the output string from the Get iPhone Generation action to a user defined string containing one of many device strings and have an event for each device to direct it to run the right script using the add script action? And if so, could you do all this by using only one String Compare on the starting state or would you have to use several string compare actions on the state for each device (essentially I am asking for the simplest way to do this, I am still a bit unfamiliar with playmaker)?

Also, I have another device detecting related (but different issue). I was told that the best way to have custom 2D sprite backgrounds for different screen sized devices (as in a custom background to fit devices with different screen sizes, e.g. a specific custom background for the iPhone 5 and iPad) is to load the correct background at runtime using Resources.Load to help load the correct prefab (not through playmaker). Is there anyway I could do such a thing through playmaker. I was considering to load all the backgrounds and hide the irrelevant ones but I was told that would produce a large memory overhead. How would I accomplish such a thing that was suggested to me through playmaker. I assume I would still use the same action that you created?

Thanks!
« Last Edit: July 24, 2014, 08:10:41 AM by blazingriver »

blazingriver

  • Playmaker Newbie
  • *
  • Posts: 26
    • View Profile
Re: Detect iOS Generation/Model?
« Reply #3 on: July 28, 2014, 02:16:55 AM »
Bump

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14819
  • Official Playmaker Support
    • View Profile
Re: Detect iOS Generation/Model?
« Reply #4 on: July 29, 2014, 06:21:32 AM »
Hi,

you can find the full list on the Unity Help:

http://docs.unity3d.com/ScriptReference/iPhoneGeneration.html

And then you do a string compare yes to redirect and setup your app the way you want for all the different devices.


Bye,

 Jean

blazingriver

  • Playmaker Newbie
  • *
  • Posts: 26
    • View Profile
Re: Detect iOS Generation/Model?
« Reply #5 on: July 29, 2014, 07:50:30 AM »
Thanks! I will try that out soon and see how that goes.