using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class TipShowX : BaseShow, IComparable { public int CompareTo(object obj) { TipShow another = obj as TipShow; return Vector3.Distance( CommonData.MainCamera.transform.position, ResetVector3_Y( another.transform.position) ) .CompareTo(Vector3.Distance( CommonData.MainCamera.transform.position, ResetVector3_Y(transform.position) )); } Vector3 ResetVector3_Y(Vector3 pos, float y = 0) { return new Vector3(pos.x, y, pos.z); } //public bool isplay; //void OnBecameVisible() //当物体进入相机视野 //{ // Debug.Log(gameObject.name + "In"); //} //void OnBecameInvisible() //当物体离开相机视野 //{ // Debug.Log(gameObject.name + "Out"); //} //void Update() //{ // Vector3 screenCenter = new Vector3(Screen.width / 2, Screen.height / 2, 0); // Vector3 objectPosition = CommonData.MainCamera.WorldToScreenPoint(transform.position); // if (objectPosition.x >= screenCenter.x && objectPosition.x <= screenCenter.x + Screen.width && // objectPosition.y >= screenCenter.y && objectPosition.y <= screenCenter.y + Screen.height) // { // Debug.Log(gameObject.name + "In"); // } //} }