| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class CrossHair : MonoBehaviour
- {
- public static CrossHair ins;
- private Image image = null;
- private bool open = false;
- private bool visiable = false;
- void Awake()
- {
- ins = this;
- }
- void Start()
- {
- this.image = this.GetComponent<Image>();
- this.open = LoginMgr.myUserInfo.openCrossHair;
- this.visiable = this.image.enabled;
- this.SetVisiable(false);
- }
- void Update()
- {
- if (open) SetVisiable(ArmBow.ins && ArmBow.ins.NeedCrossHair());
- }
- void SetVisiable(bool value)
- {
- if (this.visiable == value) return;
- this.visiable = value;
- this.GetComponent<Image>().enabled = this.visiable;
- }
- public RaycastHit GetRaycastHit() {
- float maxDistance = 100;
- int layerMask = 1 << 8;
- RaycastHit hit;
- Ray ray = Camera.main.ScreenPointToRay(this.transform.position, Camera.MonoOrStereoscopicEye.Mono);
- bool raycastResult = Physics.Raycast(ray.origin, ray.direction, out hit, maxDistance, layerMask);
- // if (raycastResult) return hit.point;
- return hit;
- }
- }
|