Touch input on a game object

Hi everyone

I have a question about touch inputs. I am new to the touch and still learning Unity. I am making a game for Windows 8 and I want the user to click a game object and sends an event to a script attached to the main camera. I got the mouse buttons (0) working. I not sure if I am can or how to send the event from the chest being touched to equal a mouse button one click event that would do all the checks on the other script. The code is mostly written in C#.

Thanks for the advice or suggestions.

John L

Hi,

Thanks for the reply! I decided to rewrite the script from example from Unity Scripting API from Input.GetTouch and I am still having no luck with touch events working. Below is a copy of my script

using UnityEngine;
using System.Collections;


[RequireComponent(typeof(Collider))]//Need a Collider
public class OnTouchEvent : MonoBehaviour {
    private bool checkClicked;
    private int Score;
    public dfPanel completePanel;
    public bool hasScored = false;
    


    void Start()
    {
        // Make the rigid body not change rotation
        if (rigidbody)
            rigidbody.freezeRotation = true;

        //completePanel = GameObject.Find("LeaveComplete");
        
        checkClicked = MouseLookRestricted.checkClicked;
        Score = MouseLookRestricted.Score;
       
    }

    void Update ()
    {
        int i = 0;
        while (i < Input.touchCount)
        {
            if (Input.GetTouch(i).phase == TouchPhase.Began)

            OpentheChest();
        }
    }
 
    public void OpentheChest()
    {
       
             FCMain pMain = GetHitChest();

         if (pMain != null)
        {
             if(hasScored == false)
             {
            //Score += 1;// check to see if event has happened to track score
                 MouseLookRestricted.Score += 1;
                 checkClicked = true;// changes bool to true so only one click will work
                  //Invoke("Waittime", (5));//Wait before showing completion screen
                  // complete
                 pMain.ToggleOpen();
                 completePanel.IsVisible = true;
                    
                //Time.timeScale = 0;
                //PauseEvents.paused = true;
                 Debug.Log("For Touch");
                 hasScored = true;
             }
             
             else
             {
                 Debug.Log("You already Completed this level!");
             }

        }
        

    }

   FCMain GetHitChest()
    {
        Debug.Log("Test");
       return gameObject.GetComponent<FCMain>();;
    }


 }

What I am trying to make happen is when the user touches chest(gameobject the script is attached to the chest),and it will call the function OpentheChest. I am still new and learning, so any help would be appreciated.

Thanks,
John