【问题标题】:Unity C# Change pressed sprite from buttonUnity C#从按钮更改按下的精灵
【发布时间】:2015-11-01 19:05:07
【问题描述】:

当按钮被按下时如何改变按钮的精灵? 我已经改变了正常的精灵: gameObject.GetComponent().sprite = Resources.Load("MineScreenImages/" + Ge.player.ActiveDiggingTool.DiggingToolId.ToString ()+"Idle");

我已经尝试找到pressedSprite 或类似spriteState 的东西,但没有成功。

【问题讨论】:

  • gameObject.GetComponent().spriteState.pressedSprite = Resources.Load ("imagename/");没有工作对此感到有希望

标签: image button unity3d sprite


【解决方案1】:

试试这个

public Button bt;
public SpriteState st;

void Start () {
        bt.GetComponent<Image> ().sprite = newspr;
        st.pressedSprite = newspr1;
        bt.spriteState = st;
}   

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-09
    相关资源
    最近更新 更多