// Update is called once per frame void Update() { RaycastHit hit = new RaycastHit(); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); worldMousePosition = ray.direction; Debug.DrawRay(ray.origin, ray.direction * 1000f, Color.red); if (Physics.Raycast(ray, out hit)) { if (Input.GetMouseButtonDown(0)) { if (hit.transform != null) { Debug.Log(hit.transform.gameObject.name); PooslMgr.Despawn(hit.transform.gameObject); } } hit.transform.GetComponent <MeshRenderer>().material.color = Color.green; hitGos.Enqueue(hit.transform.gameObject); Debug.DrawRay(ray.origin, (hit.point - ray.origin), Color.green); } else { if (hitGos.Count > 0) { hitGos.Dequeue().GetComponent <MeshRenderer>().material.color = Color.white; } } }
public void Swapn(string goName) { var obj = PooslMgr.Spawn(goName); if (!obj.GetComponent <BoxCollider>()) { obj.AddComponent <BoxCollider>(); } obj.transform.position = PoolsManTest.worldMousePosition * 100f; }
private void Awake() { if (_instance != null) { Destroy(gameObject); } else { _instance = this; Instance.gameObject.name = "GameObjPoolsMan"; Instance.transform = gameObject.transform; DontDestroyOnLoad(gameObject); } }
// Start is called before the first frame update void Start() { PooslMgr.CreatePool(prefab); }