void Update() { if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit) && hit.transform.tag == "Cell") { CellClickHandler handler = hit.transform.GetComponent <CellClickHandler>(); if (Input.GetMouseButtonDown(0)) { handler.LeftClick(); } else { handler.RightClick(); } } } if (Input.GetMouseButton(2)) { Camera.main.GetComponent <CameraController>().Rotate(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")); } if (Input.GetAxis("Mouse ScrollWheel") != 0f) { Camera.main.GetComponent <CameraController>().Scroll(Input.GetAxis("Mouse ScrollWheel")); } }
public override void RegisterCellClickHandler(CellClickHandler newClickHandler) { OnCellClick += newClickHandler; }
/// <summary> /// 添加选择、反选事件 /// </summary> /// <param name="handler"></param> public void addClickEventHandler(CellClickHandler handler) { this._onCellSelected += handler; if ( !this._isAddedClickHander ) { this._isAddedClickHander = true; UIEventListener.Get(this.gameObject).onClick += this.onCellClick; } }
/// <summary> /// 移除选择、反选事件 /// </summary> /// <param name="handler"></param> public void removeClickEventHandler(CellClickHandler handler) { this._onCellSelected -= handler; if ( this._isAddedClickHander ) { this._isAddedClickHander = false; UIEventListener.Get(this.gameObject).onClick -= this.onCellClick; } }
public abstract void RegisterCellClickHandler(CellClickHandler newClickHandler);