[英]Unity3d attach texture to the cube problems
I have created a cube in the scene and I want to attach the texture to the cube by scripting. 我在场景中创建了一个立方体,我想通过脚本将纹理附加到立方体。 The problem is there is no error of my code but The cube doesn't change after I press run in my program... 问题是我的代码没有错误,但是在我的程序中按Run键后,多维数据集没有更改...
Here is my code 这是我的代码
using UnityEngine;
using System.Collections;
public class testing : MonoBehaviour {
void start(){
Texture2D tex = (Texture2D)Resources.Load("BlueColorTex.png", typeof(Texture2D));
renderer.material.mainTexture = tex;
}
}
void start()
{
Texture2D tex = (Texture2D)Resources.Load("BlueColorTex", typeof(Texture2D));
renderer.material.mainTexture = tex;
}
Resources.Load does not use extensions. Resources.Load不使用扩展。 This is a common mistake. 这是一个常见的错误。
Returns the asset at path if it can be found otherwise returns null. 如果可以找到,则返回路径处的资产,否则返回null。 Only objects of type T will be returned. 仅返回类型T的对象。 The path is relative to any Resources folder inside the Assets folder of your project, extensions must be omitted. 该路径相对于项目的Assets文件夹内的任何Resources文件夹, 必须省略扩展名。
from: http://docs.unity3d.com/ScriptReference/Resources.Load.html 来自: http : //docs.unity3d.com/ScriptReference/Resources.Load.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.