得続ける:私はエラーCS0029
CS0029 Cannot implicitly convert type
UnityEngine.Renderer[]
toSystem.Collections.Generic.List<UnityEngine.Renderer>
コードがあるの:
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
public class AssignShadersToChildren : MonoBehaviour
{
private new GameObject renderer;
public Shader shader; // This should hold the Shader you want to use
void Start()
{
// We create a list that will hold all the renderers(objects)
// so we can then assign the shader
List<Renderer> renderers = new List<Renderer>();
renderers = GetComponentsInChildren<Renderer>();
// For every Renderer in the list assign the materials shader to the shader
foreach (Renderer r in renderers)
{
r.material.shader = shader;
}
}
}
方法 'GetComponentsInChildren'はおそらく'レンダラ[] 'の代わりに' '一覧 –
そのエラーに問題が何であるの戻っていますか?あなたはタイプが間違っています。また、スローアウェイリストを作成します。 'renderers'の型を正しいものに変更し、リストの作成を削除してください。 –