示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (GuiManager != null && GuiManager.IsMouseOverGui)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.Mouse0) ||
            Input.GetKeyDown(KeyCode.Mouse1))
        {
            OrbitCamera.DeactivateOrbit();
            GuiManager.HideStarFocus();
            PlanetsWithStars.PickedStar = null;
        }

        if (Input.GetKeyDown(KeyCode.H) ||
            Input.GetKeyDown(KeyCode.Home))
        {
            OrbitCamera.SetMode(CameraMode.Free);
            OrbitCamera.OrbitLocation(Stars[0]);
            GuiManager.SetStarFocus(Stars[0]);
        }

        if (Input.GetKey(KeyCode.Mouse0))
        {
            Star closestStar;
            if (PickStar(out closestStar))
            {
                GuiManager.SetStarFocus(closestStar);
            }
        }
        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            Star closestStar;
            if (PickStar(out closestStar))
            {
                OrbitCamera.SetMode(CameraMode.Free);
                OrbitCamera.OrbitLocation(closestStar);
                GuiManager.SetStarFocus(closestStar);
                PlanetsWithStars.PickedStar = closestStar;
            }
        }
    }