该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
using UnityEngine;
using System.Collections;
public class click : MonoBehaviour {
public float validTouchDistance = 200;
public string layerName;
public Texture2D rivers;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown (0)) {
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hitInfo;
if (Physics.Raycast (ray, out hitInfo, validTouchDistance)) {
GameObject gameObj = hitInfo.collider.gameObject;
Vector3 hitPoint = hitInfo.point;
Vector2 coo = new Vector2 (10 * hitPoint.x + 2816, -10 * hitPoint.z + 1024);
Vector4 terr = 255 * rivers.GetPixel (Mathf.RoundToInt (coo.x), Mathf.RoundToInt (coo.y));
print (gameObj.name + " " + coo.ToString () + " " + rivers.GetPixel (Mathf.RoundToInt (coo.x), Mathf.RoundToInt (coo.y)));
}
}
}
}
一张5632x2048的图,贴在56.32x20.48的平面上,只有两种颜色,filter mode是point,很清晰,但是输出结果却完全是凌乱的,一种是(1,1,1,1)另一种是(0.478,0.478,0.478,0.478),可是完全不按照两种颜色排布,出了什么错么