示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            GameObject unitRef = IsMouseOnUnit(Input.mousePosition);

            Debug.Log("Mouse Was clicked, unit ref" + (unitRef == null ? "NULL" : "NOT NULL"));

            if (unitRef != null)
            {
                Debug.Log("Mouse is over a unit");
                if (PreviousUnit != null)
                {
                    animalController previousController = PreviousUnit.GetComponent <animalController>();
                    previousController.UnselectUnit();
                }
                CurrentUnit = unitRef;
                animalController controller = CurrentUnit.GetComponent <animalController>();
                controller.SelectUnit();
                PreviousUnit = CurrentUnit;
            }
        }
    }