但是有个疑问:
我用C#在Script里面,使用 XXX(某个给定的Transform).renderer.material.color.a = 某数值 的语句的时候(测试的时候是写在Start()方法里),总有错误跳出来说:
error CS1612: Cannot modify a value type return value of `UnityEngine.Material.color'. Consider storing the value in a temporary variable
实在是不理解为什么会有这个错误。。。
附上脚本代码:
using UnityEngine;
using System.Collections;
public class script_FromS0toS1 : MonoBehaviour
{
// 在Unity3d中给定一个Transform
public Transform theMask;
// Use this for initialization
void Start ()
{
isNext = false;
theMask.renderer.material.color = Color.black;
theMask.renderer.material.color.a = 0.5f; //这句产生了错误,这句我原本想实现的是半透明。。
}
// Update is called once per frame
void Update ()
{
}
}