2016年4月8日 星期五

滑鼠點擊/滑進/滑出物件

程式碼如下:

using UnityEngine;
using System.Collections;

public class objClick MonoBehaviour
{
    void OnMouseEnter()
    {//滑鼠滑進後,物件顏色改變為紅色
        GetComponent<Renderer>().material.color = Color.red;
    }
    void OnMouseDown()
    {//滑鼠點擊後,出現物件名稱+被點擊
        Debug.Log(name.ToString() + "被點擊");
    }

    void OnMouseExit()
    {//滑鼠滑出後,物件顏色改變為白色
        GetComponent<Renderer>().material.color = Color.white;
    }
}

沒有留言:

張貼留言

.htaccess應用

去除WWW RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.com $ [ NC ] RewriteRule ^(.*) $ https: / /example.com/ $1 [ R = 301...