如何通过触发器将对象的纹理更改为新纹理

时间:2017-05-01 12:10:22

标签: javascript unity3d

我在游戏中有一个触发器,想要在玩家进入某个区域时更改纹理。我已经设置了触发器,但无法更改waal(对象)的图像?

以下是我正在使用的代码:

var Wall1: GameObject; \\Existing Game Object
var wall1TC: Texture; \\Texture to change Existing Game Object to.


  function OnTriggerEnter() {

     GetComponent.<Renderer>().material.mainTexture = Resources.Load("Wall_New_Texture", Texture);

  }

不确定我在这里做错了什么?

有人可以帮忙吗?

由于

1 个答案:

答案 0 :(得分:2)

以下是更改墙面材质纹理的代码 -

var Wall1: GameObject; \\Existing Game Object
var wall1TC: Texture; \\Texture to change Existing Game Object to.

function OnTriggerEnter() {

    Wall1.GetComponent.<Renderer>().material.mainTexture = wall1TC;

}
相关问题