public GameObject AddLine(string name) { DD_CoordinateAxis coordinate = m_CoordinateAxis.GetComponent <DD_CoordinateAxis>(); if (coordinate.lineNum >= maxLineNum) { print("coordinate.lineNum > maxLineNum"); return(null); } if (coordinate.lineNum != lineButtonsContent.transform.childCount) { print("coordinate.lineNum != m_LineButtonList.Count"); } GameObject line = coordinate.AddLine(name); if (false == AddLineButton(line)) { if (false == coordinate.RemoveLine(line)) { print(this.ToString() + " AddLine error : false == coordinate.RemoveLine(line)"); } line = null; } return(line); }
private void Awake() { DD_CoordinateAxis coordinateAxis = transform.GetComponentInChildren <DD_CoordinateAxis>(); if (null == coordinateAxis) { m_CoordinateAxis = Instantiate((GameObject)Resources.Load("Prefabs/CoordinateAxis"), gameObject.transform); m_CoordinateAxis.name = "CoordinateAxis"; } else { m_CoordinateAxis = coordinateAxis.gameObject; } DD_LineButtonsContent tempObject = GetComponentInChildren <DD_LineButtonsContent>(); if (null == tempObject) { Debug.LogWarning(this + "Awake Error : null == lineButtonsContent"); return; } else { if (null == (lineButtonsContent = tempObject.gameObject)) { Debug.LogWarning(this + "Awake Error : null == lineButtonsContent"); return; } } }
protected override void Awake() { m_DataDiagram = GetComponentInParent <DD_DataDiagram>(); if (null == m_DataDiagram) { Debug.Log(this + "null == m_DataDiagram"); } m_Coordinate = GetComponentInParent <DD_CoordinateAxis>(); if (null == m_Coordinate) { Debug.Log(this + "null == m_Coordinate"); } GameObject parent = gameObject.transform.parent ? gameObject.transform.parent.gameObject : null; if (null == parent) { Debug.Log(this + "null == parent"); } RectTransform parentrt = parent ? parent.GetComponent <RectTransform>() : null; RectTransform localrt = gameObject.GetComponent <RectTransform>(); if ((null == localrt) || (null == parentrt)) { Debug.Log(this + "null == localrt || parentrt"); } //设置锚点为左下角 localrt.anchorMin = Vector2.zero; localrt.anchorMax = new Vector2(1, 1); //设置轴心为左下角 localrt.pivot = Vector2.zero; //设置轴心的坐标为坐标系区域的左下角 localrt.anchoredPosition = Vector2.zero; //设置平铺的margin为0 localrt.sizeDelta = Vector2.zero; if (null != m_Coordinate) { m_Coordinate.CoordinateRectChangeEvent += OnCoordinateRectChange; m_Coordinate.CoordinateScaleChangeEvent += OnCoordinateScaleChange; m_Coordinate.CoordinateeZeroPointChangeEvent += OnCoordinateZeroPointChange; } //m_ViewRect.Set(0, 0, m_Rect.width, m_Rect.height); }
public void InputPoint(GameObject line, Vector2 point) { DD_CoordinateAxis coordinate = m_CoordinateAxis.GetComponent <DD_CoordinateAxis>(); coordinate.InputPoint(line, point); }