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); } } } }
private void Awake() { if (_instance == null) { _instance = this; } else { Destroy(gameObject); } plane = new Plane(new Vector3(0.0f, -2f, 0.0f), new Vector3(-0.2f, 0.8f, 1f)); _sliceableAsync = GetComponent <IBzSliceableAsync> (); Vibration.Init(); }
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); } } } }
void Start() { _sliceableAsync = GetComponentInParent <IBzSliceableAsync>(); }