public void Release() { foreach (IFeatureRenderer renderer in _renderers) { if (renderer == null) { continue; } renderer.Release(); } _renderers.Clear(); }
public void Capture(bool split) { Vector2 topLeft, bottomRight; Vector3[] data; topLeft.x = Mathf.Min(Target.GetComponentsInChildren <Node>().Where(x => x.tag == "Block").Min(x => x.GetWidthLimits().x), Target.GetComponentsInChildren <LineRenderer>().Min( x => { data = new Vector3[x.positionCount]; x.GetPositions(data); return(x.transform.position.x + data.Min(q => q.x)); })); topLeft.y = Target.GetComponentsInChildren <Transform>().Where(x => x.tag == "Block").Max(x => x.position.y); bottomRight.x = Mathf.Max(Target.GetComponentsInChildren <Node>().Where(x => x.tag == "Block").Max(x => x.GetWidthLimits().y), Target.GetComponentsInChildren <LineRenderer>().Max( x => { data = new Vector3[x.positionCount]; x.GetPositions(data); return(x.transform.position.x + data.Max(q => q.x)); })); bottomRight.y = Target.GetComponentsInChildren <Transform>().Where(x => x.tag == "Block").Min(x => x.position.y); if (!split) { float ratio = Screen.width / (float)Screen.height; float size = Mathf.Max((bottomRight.x - topLeft.x + Padding) / 2 / ratio, (topLeft.y - bottomRight.y + Padding) / 2); Camera.orthographicSize = size; Camera.rect = new Rect(0, 0, (bottomRight.x - topLeft.x + Padding) / (topLeft.y - bottomRight.y + Padding), 1); RendererList.Add((topLeft + bottomRight) / 2f); Camera.transform.position = (topLeft + bottomRight) / 2f; Camera.transform.position += Vector3.back; } else { Camera.rect = new Rect(0, 0, 1, 1); Camera.orthographicSize = 500; float height = Camera.orthographicSize; #if UNITY_EDITOR float width = Camera.orthographicSize / Screen.currentResolution.height * Screen.currentResolution.width; #else float width = Camera.orthographicSize / Screen.height * Screen.width; #endif var sPoint = topLeft + new Vector2(width - Padding, -height + Padding); Camera.transform.position = sPoint; RendererList.Clear(); do { do { //var g = new GameObject(Camera.transform.position.ToString()); //g.transform.position = transform.position; //GameObject.Instantiate(Camera.gameObject,Camera.transform.position, Quaternion.identity); RendererList.Add(transform.position); Camera.transform.Translate(new Vector2(0, -height * 2), Space.World); }while (Camera.transform.position.y + height - Padding > bottomRight.y); Camera.transform.position = new Vector2(Camera.transform.position.x + width * 2, sPoint.y); }while (Camera.transform.position.x - width + Padding < bottomRight.x); } filePath = GetScreenCapturePath(); }