public Connection(int leftButtonIndex, int leftButtonPairIndex, int rightButtonIndex, int rightButtonPairIndex, UnityEngine.UI.Extensions.UILineRenderer line) { this.leftButtonIndex = leftButtonIndex; this.leftButtonPairIndex = leftButtonPairIndex; this.rightButtonIndex = rightButtonIndex; this.rightButtonPairIndex = rightButtonPairIndex; this.line = line; }
static public int get_BezierSegmentsPerCurve(IntPtr l) { try { UnityEngine.UI.Extensions.UILineRenderer self = (UnityEngine.UI.Extensions.UILineRenderer)checkSelf(l); pushValue(l, self.BezierSegmentsPerCurve); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_Margin(IntPtr l) { try { UnityEngine.UI.Extensions.UILineRenderer self = (UnityEngine.UI.Extensions.UILineRenderer)checkSelf(l); pushValue(l, self.Margin); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int get_BezierMode(IntPtr l) { try { UnityEngine.UI.Extensions.UILineRenderer self = (UnityEngine.UI.Extensions.UILineRenderer)checkSelf(l); pushEnum(l, (int)self.BezierMode); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int constructor(IntPtr l) { try { UnityEngine.UI.Extensions.UILineRenderer o; o = new UnityEngine.UI.Extensions.UILineRenderer(); pushValue(l, o); return(1); } catch (Exception e) { return(error(l, e)); } }
//This constructor looks over-the-top, but all it is doing is saving the default points as split+on mode, // and then creating full+on by removing the stem down the middle from that point-list manually public UIBorder(UnityEngine.UI.Extensions.UILineRenderer lineRenderer) { this.lineRenderer = lineRenderer; splitPoints = lineRenderer.Points; fullPoints = new Vector2[5]; for (int i = 0; i < 4; i++) { fullPoints[i] = splitPoints[i]; } fullPoints[4] = new Vector2(0, .02f); _split = true; _on = true; }
static public int set_Margin(IntPtr l) { try { UnityEngine.UI.Extensions.UILineRenderer self = (UnityEngine.UI.Extensions.UILineRenderer)checkSelf(l); UnityEngine.Vector2 v; checkType(l, 2, out v); self.Margin = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_UseMargins(IntPtr l) { try { UnityEngine.UI.Extensions.UILineRenderer self = (UnityEngine.UI.Extensions.UILineRenderer)checkSelf(l); System.Boolean v; checkType(l, 2, out v); self.UseMargins = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_LineThickness(IntPtr l) { try { UnityEngine.UI.Extensions.UILineRenderer self = (UnityEngine.UI.Extensions.UILineRenderer)checkSelf(l); System.Single v; checkType(l, 2, out v); self.LineThickness = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_uvRect(IntPtr l) { try { UnityEngine.UI.Extensions.UILineRenderer self = (UnityEngine.UI.Extensions.UILineRenderer)checkSelf(l); UnityEngine.Rect v; checkValueType(l, 2, out v); self.uvRect = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_BezierSegmentsPerCurve(IntPtr l) { try { UnityEngine.UI.Extensions.UILineRenderer self = (UnityEngine.UI.Extensions.UILineRenderer)checkSelf(l); System.Int32 v; checkType(l, 2, out v); self.BezierSegmentsPerCurve = v; return(0); } catch (Exception e) { return(error(l, e)); } }
static public int set_BezierMode(IntPtr l) { try { UnityEngine.UI.Extensions.UILineRenderer self = (UnityEngine.UI.Extensions.UILineRenderer)checkSelf(l); UnityEngine.UI.Extensions.UILineRenderer.BezierType v; checkEnum(l, 2, out v); self.BezierMode = v; return(0); } catch (Exception e) { return(error(l, e)); } }
void OnSceneGUI() { UILineRenderer curveRenderer = target as UILineRenderer; if (!curveRenderer || curveRenderer.drivenExternally || curveRenderer.Points == null || curveRenderer.Points.Length < 2) { return; } var oldMatrix = Handles.matrix; var transform = curveRenderer.GetComponent <RectTransform>(); //Pivot must be 0,0 to edit //transform.pivot = Vector2.zero; Handles.matrix = transform.localToWorldMatrix; var sizeX = curveRenderer.rectTransform.rect.width; var sizeY = curveRenderer.rectTransform.rect.height; var offsetX = -curveRenderer.rectTransform.pivot.x * sizeX; var offsetY = -curveRenderer.rectTransform.pivot.y * sizeY; Vector2[] points = new Vector2[curveRenderer.Points.Length]; for (int i = 0; i < curveRenderer.Points.Length; i++) { points[i] = curveRenderer.Points[i]; } //Need to transform points to worldspace! when set to Relative if (curveRenderer.RelativeSize) { for (int i = 0; i < points.Length; i++) { points[i] = new Vector2(points[i].x * sizeX + offsetX, points[i].y * sizeY + offsetY); } } for (int i = 0; i < points.Length - 1; i += 2) { Handles.DrawLine(points[i], points[i + 1]); } for (int i = 0; i < points.Length; ++i) { using (var check = new EditorGUI.ChangeCheckScope()) { var p = Handles.PositionHandle(points[i], Quaternion.identity); if (check.changed) { Undo.RecordObject(curveRenderer, "Changed Curve Position"); if (curveRenderer.RelativeSize) { curveRenderer.Points[i] = new Vector2((p.x - offsetX) / sizeX, (p.y - offsetY) / sizeY); } else { curveRenderer.Points[i] = p; } curveRenderer.transform.gameObject.SetActive(false); curveRenderer.transform.gameObject.SetActive(true); } } } Handles.matrix = oldMatrix; }
void OptionButtonClicked(int buttonIndex, int pairIndex, int duality) { if (inConnectionButtonIndexes.Contains(buttonIndex)) { //Em conexão } else { if (selectedButtonIndex == -1) { selectedButtonIndex = buttonIndex; selectedButtonPairIndex = pairIndex; selectedButtonDuality = duality; allButons[buttonIndex].GetComponentInChildren <Image>().color = Color.red; } else { if (buttonIndex == selectedButtonIndex) { selectedButtonIndex = -1; selectedButtonPairIndex = -1; selectedButtonDuality = -1; allButons[buttonIndex].GetComponentInChildren <Image>().color = Color.white; } else if (selectedButtonDuality == duality) { allButons[selectedButtonIndex].GetComponentInChildren <Image>().color = Color.white; selectedButtonIndex = buttonIndex; selectedButtonPairIndex = pairIndex; selectedButtonDuality = duality; allButons[buttonIndex].GetComponentInChildren <Image>().color = Color.red; } else if (selectedButtonDuality != duality) { allButons[selectedButtonIndex].GetComponentInChildren <Image>().color = Color.yellow; allButons[buttonIndex].GetComponentInChildren <Image>().color = Color.yellow; inConnectionButtonIndexes.Add(selectedButtonIndex); inConnectionButtonIndexes.Add(buttonIndex); float leftX; float leftY; float rightX; float rightY; if (selectedButtonDuality == 0) { leftX = scrollListViewport.InverseTransformPoint(allButons[selectedButtonIndex].GetComponent <RectTransform>().position).x; rightX = scrollListViewport.InverseTransformPoint(allButons[buttonIndex].GetComponent <RectTransform>().position).x; leftX = leftX + allButons[selectedButtonIndex].GetComponent <RectTransform>().sizeDelta.x / 2 - 5; rightX = rightX - allButons[buttonIndex].GetComponent <RectTransform>().sizeDelta.x / 2 + 5; leftY = scrollListViewport.InverseTransformPoint(allButons[selectedButtonIndex].GetComponent <RectTransform>().position).y; rightY = scrollListViewport.InverseTransformPoint(allButons[buttonIndex].GetComponent <RectTransform>().position).y; } else { leftX = scrollListViewport.InverseTransformPoint(allButons[buttonIndex].GetComponent <RectTransform>().position).x; rightX = scrollListViewport.InverseTransformPoint(allButons[selectedButtonIndex].GetComponent <RectTransform>().position).x; leftX = leftX + allButons[buttonIndex].GetComponent <RectTransform>().sizeDelta.x / 2 - 5; rightX = rightX - allButons[selectedButtonIndex].GetComponent <RectTransform>().sizeDelta.x / 2 + 5; leftY = scrollListViewport.InverseTransformPoint(allButons[buttonIndex].GetComponent <RectTransform>().position).y; rightY = scrollListViewport.InverseTransformPoint(allButons[selectedButtonIndex].GetComponent <RectTransform>().position).y; } //create connection and line GameObject lineRenderer = (GameObject)Instantiate(lineRendererPrefab); lineRenderer.transform.SetParent(scrollListViewport, false); lineRenderer.transform.localScale = new Vector3(1, 1, 1); UnityEngine.UI.Extensions.UILineRenderer line = lineRenderer.GetComponent <UnityEngine.UI.Extensions.UILineRenderer>(); var leftPoint = new Vector2() { x = leftX, y = leftY }; var rightPoint = new Vector2() { x = rightX, y = rightY }; var pointList = new List <Vector2>(); pointList.Add(leftPoint); pointList.Add(rightPoint); line.Points = pointList.ToArray(); ParentPanel.SetAsLastSibling(); Connection connection; if (selectedButtonDuality == 0) { connection = new Connection(selectedButtonIndex, selectedButtonPairIndex, buttonIndex, pairIndex, line); } else { connection = new Connection(buttonIndex, pairIndex, selectedButtonIndex, selectedButtonPairIndex, line); } connections.Add(connection); selectedButtonIndex = -1; selectedButtonPairIndex = -1; selectedButtonDuality = -1; } } } }
private void Awake() { canvas = GetComponentInParent <RectTransform>().GetParentCanvas().GetComponent <RectTransform>(); rt = GetComponent <RectTransform>(); lr = GetComponent <UILineRenderer>(); }