-期末作品進度#6(隨機題目)-
隨機題目
- 加入一個cube板子當題目板
- 新增material(題目圖片)
- 程式放入cube
程式碼 ( 原版 _ 每秒會換一張 )
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class chagneMatQuck : MonoBehaviour
{
public Material mat1;
public Material mat2;
public Material mat3;
// Start is called before the first frame update
void Start()
{
}
int frameN=0;
// Update is called once per frame
void Update()
{
if(frameN%60==0){
int now= (int)(frameN/60)%3;
Renderer thisRend = GetComponent<Renderer>();
if(now==0) thisRend.material = mat1;
if(now==1) thisRend.material = mat2;
if(now==2) thisRend.material = mat3;
}
frameN++;
}
}
程式碼 ( 新版 _ 一次換一張 )
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class cvb : MonoBehaviour
{
public Material mat1;
public Material mat2;
public Material mat3;
// Start is called before the first frame update
void Start()
{
int now= Random.Range(0,3);
Renderer thisRend = GetComponent<Renderer>();
if(now==0) thisRend.material = mat1;
if(now==1) thisRend.material = mat2;
if(now==2) thisRend.material = mat3;
}
//int frameN=0;
// Update is called once per frame
void Update()
{
}
}
沒有留言:
張貼留言