我想更改游戏对象列表的纹理包裹模式。我能想到的简单算法: - gameObjects的名单 - 为每个gameObject,gameObject.texturewrapmode = repot
但我不能这样做。
我希望我理解问题是正确的。如果您有一个由GameObject
S组成的List<GameObject>
列表(显然),则可以通过代码设置其WrapMode
,例如:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class txWrap : MonoBehaviour
{
public List<GameObject> myGameObjects;
// Use this for initialization
void Awake ()
{
/*
* IMPORTANT: if you use those textures' wrap mode ever again,
* ESPECIALLY during runtime, use similar method to get the components to
* another List, with the generic type of List<Texture>.
* GetComponent is slow and prone to error, use it runtime as few as possible.
*/
foreach(var item in myGameObjects)
{
item.GetComponent<Texture>().wrapMode = TextureWrapMode.Repeat;
}
}
}
现在,如果您是编码的新手,则可能需要搜索关键字generic
,foreach
,enum
。如果您知道这些,很抱歉宣讲:)