Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void OnGUI()
- {
- GameObject [] pipes = GameObject.FindGameObjectsWithTag("Holder"); //get all holder gameobjects
- foreach(GameObject pipe in pipes) //loop through all holder gameobjects
- {
- SetPipe setPipeScript = pipe.GetComponent<SetPipe>();
- selGridInt = GUI.SelectionGrid(new Rect(50, 70, 100, 500), selGridInt, pipeShape, 1);
- setPipeScript.pipeSelect = selGridInt;
- }
- }
- public class SetPipe : MonoBehaviour {
- public Transform [] pipe; //put this into an array so it's easier to get stuff from it. just set the size to 7 in the Inspector and fill it with your pipe objects.
- public int pipeSelect;
- void OnMouseOver()
- {
- if (Input.GetMouseButtonDown(0))
- {
- Debug.Log(pipe[pipeSelect].name);
- Instantiate(pipe[pipeSelect], gameObject.transform.position, Quaternion.Euler(0, 0, -90));
- Destroy(gameObject);
- }
- }
- }
Advertisement
RAW Paste Data
Copied
Advertisement