void SpawnIcon() { if (!searching && IconPool.PoolAvailable()) { StartCoroutine(FindSpawnPoint()); } if (pickedSpawnPosition != Vector3.zero && IconPool.PoolAvailable()) { GameObject icon = IconPool.GetAvailableObject(); icon.GetComponent <InteractableIcon>().Reset(); icon.transform.position = pickedSpawnPosition; IconSnapToGrid iconSnap = icon.GetComponent <IconSnapToGrid>(); iconSnap.Init(); if (!iconSnap.TrySnapIcon()) { IconPool.ReturnGameObjectToPool(iconSnap.gameObject); } icon = null; StopAllCoroutines(); searching = false; pickedSpawnPosition = Vector3.zero; } }
private void Awake() { if (iconPool == null) { throw new System.ArgumentNullException("Missing icon pool, please assign one in the inspector."); } iconSnap = GetComponent <IconSnapToGrid>(); iconSnap.Init(); iconSnap.TrySnapIcon(); saveData = FindObjectOfType <SaveData>(); }
public void OnClick() { if (!IsClickedOn) { //picked up IsClickedOn = true; if (!iconSnapScript.grid.TryUnregisterIconOnPosition(iconSnapScript.CurrentSnapPosition)) { throw new System.ArgumentException("This item is not registered"); } } else { if (iconSnapScript.TrySnapIcon() || HoverOverBin) { IsClickedOn = false; } } }