Replace PlatformUtility with class instances
Describe the problem
At the moment, the MRTK uses its own RuntimePlatform enum to distinguish between platforms. It neither lists all platforms that Unity supports nor does it distinguish between "platforms" on the same platform (OculusGo and mobile devices are both Android platform).
Describe the solution you'd like
Instead of ever extending this enum with new platforms and thinking about a way to even distinguish between devices on the same platform, this can be replaced by a class deriving mechanism. Every script that makes use of the enum now makes use of System.Type implementing a simple check interface. Implementing this interface one can provide any logic that defines if conditions for a platform are met, like: "Is the Oculus SDK active AND the platform Android" in which case the class could itself derive from an Android only checker class and extend it to only meet Oculus Go requirements.
Describe alternatives you've considered
I thought about ScriptableObjects, but they would work the same with the overhead of first creating an instance of any of the derived classes of them. This would bloat the project and is just unnecessary.
Example Pseudo Code:
public class AndroidPlatformSupport : IPlatformSupport
{
public virtual bool Check()
{
return Application.platform == RuntimePlatform.Android;
}
}
public class OculusGoPlatformSupport : AndroidPlatformSupport
{
public override bool Check()
{
return base.Check() && OVRPlugin.GetSystemHeadsetType() == SystemHeadset.Oculus_Go;
}
}
I actually really like this idea. The only complication I can see would be the number of combinations we would need to support and the variations within the providers in order to support them.
Agreed, I like this idea as well.
Having a base device class and interfaces defining each platform and device is an interesting idea.
I'm unsure how it'll play out in the UI for selecting one, and how platform capabilities will be enabled.
We should definitely discuss this idea more.
I added some pseudo code to clarify my idea better. You basically lay out the current 5 supported platforms the way they are already checked anyways. Everyone can then refine the check to whatever platform specific he needs.
Love this.
Adding #5771 because of relation