My game works on the iPhone. Everything went smoothly.
However, some of my menu buttons work and some do not. Some of my menus show up and some do not. Zero of my finger/mouse clicks work during the actual game play.
Does anyone know why mouse/finger clicks will not work in iPhone? I’m using Unity 3 and iPhone 4.2. Let me know if I need to post button code or anything.
I’n not sure quite what to post for the code, but you can play the game for free at www.wooglie.com…look for “bubble factory.” I guess I can post the button and mouse click code? I’ll post it once I find it in the iphone sdk…unity exported a ton of files…
hmmm…I don’t see any code in the iphone sdk that has anything to do with my game…so I wonder if that means the export from unity was not correctly built???
Ok, so here is the old code commented out in unity and the new code below. Remember, the old code at the top is for a mouse down that builds and works in unity and makes it’s way to the iphone, but does not work in game on the iphone. The new code below that is not commented out will not even build. I imagine there is a small error in my code, but I need to know if I’m on the right track with the touch code.
if(MenuStates.curState != MenuType.PAUSE MenuStates.curState == MenuType.HUD)
{
var hit:RaycastHit;
for (var i = 0; i < Input.touchCount; ++i) {
if (Input.GetTouch(i).phase == TouchPhase.Began) {
// Construct a ray from the current touch coordinates
var ray = Camera.main.ScreenPointToRay (Input.GetTouch(i).position);
if (Physics.Raycast (ray, hit)) {
// Create a particle if hit
var hitObj:GameObject = hit.transform.GetComponent(GameObject);
Ok, so my mouse down code does not work. The iphonetouchcode does not work, and the touch code does not work. Am I missing something. All I need is: When I touch this texture image, do something…like show text or take me to the next texture…Can anyone show me that touch/mouse click code?? I need it for the iphone.
I’m not a programmer so I can’t help to much, but you can also use Input.GetMouseButton(0) on the iphone, though its no good if you need multi touch. I would suggest looking at the Penelope tutorial.
if(!SquidgyToggle.isSquidgy !SquidgyToggle.isOnHUD Time.timeScale != 0.0)
{
var hit : RaycastHit;
for (var i = 0; i < Input.touchCount; ++i) {
if (Input.GetTouch(i).phase == TouchPhase.Began) {
// Construct a ray from the current touch coordinates
var ray = Camera.main.ScreenPointToRay (Input.GetTouch(i).position);
if (Physics.Raycast (ray, hit)) {
// Create a particle if hit
var hitObj:GameObject = hit.transform.GetComponent(GameObject) as GameObject;
My touches don’t work even though the code fully works as mouse clicks in Unity. I’m using all the 4.2 softwares and updates. The bubbles are dynamically created as particles on planes, if that helps. Thanks!!!
You should not assume that all new touches will have TouchPhase.Began. For example if there was a very short touch, which’s duration was shorter that frametime then it will have TouchPhase.Ended, because it began and ended on the same frame and you get only the latest phase. Touch.fingerId might be more reliable way to track new touches.