|
@@ -55,6 +55,7 @@ namespace GFGGame
|
|
|
_ui.m_btnBg.onClick.Add(OnClickBtnBg);
|
|
|
_ui.m_btnChoose.onClick.Add(OnClickBtnChoose);
|
|
|
_ui.m_btnBack.onClick.Add(OnClickBtnBack);
|
|
|
+ _ui.m_btnPhotograph.onClick.Add(OnClickBtnPhotograph);
|
|
|
|
|
|
_ui.m_ComSelectRes.m_list.itemRenderer = RenderListItem;
|
|
|
_ui.m_ComSelectRes.m_list.onClickItem.Add(OnListItemClick);
|
|
@@ -263,14 +264,19 @@ namespace GFGGame
|
|
|
|
|
|
private void OnClickBtnSizeBegin(EventContext context)
|
|
|
{
|
|
|
+ GameObject gameObject = _ui.m_comSelectBox.target.data as GameObject;
|
|
|
InputEvent inputEvent = (InputEvent)context.data;
|
|
|
- // Vector2 size = _ui.m_comSelectBox.m_imgBox.size;
|
|
|
+
|
|
|
Vector2 pt1 = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y));
|
|
|
- Vector2 pt2 = this.viewCom.GlobalToLocal(new Vector2(_ui.m_comSelectBox.target.x, _ui.m_comSelectBox.target.y));
|
|
|
+ Vector2 screenPos = _ui.m_comSelectBox.target.LocalToGlobal(Vector2.zero);
|
|
|
+ Vector2 pt2 = screenPos;// this.viewCom.GlobalToLocal(new Vector2(_ui.m_comSelectBox.target.x, _ui.m_comSelectBox.target.y));
|
|
|
float dist = Vector2.Distance(pt1, pt2);
|
|
|
-
|
|
|
- _startDistance = dist / _ui.m_comSelectBox.target.scaleX;// Mathf.Sqrt(size.x * size.x + size.y * size.y) / 2;// Vector2.Distance(pt1, pt2);
|
|
|
- Debug.Log("_startDistance:" + _startDistance);
|
|
|
+ _startDistance = dist;/// gameObject.transform.localScale.x;
|
|
|
+ // Vector2 screenPos = _ui.m_comSelectBox.target.LocalToGlobal(Vector2.zero);
|
|
|
+ // Vector2 posInB = new Vector2(_ui.m_comSelectBox.m_btnSize.x, _ui.m_comSelectBox.m_btnSize.y);
|
|
|
+ // Vector2 pt1 = screenPos;// this.viewCom.GlobalToLocal(screenPos); ;
|
|
|
+ // _startDistance = Mathf.Sqrt(pt1.x * pt1.x + pt1.y * pt1.y) / 2;// Vector2.Distance(pt1, pt2);
|
|
|
+ Debug.Log(" _startDistance:" + _startDistance + " pt1:" + pt1 + " screenPos:" + screenPos);
|
|
|
}
|
|
|
private void OnClickBtnSizeMove(EventContext context)
|
|
|
{
|
|
@@ -415,6 +421,26 @@ namespace GFGGame
|
|
|
_ui.m_comSelectBox.target.visible = false;
|
|
|
hitParentGameObj = null;
|
|
|
}
|
|
|
+ private void OnClickBtnPhotograph()
|
|
|
+ {
|
|
|
+ _ui.target.visible = false;
|
|
|
+ Timers.inst.StartCoroutine(ScreenShotTex());// ();
|
|
|
+ }
|
|
|
+ private IEnumerator ScreenShotTex()
|
|
|
+ {
|
|
|
+ _ui.target.visible = false;
|
|
|
+ yield return new WaitForEndOfFrame();
|
|
|
+ // Texture2D tex = UnityEngine.ScreenCapture.CaptureScreenshotAsTexture();
|
|
|
+ Rect rect = new Rect(0, 0, UnityEngine.Screen.width, UnityEngine.Screen.height);
|
|
|
+ Texture2D tex = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.ARGB32, false);//新建一个Texture2D对象
|
|
|
+ tex.ReadPixels(rect, 0, 0);//读取像素,屏幕左下角为0点
|
|
|
+ tex.Apply();//保存像素信息
|
|
|
+
|
|
|
+ ViewManager.Show<PhotographSaveView>(tex);
|
|
|
+ _ui.target.visible = true;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void OnClickBtnBack()
|
|
|
{
|
|
|
this.Hide();
|