Beispiel #1
0
    protected void AdjustSelectionBox()
    {
        if (!SelectBox.isActive)
        {
            SelectBox.Enable();
        }
        Vector3 worldClickedPosition = Camera.main.ScreenToWorldPoint(clickedPosition);
        Vector3 worldMousePosition   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        float   xMin = Mathf.Min(worldMousePosition.x, worldClickedPosition.x);
        float   xMax = Mathf.Max(worldMousePosition.x, worldClickedPosition.x);
        float   yMin = Mathf.Min(worldMousePosition.y, worldClickedPosition.y);
        float   yMax = Mathf.Max(worldMousePosition.y, worldClickedPosition.y);
        float   zMin = Mathf.Min(worldMousePosition.z, worldClickedPosition.z);
        float   zMax = Mathf.Max(worldMousePosition.z, worldClickedPosition.z);

        SelectBox.AdjustSize(new Vector3(xMin, yMin, zMin), new Vector3(xMax, yMax, zMax));
    }