###前提・実現したいこと
Unity5.5.2fでのソースからのオブジェクトのマテリアル変更です。参照はpublicを使うのでソースから指定する必要はありません。
自分でも調べてみましたが、全くもって分かりませんでした。C#初心者ですので、なるべくかみ砕いた説明をお願いします。
###発生している問題・エラーメッセージ
公式フォーラムを覗いても書き方が全く分かりません。一応JavaScriptでは書けました。
エラーメッセージ Assets/1st shape/aaaa.cs(10,20): error CS0118: `UnityEngine.Component.renderer' is a `property' but a `type' was expected Assets/1st shape/aaaa.cs(11,21): error CS0118: `UnityEngine.Component.renderer' is a `property' but a `type' was expected
###該当のソースコード
c#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class aaaa : MonoBehaviour { 6 public GameObject RED,BLUE; 7 public Material redshine,reddark,blueshine,bluedark; 8 // Use this for initialization 9 void Start () { 10 RED.GetComponent<renderer>().material= bluedark; 11 BLUE.GetComponent<renderer>().material= bluedark; 12 } 13 14 // Update is called once per frame 15 void Update () { 16 17 } 18} 19
###試したこと
RED.GetComponent~の部分をRED.renderer.materialに変えてもみましたが、どうやら古い書き方の上、エラーが増えてしまう始末でした。
###補足情報(言語/FW/ツール等のバージョンなど)
c#/Unity5.5.2f
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。