Sprites 폴더 생성
public class PlotManager : MonoBehaviour
{
void Start()
{
}
void Update()
{
}
private void OnMouseDown()
{
Debug.Log("Clicked");
}
}
[Plot]
Add Component - PolygonCollider2D
Points의 하위 Element 값 조정해 Collider 크기 맞추기
Collider 설정 후 클릭 시 Console창에 명령어 출력
plant 변수 → active: plant / inactive: harvest
public class PlotManager : MonoBehaviour
{
bool isPlanted = false;
public GameObject plant;
void Update() {}
private void OnMouseDown()
{
if (isPlanted)
{
Harvest();
}
else
{
Plant();
}
}
void Harvest()
{
Debug.Log("Harvested");
isPlanted = false;
plant.SetActive(false);
}
void Plant()
{
Debug.Log("Planted");
isPlanted = true;
plant.SetActive(true);
}
}
Plot 클릭 → Planted(true) / Harvest(false)
14:10 timer 설정 전까지