| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 | 
							- using System.Collections;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- using UnityEngine.UI;
 
- public class ShuiWeiIconCtrl : MonoBehaviour
 
- {
 
-     private RectTransform rect;
 
-     private Camera _camera;
 
-     
 
-     public ShuiWeiData _data;
 
-     private Text valueText;
 
-     private Button histroyButton;
 
-     
 
-     public Transform targetTransForm;
 
-     public void Init(ShuiWeiData data)
 
-     {
 
-         _camera = CameraManager.instance.mainCamera;
 
-         _data = data;
 
-         
 
-         rect = this.GetComponent<RectTransform>();
 
-         
 
-         rect.anchoredPosition = new Vector2(2000, 0);
 
-         
 
-         valueText = this.transform.Find("valueText").GetComponent<Text>();
 
-         valueText.text = $"{data.value} <size=12><color=FFFFFF>m</color></size>";
 
-         histroyButton = this.transform.Find("histroyButton").GetComponent<Button>();
 
-         histroyButton.onClick.RemoveAllListeners();
 
-         histroyButton.onClick.AddListener(() =>
 
-         {
 
-             GCJKLayer._Instance.ShowHistoryPanle(_data);
 
-         });
 
-     }
 
-     
 
-     void Update()
 
-     {
 
-         if (targetTransForm != null)
 
-         {
 
-             if (IsObjectInCameraView(targetTransForm, _camera))
 
-             {
 
-                 rect.transform.position=_camera.WorldToScreenPoint(targetTransForm.position);
 
-             }
 
-             else
 
-             {
 
-                 rect.transform.position = new Vector3(2000, 0, 0);
 
-             }
 
-         }
 
-     }
 
-     
 
-     bool IsObjectInCameraView(Transform objectTransform, Camera camera)
 
-     {
 
-         Vector3 objectScreenPosition = camera.WorldToScreenPoint(objectTransform.position);
 
-         return objectScreenPosition.z > 0 &&
 
-                objectScreenPosition.x > 0 &&
 
-                objectScreenPosition.x < Screen.width &&
 
-                objectScreenPosition.y > 0 &&
 
-                objectScreenPosition.y < Screen.height;
 
-     }
 
- }
 
 
  |