// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.transform.gameObject.tag.Contains("ActionObject")) { // save clicked object mouseHeldOverActionObject = true; clickedObject = hit.transform.gameObject; clickStartTime = Time.time; clickedMousePosition = Input.mousePosition; } else { // just set moving destination //hit.point selectedAction = enCharacterAction.Walk; } } } else if (Input.GetMouseButtonUp(0)) { // perform default click action if action was not selected from menu if (!displayObjectActionMenu) { // default action // print("Default action"); } // release held object if (mouseHeldOverActionObject) { clickStartTime = 0.0f; mouseHeldOverActionObject = false; displayObjectActionMenu = false; } } if (mouseHeldOverActionObject) { // display action menu if mouse is held long enough if (Time.time - clickStartTime >= DISPLAY_MENU_TIME) { displayObjectActionMenu = true; } } print (selectedAction); }
// Action icons //public Texture actionIcon; // Use this for initialization void Start() { selectedAction = enCharacterAction.NoAction; }