Unity3D 5.0+;iTween+;NGUI::使用iTween.ValueTo时遇到问题

Unity3D 5.0+;iTween+;NGUI::使用iTween.ValueTo时遇到问题,unity3d,itween,Unity3d,Itween,电话回访没有被取消,看不出有什么问题,我买了5美元一包的样品,据我所知,我正在正确地遵循他们的模式。我以前成功地使用过这个 所以在下面的这个类中,一个特定的按钮要么被按下,要么被取消选择。在本例中,我专门调试所选的tween,但两者都不能正常工作。InstantSelectionSpritesUp()函数工作正常,它手动进入并将alpha颜色设置为1。这个很好用,所以我已经把它注释掉了,现在我正在试着用tween。这孩子不管用。通过Debug.Log,我知道SetAsSelected()和Fad

电话回访没有被取消,看不出有什么问题,我买了5美元一包的样品,据我所知,我正在正确地遵循他们的模式。我以前成功地使用过这个

所以在下面的这个类中,一个特定的按钮要么被按下,要么被取消选择。在本例中,我专门调试所选的tween,但两者都不能正常工作。InstantSelectionSpritesUp()函数工作正常,它手动进入并将alpha颜色设置为1。这个很好用,所以我已经把它注释掉了,现在我正在试着用tween。这孩子不管用。通过Debug.Log,我知道SetAsSelected()和FadeSelectionSpritesUp()实际上正在被调用。但是,不会调用UpdateCinalpha()和UpdateBGAlpha,因为没有向控制台打印日志。StopTween()之所以存在,是因为当你在同一个游戏对象上调用新的Tween时,它不会自动销毁预先存在的Tween。我已经对此进行了评论,没有任何变化,所以这不是问题所在。一定是我的电话格式有问题

public class NavigationButton : MonoBehaviour{
// this is the super class for all of the navigation buttons

public UISprite bgDeselected;
public UISprite bgSelected;
public UISprite iconDeselected;
public UISprite iconSelected;

protected bool isCurrentlySelected = false;
protected float fadeTime = 0.5f;
protected Color alphaZero = new Color( 1.0f, 1.0f, 1.0f, 0.0f );
protected Color alphaOne = new Color( 1.0f, 1.0f, 1.0f, 1.0f );

// ----------------------------------------------------------------------------------------------------------------------------

void Start()
{
    // make the selected state of the button zero instantly so the user doesn't see it at all on app load
    InstantSelectionSpritesDown();
}

// ----------------------------------------------------------------------------------------------------------------------------

public void SetAsSelected()
{
    Debug.Log ( this.gameObject.name + ":SetAsSelected()" );

    // this funcion is called because this button has been pressed
    // we want this button to now show as being selected
    FadeSelectionSpritesUp();
    //InstantSelectionSpritesUp();

    isCurrentlySelected = true;
}

public void SetAsDeselected()
{
    Debug.Log ( this.gameObject.name + ":SetAsDeselected()" );

    // this funcion is called because the button another button in the nav has been pressed
    // we want this button to now show as being not selected
    //FadeSelectionSpritesDown();
    InstantSelectionSpritesDown();

    isCurrentlySelected = false;
}

// ----------------------------------------------------------------------------------------------------------------------------

protected void FadeSelectionSpritesDown()
{
    Debug.Log ( this.gameObject.name + ":FadeSelectionSpritesDown() :: iconSelected.gameObject:"+iconSelected.gameObject+" :: bgSelected.gameObject:"+bgSelected.gameObject  );
    //StopTweens();??

    // this function fades the alpha of the BG and Icon sprites down to 0% alpha
    iTween.ValueTo( iconSelected.gameObject ,iTween.Hash( "from", 1.0f, "to", 0.0f, "time", fadeTime, "onUpdate", "UpdateIconAlpha"));
    iTween.ValueTo( bgSelected.gameObject ,iTween.Hash( "from", 1.0f, "to", 0.0f, "time", fadeTime, "onUpdate", "UpdateBGAlpha"));
}

protected void FadeSelectionSpritesUp()
{
    Debug.Log ( this.gameObject.name + ":FadeSelectionSpritesUp() :: iconSelected.gameObject:"+iconSelected.gameObject+" :: bgSelected.gameObject:"+bgSelected.gameObject  );
    StopTweens();

    // this function fades the alpha of the BG and Icon sprites up to 100%
    iTween.ValueTo( iconSelected.gameObject ,iTween.Hash( "from", 0.0f, "to", 1.0f, "time", fadeTime, "onUpdate", "UpdateIconAlpha"));
    iTween.ValueTo( bgSelected.gameObject ,iTween.Hash( "from", 0.0f, "to", 1.0f, "time", fadeTime, "onUpdate", "UpdateBGAlpha"));
}

// ----------------------------------------------------------------------------------------------------------------------------

protected void StopTweens()
{
    // iTween doesn't destroy tweens that are already going if a new tween is added to the same object, so we need to destroy existing tweens manually
    iTween.Stop(iconSelected.gameObject);
    iTween.Stop(bgSelected.gameObject);
}

protected void UpdateIconAlpha( float alphaAsFloat )
{
    Debug.Log ( this.gameObject.name + ":UpdateIconAlpha() :: alphaAsFloat:"+alphaAsFloat+" :: bgSelected.gameObject:"+iconSelected  );
    iconSelected.color = new Color( alphaOne.r, alphaOne.g, alphaOne.b, alphaAsFloat );
}

protected void UpdateBGAlpha( float alphaAsFloat )
{
    Debug.Log ( this.gameObject.name + ":UpdateBGAlpha() :: alphaAsFloat:"+alphaAsFloat+" :: bgSelected.gameObject:"+bgSelected  );
    bgSelected.color = new Color( alphaOne.r, alphaOne.g, alphaOne.b, alphaAsFloat );
}

// ----------------------------------------------------------------------------------------------------------------------------

protected void InstantSelectionSpritesDown()
{
    // this function instantly sets the alpha of the BG and Icon sprites to 0% alpha
    iconSelected.color = alphaZero;
    bgSelected.color = alphaZero;
}

protected void InstantSelectionSpritesUp()
{
    // this function instantly sets the alpha of the BG and Icon sprites to 100% alpha
    iconSelected.color = alphaOne;
    bgSelected.color = alphaOne;
}}
有什么想法吗

谢谢! 德拉

RebelFuture.com
OpenSourceRebevery.com

可能与Unity 5的兼容性有关。你看到iTween下载上的警告了吗?