Search Unity

Make a 3D mesh as a box a button

Discussion in 'Scripting' started by rimiki, Sep 30, 2015.

  1. rimiki

    rimiki

    Joined:
    Dec 30, 2014
    Posts:
    102
    Dears,

    Is it possible that I ake a 3D mesh (a box for example) a button?

    Thank you for any suggestions : ))
     
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    Sort of, you can't just attach a button script to it and have it be ready. You'll have to write a script yourself that can check when you click the 3D mesh and call any functions you want it to.

    To check if the mesh is clicked on, put a 3D collider on the object and use Physics.Raycast() on a ray that you get from camera.ScreenPointToRay(). I recommend not using a mesh collider unless you really need the precision.

    Let me know if/where you get stuck and I'll elaborate. Best of luck!
     
  3. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
  4. rimiki

    rimiki

    Joined:
    Dec 30, 2014
    Posts:
    102
    Thank you :)