public void Start() { //during awake of first scene force touch state is not yet available. If InputManager is initialized later it's ok to call this in Awake. //For platforms other than iOS ForceTouchState.IncompatibleOS will be returned. forceTouchState = ForceTouchPlugin.GetForceTouchState(); //if (forceTouchState != ForceTouchState.IncompatibleOS) // AddCallback (); }
/* * Method that will be called by native end if ForceTouch state changes. You must * subscribe to that event by calling AddCallback method. For this method to be called, * InputManager component has to be in hierarchy. * See AddCallbackMethod in ForceTouchPlugin.cs for more info */ public void UpdateForceTouch(string message) { if (GetComponent <StatusUI>()) //this is only required for StatusUI. { GetComponent <StatusUI>().callbackMessage = message; } forceTouchState = ForceTouchPlugin.GetForceTouchState(Int32.Parse(message)); }
public void Start() { //during awake of first scene force touch state is not yet available. If InputManager is initialized later it's ok to call this in Awake. //For platforms other than iOS ForceTouchState.IncompatibleOS will be returned. forceTouchState = ForceTouchPlugin.GetForceTouchState(); //it would be best to only start tracking if forceTouchState is Available or if supportsTouchRadius is true. //If native touches are used on old ios devices or devices that have force touch disabled it's a performance penalty that could be avoided. //if (forceTouchState == ForceTouchState.Available) { ForceTouchPlugin.StartTracking(); //won't be executed on anything but iOS so no need to add compiler conditionals //AddCallback(); } }