コード例 #1
0
    void UpdateInputs()
    {
#if UNITY_STANDALONE_WIN
        input = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        mX    = Input.GetAxisRaw("Mouse X");
        float mMag = Mathf.Sqrt(mX * mX + mY * mY);
        mY = Input.GetAxisRaw("Mouse Y");
        if (mMag > 5)
        {
            mX = 0;
            mY = 0;
        }
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit raycastHit;
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out raycastHit, 3f, 1 << LayerMask.NameToLayer("Cube")))
            {
                FPSDisplay.PutMessage("Hit", true);
                holdObject = raycastHit.collider.gameObject.GetComponent <PickUp>();
                HoldObject(holdObject);
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            ReleaseHoldObject();
        }
#endif
#if UNITY_ANDROID
        mX    = 0;
        mY    = 0;
        input = new Vector2(variableJoystick.Horizontal, variableJoystick.Vertical);
        foreach (Touch touch in Input.touches)
        {
            FPSDisplay.PutMessage(touch.phase.ToString() + touch.deltaPosition, true);
            if (touch.phase == TouchPhase.Began)
            {
                RaycastHit raycastHit;
                Ray        ray = Camera.main.ScreenPointToRay(touch.position);
                if (Physics.Raycast(ray, out raycastHit, 3f, 1 << LayerMask.NameToLayer("Cube")))
                {
                    FPSDisplay.PutMessage("Hit", true);
                    holdObject = raycastHit.collider.gameObject.GetComponent <PickUp>();
                    HoldObject(holdObject);
                }
                else
                {
                    FPSDisplay.PutMessage("NotHit", true);
                }
            }
            else if (touch.phase == TouchPhase.Moved && touch.position.x > Screen.width / 2)
            {
                // Construct a ray from the current touch coordinates
                mX += touch.deltaPosition.x / Screen.width * 100;
                mY += touch.deltaPosition.y / Screen.height * 100;
            }
        }
#endif
        jumpButton = Input.GetButton("Jump");
    }
コード例 #2
0
    void OnPreCull()
    {
        for (int i = 0; i < portals.Length; i++)
        {
            portals[i].PrePortalRender();
        }
        bool[] vis = new bool[portals.Length];
        Portal.renderCount = 0;
        for (int i = 0; i < portals.Length; i++)
        {
            Portal curPortal = portals[i];
            if (curPortal.enabled == true)
            {
                if (!curPortal.Judge(playerCam, curPortal.recursionLimit))
                {
                    vis[i] = false;
                    continue;
                }
                else
                {
                    vis[i] = true;
                }

                curPortal.Render(playerCam, curPortal.recursionLimit);
            }
        }
        FPSDisplay.PutMessage("renderCount:" + Portal.renderCount, false);
        for (int i = 0; i < portals.Length; i++)
        {
            if (!vis[i])
            {
                continue;
            }
            Portal curPortal = portals[i];
            curPortal.SetViewTexture();
        }
        for (int i = 0; i < portals.Length; i++)
        {
            if (!vis[i])
            {
                continue;
            }
            Portal curPortal = portals[i];
            curPortal.ReleaseViewTexture();
        }
        for (int i = 0; i < portals.Length; i++)
        {
            portals[i].PostPortalRender();
        }
    }