I have the following code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BuildSystem : MonoBehaviour {
RaycastHit hit;
Ray ray;
Vector3 Paredposition;
public int elevacion;
public Transform CuboObjeto, Cubo, Cubo2;
public LayerMask layer;
public void Boton1(){
coso ();
if (Input.GetMouseButtonDown (0)) {
Instantiate (Cubo, CuboObjeto.position, CuboObjeto.rotation);
}
}
public void Boton2(){
coso ();
if (Input.GetMouseButtonDown (0)) {
Instantiate (Cubo2, CuboObjeto.position, CuboObjeto.rotation);
}
}
void coso(){
ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if(Physics.Raycast(ray, out hit, 5, layer)){
Paredposition = hit.point;
Paredposition.y = 0f;
CuboObjeto.position = Paredposition;
}
}
}
What I try to do there is that by pressing a button change to what corresponds
I have 2 buttons, one to appear black and the other blue
So when I press for example, black, that I can just put that block and if then I play blue, I can just put the blue, etc.