Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlatformController : MonoBehaviour
- {
- // Start is called before the first frame update
- private bool showMenu = false;
- public GameObject tower;
- public GameObject prefabTower;
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- }
- void OnMouseDown()
- {
- showMenu = true;
- Debug.Log("Click");
- }
- void OnGUI()
- {
- if(showMenu && !tower)
- {
- Vector3 pos = new Vector3(transform.position.x, transform.position.y, transform.position.z);
- Vector3 crd = Camera.main.WorldToScreenPoint(pos);
- crd.y = Screen.height - crd.y;
- GUI.Box(new Rect(crd.x - 150, crd.y - 100, 310, 200), $"Управление башней {gameObject.name}");
- if (GUI.Button(new Rect(crd.x - 145, crd.y - 70, 290, 30), "Купить башню"))
- {
- showMenu = false;
- //prefabTower = Resources.Load("Prefabs/Tower", typeof(GameObject));
- //GameObject instance = Instantiate(Resources.Load("Tower", typeof(GameObject))) as GameObject;
- tower = Instantiate(prefabTower, gameObject.transform.position, Quaternion.identity);
- }
- if (GUI.Button(new Rect(crd.x - 145, crd.y + 70, 290, 20), "Закрыть меню"))
- {
- showMenu = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement