2019年5月28日 星期二

逸臻的筆記Week15-期末作品進度#6(隨機題目)

-期末作品進度#6(隨機題目)-


隨機題目


  1. 加入一個cube板子當題目板
  2. 新增material(題目圖片)
  3. 程式放入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()
    {

    }
}




沒有留言:

張貼留言