2019年5月28日 星期二

Week15 +1 notes

一個題目板可以秀圖片,放入三個圖片,圖片一秒會換下一張
  1. 增加cube
  2. 增加material
  3. shader改成specular
  4. 照片拉到material右邊正方形框
  5. 把程式拉給cube
  6. 再把下面做好的material放入程式底下



using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class chagneMatQuck : MonoBehaviour
{
    public Material one;
    public Material two;
    public Material three;
    
    // 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 = one;
            if(now==1) thisRend.material = two;
            if(now==2) thisRend.material = three;
        }        
        frameN++;
    }
}

沒有留言:

張貼留言