纳金网

标题: Unity3d渐隐效果的代码 [打印本页]

作者: 狂风大尉    时间: 2014-11-26 02:26
标题: Unity3d渐隐效果的代码

代码如下:
  1. using UnityEngine;
  2. using System.Collections;

  3. public class Dis : MonoBehaviour {

  4. private float AlphaValue = 1;
  5. private float time = 0;
  6. private bool state = false;
  7. // Use this for initialization
  8. void Start () {

  9. }

  10. // Update is called once per frame
  11. void Update () {
  12. time += Time.deltaTime;
  13. if(time >= 0.2f)
  14. {
  15. state = true;
  16. time = 0;
  17. }
  18. if(state)
  19. {
  20. AlphaValue -= 0.1f;
  21. state = false;
  22. }
  23. if(AlphaValue <= 0)
  24. {
  25. AlphaValue = 1;
  26. }

  27. GameObject.Find("Cube").renderer.material.color = new Color(0.5f,0.3f,1,AlphaValue);
  28. Debug.Log(AlphaValue);
  29. }
  30. }
复制代码

作者: hyui    时间: 2014-11-26 02:53
good to learn from
code !!
作者: may    时间: 2014-11-26 07:21
thanks, 不错的介绍
作者: oelongeo    时间: 2014-11-26 11:22
谢谢指导!  学习了 代码真实用
作者: Mr.Fair    时间: 2014-11-26 13:34

谢谢指导!  学习了 代码真实用
作者: seven11235    时间: 2014-11-26 16:02
update里面find,真是醉了····




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5