Copying and Pasting cs Code
In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.
For example, you can follow the pattern in this listing: public void Update()
{
if (!InputController.Enabled) return;
calculateTransform();
if (Input.GetButtonDown("Fire1"))
{
if (checkBounds(rect, convertTo800x480(Input.mousePosition)))
{
isTouchedDown = true;
if(gameObject.GetComponent() != null)
gameObject.GetComponent().OnTouchDown();
InputController.IsScreen = false;
}
}
else if (Input.GetButtonUp("Fire1"))
{
if (gameObject.GetComponent() != null)
gameObject.GetComponent().OnCheckUp();
Vector2 mouse = convertTo800x480(Input.mousePosition);
if (isTouchedDown && checkBounds(rect, convertTo800x480(Input.mousePosition)))
{
if(gameObject.GetComponent() != null)
gameObject.GetComponent().OnTouchUp();
}
isTouchedDown = false;
}
}
{
if (!InputController.Enabled) return;
calculateTransform();
if (Input.GetButtonDown("Fire1"))
{
if (checkBounds(rect, convertTo800x480(Input.mousePosition)))
{
isTouchedDown = true;
if(gameObject.GetComponent
gameObject.GetComponent
InputController.IsScreen = false;
}
}
else if (Input.GetButtonUp("Fire1"))
{
if (gameObject.GetComponent
gameObject.GetComponent
Vector2 mouse = convertTo800x480(Input.mousePosition);
if (isTouchedDown && checkBounds(rect, convertTo800x480(Input.mousePosition)))
{
if(gameObject.GetComponent
gameObject.GetComponent
}
isTouchedDown = false;
}
}