このねこの絵の色を変えたくて以下のサイトを参考にしてみました。
スクリプトからの変更がうまくいきません。
this.gameObject.GetComponent<SpriteRenderer>().material.hue = Random.Range(0.0f, 1000.0f);
using System.Collections; using System.Collections.Generic; using UnityEngine; public class NewBehaviourScript : MonoBehaviour { void Start () { } void Update () { if(Input.touchCount > 0) { Touch t = Input.GetTouch(0); Vector2 worldPoint = Camera.main.ScreenToWorldPoint(t.position); if(t.phase == TouchPhase.Began) { RaycastHit2D hit = Physics2D.Raycast(worldPoint,Vector2.zero); if(hit) { if(hit.collider.gameObject == this.gameObject) { this.gameObject.GetComponent<SpriteRenderer>().material.hue = Random.Range(0.0f, 1000.0f); transform.position = new Vector3(Random.Range(0.0f, 4.0f) - 2.0f, Random.Range(0.0f, 8.0f) - 4.0f); } } } } } }
Assets/NewBehaviourScript.cs(27,63): error CS1061: Type `UnityEngine.Material' does not contain a definition for `hue' and no extension method `hue' of type `UnityEngine.Material' could be found. Are you missing an assembly reference?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。