Transfer controls from keyboard buttons to IPhone buttons

Luckily my game only has two buttons. Haha so i wanted to make a simple IPhone game but since i am not really used to iphone inputs i just wanted to test it with the keyboard. So all my game is, is going left and right. But i want it so that if you touch the right side of the screen, the ship goes to the right, and if you touch the left side of the screen, it goes left. So this is my script
#pragma strict

var isIdle = true;
var isLeft = false;
var isRight = false;

function Update () {
	var translation : float = Time.deltaTime * 3;
	gameObject.animation.wrapMode = WrapMode.Loop;
	
	if (Input.GetKeyDown(KeyCode.A)){
	isIdle = false;
	isLeft = true;
	isRight = false;
	}
	if (Input.GetKeyDown(KeyCode.D)){
	isIdle = false;
	isLeft = false;
	isRight = true;
	}
	if (Input.GetKeyUp(KeyCode.A)){
	isIdle = true;
	isLeft = false;
	isRight = false;
	}
	if (Input.GetKeyUp(KeyCode.D)){
	isIdle = true;
	isLeft = false;
	isRight = false;
	}
	if (isIdle == true) {
		gameObject.animation.Play("Idle");
	}
	if (isLeft == true){
		gameObject.animation.Play("MoveLeft");
		transform.Translate (-translation, 0, 0,Space.World);
	}
	if (isRight == true){
		gameObject.animation.Play("MoveRight");
		transform.Translate (translation, 0, 0, Space.World);
	}
	
}

how do i convert it from “A” and “D”, to these new Iphone inputs?

Here is a nice trick and is the quickest way to get you heading in the right direction. OnMouseDown functions work with mobile input. Pretty much, you have to triggers (one for right and one for left) that cover your cameras view and are see-through. You will need to separate your code into two separate scripts, one to handle right movement and the other to handle left movement. Now, hear is the downside to using OnMouseDown: Their is only ONE mouse. If you touch the screen with two fingers, the touch screen reads the input as a mouse click at the midpoint of the two touches. So, in effect, OnMouseDown is not multitouch supportive, but it is the easiest way of converting your scripts. That is one way of doing it however.

The best way to accomplish transitioning between pc to mobile input is to make two invisible GUITextures (similar to the above method’s triggers). Using these GUITextures, you will check for a hitTest on that texture. Then, move left or right accordingly. The only difference between this method and the one above is this method is multitouch supportive. This is because instead of using an invisible mouse as your touch input, it actually uses your fingers. Here is a quiche snippet of code over how to check for hitTest:

var moveLeft : GUITexture;
var moveRight : GUITexture;

function Update () {
      for (var touch : Touch in Input.touches) {
            if (moveLeft.HitTest( touch.position )) {
                  rigidbody.AddForce(2,0,0);
            }
            if (moveRight.HitTest( touch.position )) {
                  rigidbody.AddForce(-2,0,0);
            }
      }
}

*Note: If you use the above code, it does not support computer input. You must either test using the Unity Remote or build the game to your device.