Chinaunix首页 | 论坛 | 博客
  • 博客访问: 75132
  • 博文数量: 48
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 340
  • 用 户 组: 普通用户
  • 注册时间: 2013-12-30 14:22
文章分类

全部博文(48)

文章存档

2014年(47)

2013年(1)

我的朋友

分类: IT业界

2014-03-18 11:04:43

天空变换代码

个人作法:

1、建立一个 camera , GameObject-->Create other-->camera

2、於camera建立一个 skybox component-->Rendering-->skybox

3、於main camera 也建立一个skybox

4、分别拉天空白天与黄昏材质球於cameramain cameraskybox

5、拉scriptmain camera , 再拉camera 物件於cammer

即可切换

以下是c# script 程式码

using UnityEngine;

using System.Collections;

public class changesky : MonoBehaviour {

//宣告GameObject物件

public GameObject cammer;

private int sky = 0;

// Use this for initialization

void Start () {

}

// Update is called once per frame

void Update()

{

if (Input.GetKeyDown(KeyCode.A))

{

sky++;

if (sky == 1)

{

cammer.SetActiveRecursively(false);

}

else if (sky == 2)

{

cammer.SetActiveRecursively(true);

}

if (sky == 3)

{

sky = 0;

}

}

}

}

阅读(232) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~