Example #1
0
    // Main loop
    private void Update()
    {
        if (!paused)
        {
            time += Time.deltaTime;
        }
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hitInfo = new RaycastHit();

            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            bool bodyHit = Physics.Raycast(ray, out hitInfo, 100000f);

            // if (bodyHit)
            // {
            //     Debug.Log("gb hit");
            //     HandleSelectedObject(hitInfo);
            // }
            // else if (!IsClickButton())
            // {
            //     selected = new HashSet<GravityBody>();
            //     HasSelected = false;
            //     Debug.Log("no hit");
            // }
            // else
            // {
            //     Debug.Log("ui hit");
            // }
        }
        if (selected.Count == 2)
        {
            List <GravityBody> list = new List <GravityBody>(selected);

            GbDistance  = GravityBody.DistanceBetween(list[0], list[1]);
            HasSelected = true;
        }
    }