当前位置: 首页>>代码示例>>C#>>正文


C# Settings.setRotation方法代码示例

本文整理汇总了C#中Settings.setRotation方法的典型用法代码示例。如果您正苦于以下问题:C# Settings.setRotation方法的具体用法?C# Settings.setRotation怎么用?C# Settings.setRotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Settings的用法示例。


在下文中一共展示了Settings.setRotation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

    // Update is called once per frame
    void Update()
    {
        Camera cam = gameObject.GetComponent<Camera> ();
        GameObject plane = GameObject.Find ("Root");

        if(!loaded)
        {
            loaded = true;

            SettingsLoader loader = new SettingsLoader();
            Settings settings = loader.Load();
            if(settings != null)
            {
                cam.fieldOfView = settings.cameraFOV;
                gameObject.transform.position = settings.getPosition();
                Quaternion rot = new Quaternion();

                rot.eulerAngles = settings.getRotation();

                plane.transform.rotation = rot;
            }
            else{

                Debug.Log ("Loading failed");
            }

        }

        if (Input.GetButton ("PS4_PS")) {
            Application.Quit();
        }

        if (Input.GetButton ("PS4_Square")) {
            if (!squarePressed) {
                squarePressed = true;

                SettingsLoader loader = new SettingsLoader();
                Settings settings = new Settings();
                settings.cameraFOV = cam.fieldOfView;
                settings.setPosition(gameObject.transform.position);
                settings.setRotation(plane.transform.rotation.eulerAngles);

                loader.Save(settings);
            }
        } else {
            squarePressed = false;
        }

        // Depth of field.
        float dpadX = Input.GetAxis ("PS4_DPadX");
        cam.fieldOfView += dpadX;

        // Translate camera.
        float leftX = Input.GetAxis ("PS4_LeftStickX");
        float leftY = Input.GetAxis ("PS4_LeftStickY");

        // Zoom camera.
        float l2 = Input.GetAxis ("PS4_L2");
        float r2 = Input.GetAxis ("PS4_R2");

        // Rot camera.
        float rightX = Input.GetAxis ("PS4_RightStickX");
        float rightY = Input.GetAxis ("PS4_RightStickY");
        //		Debug.LogFormat ("{0} {1}", rightX, rightY);

        float dz = 0;
        // L2 pressed
        if (l2 > 0) {
            dz+=l2;
        }

        if (r2 > 0) {
            dz -= r2;
        }

        Vector3 newPos = gameObject.transform.position;
        newPos.x += leftX;
        newPos.y +=dz;
        newPos.z -= leftY;
        gameObject.transform.position = newPos;

        Quaternion newPlaneRot = plane.transform.rotation;
        Vector3 angles = plane.transform.rotation.eulerAngles;
        angles.x += (rightY*2.0f);
        angles.z += (rightX*2.0f);
        // HACK
        if(angles.x == 90)
        {
            angles.x+=1;
        }
        newPlaneRot.eulerAngles = angles;
        plane.transform.rotation = newPlaneRot;

        //		at.x += rightX;
        //		at.z += rightY;
        //		gameObject.transform.LookAt (at);
        //
        //		if (rightX!=0f || rightY!=0f) {
        //			Vector3 newRot = gameObject.transform.rotation.eulerAngles;
//.........这里部分代码省略.........
开发者ID:sdetwiler,项目名称:spiders,代码行数:101,代码来源:InputController.cs


注:本文中的Settings.setRotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。