我在TextureInfo里面有一个纹理列表。我想在列表中添加一个纹理,如下面的示例所示。
[System.Serializable]
public class TextureInfo
{
public List<Texture> textures = new List<Texture>();
}
public List<TextureInfo> texInfo = new List<TextureInfo>();
public Texture texture;
public void Start(){
texInfo.textures.Add(new TextureInfo {textures.Add(texture)}); //How do I add one row to texInfo and then one row to textures?
}问题是我不知道如何添加到序列化列表中。
发布于 2022-07-06 12:50:04
我只想把一字一句留在这个场合,然后像这样把它修好。
[System.Serializable]
public class TextureInfo
{
public List<Texture> textures = new List<Texture>();
}
public List<TextureInfo> texInfo = new List<TextureInfo>();
public Texture texture;
public void Start()
{
var variableName = new TextureInfo();
variableName.textures.Add(texture);
texInfo.Add(variableName);
}发布于 2022-07-06 12:50:52
TextureInfo tinfo = new TextureInfo(); //Create new texture info
tinfo.textures.Add(texture); // Add texture to the list of textures in texture info
texInfo.Add(tinfo); // add texture info to the texture info listhttps://stackoverflow.com/questions/72883744
复制相似问题