By looking at this game I got two ideas, one is to use cubes(with rigidbody and colliders attached) and other is to use the GuiTexture. If using cubes, I am think that how to detect the mouse click on individual cube and if using GuiTexture than how to know whether something is below or not.
This will check each frame if there is something under the mouse. Then it checks if it is a cube (via tag). If so you could manipulate the cube using hit.collider.gameObject (such as changing it’s forward/backward position, size, material, etc.):
function Update(){
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if(Physics.Raycast(ray,hit)){
if(hit.collider.tag == "clickableCube"{
//hit.collider.gameObject now refers to the
//cube under the mouse cursor if present
}
}
}
As for the GUITexture, you can just use that in the OnGUI function to replace the mouse cursor:
var crosshair : Texture;
function Start(){
Screen.showCursor = false;
}
function OnGUI(){
var pos = Input.mousePosition;
GUI.DrawTexture(Rect(pos.x-crosshair.width/2,pos.y-crosshair.height/2,crosshair.width,crosshair.height),crosshair);
}
if (Input.GetMouseButtonDown (0)) {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 100)) {
// whatever tag you are looking for on your game object
if(hit.collider.tag == "Trigger") {
Debug.Log("---> Hit: ");
}
}
}