【问题标题】:Some build error in my Lock-on System code我的锁定系统代码中有一些构建错误
【发布时间】:2014-05-14 17:49:55
【问题描述】:
public var Locked : Texture;
public var Locking : Texture;
var cam : Camera;
public var trans : Transform;

function Start() {
    trans = trasform;
}

function Update() {
    if(enemyAI.Locked > 0 ) {
    guiTexture.texture = enabled;   //build error -> cannot convert 'boolean' to 'UnityEngine.Texture'. (BCE0022)
    guiTexture.texture = Locked;
    transform.position = cam.WorldToViewportPoint(enemyAI.Locked.position);
}
    if(enemyAI.Locking > 0 ) {
    guitexture.texture = enabled;   //equal error 
    guiTexture.texture = Locking;
    transform.position = cam.WorldToViewportPoint(enemyAI.Locking.position);
}
    else
    guiTexture.texture = false;    //equal error
}

在enemyAI.js 中,如果敌人进入Lock-on Range,则更改标签和Locked 会增加每个敌人。锁定整数后 3 秒 = 锁定。如果敌人离开锁定范围,锁定--

如何修复此代码?当目标在我想要的代码指定的范围内时..

【问题讨论】:

    标签: unity3d unityscript


    【解决方案1】:

    您似乎正在寻找的是enabledGUITExture 成员。这是一个可以设置的布尔值。

    所以你会替换你的

    guiTexture.texture = enabled;
    

    guiTexture.enabled = true;
    

    这应该可以完成工作。

    【讨论】:

    • 太棒了。很高兴这有帮助。只要确保始终参考文档即可。这将有很大帮助。 ;)
    • @Bart +1 非常好,我看到了..最近你在 Unity3D 上添加了一些很棒的东西,我们感谢你的努力。
    • 感谢@RDC。你真是太好了。
    • @Bart 是的!顺便说一句.. 恭喜您获得 10k,因为我们相信它将为您提供更多 SO 工具的功能。所以你可以做得更好。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-18
    • 2022-10-12
    • 1970-01-01
    • 2019-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多