2017-02-25 6 views
0

GameObjectのリストのテクスチャラップモードを変更したいと思います。私は考えることができます 単純なアルゴリズム:ゲームオブジェクト の --list --for各ゲームオブジェクト、GameObject.texturewrapMode =繰り返しゲームオブジェクトのテクスチャリストのWrapModeを設定する

しかし、私は私を助けてくださいことをやる傾けます。

+0

あなたは 'GameObject'sの束を持っていて、初期化としてあなたはラップモードを同じにしたいと思います。 1? 'C#'コードを囲むことができますか? – agiro

答えて

0

私はこの問題を正しく理解することを願っています。あなたは(当然)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 Googleにしたいかもしれません、 foreach,enum。あなたがそれらを知っていたら、説教のためにごめんなさい: