private GameObject GetBlockUnderMouse() { Camera camera = CameraExtensions.FindCameraUnderMouse(); if (camera == null) { return(null); } Ray ray = camera.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (!Physics.Raycast(ray, out hitInfo)) { return(null); } GameObject gameObject = RootGameObject.GetRoot(hitInfo.collider.gameObject); if (Tags.PALETTE_BLOCK.HasTag(gameObject)) { return(gameObject); } return(null); }
protected override void DoActivate(Collider collider) { originalBlock = RootGameObject.GetRoot(collider.gameObject); originalBlock.SetActive(false); moveCollisionChecker = Instantiate(originalBlock); moveCollisionChecker.name += "_Checker"; moveFeedback = Instantiate(originalBlock); moveFeedback.name += "_Feedback"; Initialise(moveFeedback, moveCollisionChecker); }
protected override Collider GetColliderForDrag() { Camera camera = CameraExtensions.FindCameraUnderMouse(); Ray ray = camera.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; // Ignore pips when raycasting if (Physics.Raycast(ray, out hitInfo)) { GameObject root = RootGameObject.GetRoot(hitInfo.collider.gameObject); if (Tags.EDITOR_BLOCK.HasTag(root) && root.transform.parent != null) { return(hitInfo.collider); } } return(null); }
// Update is called once per frame public bool CanActivate() { if (!Input.GetButton(DragButtonName) || EventSystem.current.IsPointerOverGameObject()) { return(false); } Camera camera = CameraExtensions.FindCameraUnderMouse(); Ray ray = camera.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo) && Tags.EDITOR_BLOCK.HasTag(hitInfo.collider)) { return(RootGameObject.GetRoot(hitInfo.collider.gameObject).transform.parent == null); } else { return(false); } }
public bool CanActivate() { // Note, we never return true, but do stuff anyway... if (Input.GetButtonDown(SelectionButton) && !EventSystem.current.IsPointerOverGameObject()) { Camera camera = CameraExtensions.FindCameraUnderMouse(); Ray ray = camera.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (!Physics.Raycast(ray, out hitInfo)) { return(false); } GameObject newSelection = RootGameObject.GetRoot(hitInfo.collider.gameObject); if (Tags.EDITOR_BLOCK.HasTag(newSelection)) { SelectionManager.Selection = newSelection; } } return(false); }