Hi,
I would like my Unity Editor to be seen as an iOS device. Despite being set to the iOS platform, “Application.platform” returns OSXEditor.
Can I trick the system into thinking its an iPhone?
Hi,
I would like my Unity Editor to be seen as an iOS device. Despite being set to the iOS platform, “Application.platform” returns OSXEditor.
Can I trick the system into thinking its an iPhone?
You cannot modify the value that is returned from Application.platform, but you can however trick your game into thinking what is the current platform.
For example:
using UnityEngine;
public class ApplicationEx
{
private static RuntimePlatform runtimePlatform;
static ApplicationEx()
{
#if UNITY_EDITOR
runtimePlatform = RuntimePlatform.IPhonePlayer; // return iphone as the current platform
#else
runtimePlatform = Application.platform;
#endif
}
public static RuntimePlatform platform
{
get
{
return runtimePlatform;
}
}
}
Instead of directly calling Application.platform, you wrap it in another class, and then you can return whatever value you want.
Ok, I see.
Thank you!
@liortal ,
Can you help me debugg this script as you posted? Clearly PlatformHelper is not a “static”… nothing.
This type of scripting trickery, is not in my wheel house at the moment.
I think it is a great idea, but is currently packing errors.
I fixed the code, should be fine now.
Again tho, I am getting an error.
static ApplicationEx()
{}
has no return type.
??
The code works fine, it compiles OK when i tested it here.
Drop the code that i posted above (EXACTLY, without modifying it) into a new file in your project called ApplicationEx.cs
Then, somewhere in your code, instead of:
Application.platform
You should be checking for
ApplicationEx.platform
for example:
if (ApplicationEx.platform == RuntimePlatform.IPhonePlayer)
{
// TODO
}
ok, will do.
I see what I did. I left it as my class, in monodevelop. I just pasted in the contents. Cheers. Will test soon!
Hi, I copied your code and pasted into a script (full out). I can not attach it to an object tho. Unity informs me that since the script does not derive from MonoDevelop, that it cant.
Leaving it off and running does nothing either.