2

コールバックは起動されず、何が問題なのかわかりません。私は 5 ドルのサンプルパックを購入しましたが、私が知る限り、彼らのパターンに正しく従っています. 私はこれを以前にうまく使ったことがあります。

したがって、このクラスの下では、特定のボタンが押されているか、選択解除されています。この場合、選択したトゥイーンを具体的にデバッグしていますが、どちらも正しく機能しません。InstantSelectionSpritesUp() 関数は正常に動作し、手動で到達して色のアルファを 1 に戻します。これは正常に動作するので、コメントアウトしてトゥイーンを試しています。トゥイーンが機能しません。Debug.Log を介して、SetAsSelected() と FadeSelectionSpritesUp() が実際に呼び出されていることがわかります。ただし、コンソールにログが出力されないため、UpdateIconAlpha() と UpdateBGAlpha は呼び出されません。StopTweens() があるのは、同じゲームオブジェクトで新しいトゥイーンを呼び出すときに、iTween が既存のトゥイーンを自動的に破棄しないためです。これをコメントアウトしましたが、何も変わらないので、それは問題ではありません。これ'

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 OpenSourceRebellion.com

4

0 に答える 0