コード例 #1
0
ファイル: FeedbackPaletteBlock.cs プロジェクト: xenrik/blocks
    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);
    }
コード例 #2
0
    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);
    }
コード例 #3
0
    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);
    }
コード例 #4
0
    // 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);
        }
    }
コード例 #5
0
    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);
    }