Example #1
0
    void GetInput()
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
            if (mode == "build")
            {
                RotateShowingObject();
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            if (!EventSystem.current.IsPointerOverGameObject() && ableToBuild == 0 && mode == "build")
            {
                BuildObject();
            }
        }
        if (Input.GetMouseButtonDown(1) && mode != "none")
        {
            DestroyAllShowingObjects();
            ableToBuild = 0;
            mode        = "none";
        }

        if (Input.GetMouseButtonDown(0))
        {
            if (!EventSystem.current.IsPointerOverGameObject() && mode == "trash")
            {
                RaycastHit hit = pointer.GetRaycastHit();

                GameObject obj = hit.transform.gameObject;

                DestroyObject(obj);
            }
        }
        if (Input.GetMouseButtonDown(0))
        {
            if (!EventSystem.current.IsPointerOverGameObject() && mode == "plant")
            {
                PlantCrop();
            }
        }
    }