- 最后登录
- 2017-5-15
- 注册时间
- 2012-3-1
- 阅读权限
- 90
- 积分
- 32973
  
- 纳金币
- 32806
- 精华
- 12
|
如题,具体情况就是我想在某个事件之后,屏幕画面整体变暗,直到全黑。
不知道通过哪个函数或者方法或者类来实现。
本来我想的是建立一个Plane,用它的Material的Alpha值来作为一个遮罩。
但是有个疑问:
我用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
实在是不理解为什么会有这个错误。。。
请解惑,告知我实现这个的方式。
另外请告诉我正确使用Material.color.a的方法,不甚感激。。是不是我用的不对或者在用之前要做什么前置工作。
附上脚本代码:
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 ()
{
}
}
之前一直在写XNA,这次初次接触Unity3d,请详细点说,谢谢,再次感谢。
|
|