Unity,C#和iTween

时间:2017-04-24 14:50:50

标签: c# unity3d itween

我有一个脚本,当你点击它时会使对象旋转。我想看看将iTween添加到它会改善动作,但我应该在哪里添加它?

iTween代码:

iTween.RotateBy(gameObject, iTween.Hash("x", .25, "easeType", "easeInOutBack", "loopType", "pingPong", "delay", .4));

脚本:

using UnityEngine;
using System.Collections;

public class rotate : MonoBehaviour {

    public float minX = -360.0f;
    public float maxX = 360.0f;

    public float minY = -3660.0f;
    public float maxY = 360.0f;

    public float sensX = 500.0f;
    public float sensY = 500.0f;

    float rotationY = 0.0f;
    float rotationX = 0.0f;

    void Update () {

        if (Input.GetMouseButton (0)) {
            rotationX += Input.GetAxis ("Mouse X") * sensX * Time.deltaTime;
            rotationY += Input.GetAxis ("Mouse Y") * sensY * Time.deltaTime;
            rotationY = Mathf.Clamp (rotationY, minY, maxY);
            transform.localEulerAngles = new Vector3 (rotationY, -rotationX, 0);
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您的意思是您希望替换现有的轮换代码以使用这样的iTween功能吗?

getDuration()