Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Easiest way to use the right mouse button?

Discussion in 'Scripting' started by ColdWarrior, May 26, 2015.

  1. ColdWarrior

    ColdWarrior

    Joined:
    May 8, 2015
    Posts:
    12
    I'm trying to make a simple board game prototype and want to make left clicking on a piece return a list of tiles the piece can move to, and right clicking return a list of tiles the piece can attack.

    I've read a little bit and cant find a simple solution,
    I've been doing this for left clicking:


    Code (CSharp):
    1.     void OnMouseUpAsButton(){
    2.         if (onTile.ally)
    3.             Board.S.Clicked (this);
    4.         if (onTile.onDeck)
    5.             Board.S.Clicked (this);
    6.     }
    What do you suggest for right clicking?
     
  2. krougeau

    krougeau

    Joined:
    Jul 1, 2012
    Posts:
    451
  3. hamsterbytedev

    hamsterbytedev

    Joined:
    Dec 9, 2014
    Posts:
    353
    Code (csharp):
    1.  
    2. if(Input.GetMouseButtonUp(1)){
    3.     //Do something!
    4. }
    5.  
    It's that easy :)
     
    krougeau likes this.