Пример #1
0
        void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                // if left mouse clicked, try slice this object

                Ray          ray  = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit[] hits = Physics.RaycastAll(ray, 100f);

                ++_sliceId;

                for (int i = 0; i < hits.Length; i++)
                {
                    IBzSliceable      sliceable  = hits[i].transform.GetComponentInParent <IBzSliceable>();
                    IBzSliceableAsync sliceableA = hits[i].transform.GetComponentInParent <IBzSliceableAsync>();

                    Vector3 direction = Vector3.Cross(ray.direction, Camera.main.transform.right);
                    Plane   plane     = new Plane(direction, ray.origin);

                    if (sliceable != null)
                    {
                        sliceable.Slice(plane);
                    }

                    if (sliceableA != null)
                    {
                        sliceableA.Slice(plane, _sliceId, null);
                    }
                }
            }
        }
Пример #2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            ++_sliceId;

            foreach (Transform target in gameObject.transform)
            {
                IBzSliceable      sliceable  = target.GetComponentInParent <IBzSliceable>();
                IBzSliceableAsync sliceableA = target.GetComponentInParent <IBzSliceableAsync>();

                Plane plane = new Plane(target.right, target.position);
                if (sliceable != null)
                {
                    sliceable.Slice(plane);
                }
                if (sliceableA != null)
                {
                    sliceableA.Slice(plane, 0, null);
                }
            }
        }
    }