- Home /
Question by
lalaiosmoiko · Jun 10, 2016 at 06:54 PM ·
ios3dtouchtouch controls
Force 3D touch IOS
Hello :) I am trying to make the .pressure API of unity to work with Apples 3D touch, My function is as follows;
public void Pressure2()
{
if (Input.GetTouch(0).pressure <= 0.66f)
{
mainCam.backgroundColor = Color.red;
}
else if (Input.GetTouch(0).pressure > 0.66f)
{
mainCam.backgroundColor = Color.white;
}
else if (Input.GetTouch(0).pressure > 2.66f)
{
mainCam.backgroundColor = Color.blue;
}
else if (Input.GetTouch(0).pressure > 4.66f)
{
mainCam.backgroundColor = Color.green;
}
else
{
mainCam.backgroundColor = Color.yellow;
}
}
What I am trying to do is changing the background of the camera according to force value.
But now when I click it it only becomes red!
Please help :D
also the button config:
uib.png
(33.5 kB)
Comment
Best Answer
Answer by lalaiosmoiko · Jun 13, 2016 at 08:49 PM
Ok I found it , the Event Trigger should be on UpdateSelected and not Pointer Down
Hi, main doesn't works(
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TouchPressure : $$anonymous$$onoBehaviour {
void Start () {
}
void Update ()
{
}
public void Pressure ()
{
if (Input.touchCount > 0)
{
if (Input.GetTouch (0).pressure <= 0.66f)
{
//gameObject.GetComponent<Image> ().color = Color.red;
print("ok");
}
}
}
}
Unity 2017.1 iOS Remote on iPhone SE
Your answer
![](https://koobas.hobune.stream/wayback/20220612082639im_/https://answers.unity.com/themes/thub/images/avi.jpg)