public void changeSpritePivot(GameObject obj, WMGpivotTypes theType) { RectTransform theSprite = obj.GetComponent <RectTransform>(); Text theText = obj.GetComponent <Text>(); if (theSprite == null) { return; } if (theType == WMGpivotTypes.Bottom) { theSprite.pivot = new Vector2(0.5f, 0f); } else if (theType == WMGpivotTypes.BottomLeft) { theSprite.pivot = new Vector2(0f, 0f); } else if (theType == WMGpivotTypes.BottomRight) { theSprite.pivot = new Vector2(1f, 0f); } else if (theType == WMGpivotTypes.Center) { theSprite.pivot = new Vector2(0.5f, 0.5f); if (theText != null) { theText.alignment = TextAnchor.MiddleCenter; } } else if (theType == WMGpivotTypes.Left) { theSprite.pivot = new Vector2(0f, 0.5f); if (theText != null) { theText.alignment = TextAnchor.MiddleLeft; } } else if (theType == WMGpivotTypes.Right) { theSprite.pivot = new Vector2(1f, 0.5f); if (theText != null) { theText.alignment = TextAnchor.MiddleRight; } } else if (theType == WMGpivotTypes.Top) { theSprite.pivot = new Vector2(0.5f, 1f); } else if (theType == WMGpivotTypes.TopLeft) { theSprite.pivot = new Vector2(0f, 1f); } else if (theType == WMGpivotTypes.TopRight) { theSprite.pivot = new Vector2(1f, 1f); } }
public void changeSpritePivot(GameObject obj, WMGpivotTypes theType) { UIWidget theSprite = obj.GetComponent <UIWidget>(); if (theSprite == null) { return; } if (theType == WMGpivotTypes.Bottom) { theSprite.pivot = UIWidget.Pivot.Bottom; } else if (theType == WMGpivotTypes.BottomLeft) { theSprite.pivot = UIWidget.Pivot.BottomLeft; } else if (theType == WMGpivotTypes.BottomRight) { theSprite.pivot = UIWidget.Pivot.BottomRight; } else if (theType == WMGpivotTypes.Center) { theSprite.pivot = UIWidget.Pivot.Center; } else if (theType == WMGpivotTypes.Left) { theSprite.pivot = UIWidget.Pivot.Left; } else if (theType == WMGpivotTypes.Right) { theSprite.pivot = UIWidget.Pivot.Right; } else if (theType == WMGpivotTypes.Top) { theSprite.pivot = UIWidget.Pivot.Top; } else if (theType == WMGpivotTypes.TopLeft) { theSprite.pivot = UIWidget.Pivot.TopLeft; } else if (theType == WMGpivotTypes.TopRight) { theSprite.pivot = UIWidget.Pivot.TopRight; } }
public void changeSpritePivot(GameObject obj, WMGpivotTypes theType) { RectTransform theSprite = obj.GetComponent<RectTransform>(); Text theText = obj.GetComponent<Text>(); if (theSprite == null) return; if (theType == WMGpivotTypes.Bottom) { theSprite.pivot = new Vector2(0.5f, 0f); if (theText != null) theText.alignment = TextAnchor.LowerCenter; } else if (theType == WMGpivotTypes.BottomLeft) { theSprite.pivot = new Vector2(0f, 0f); if (theText != null) theText.alignment = TextAnchor.LowerLeft; } else if (theType == WMGpivotTypes.BottomRight) { theSprite.pivot = new Vector2(1f, 0f); if (theText != null) theText.alignment = TextAnchor.LowerRight; } else if (theType == WMGpivotTypes.Center) { theSprite.pivot = new Vector2(0.5f, 0.5f); if (theText != null) theText.alignment = TextAnchor.MiddleCenter; } else if (theType == WMGpivotTypes.Left) { theSprite.pivot = new Vector2(0f, 0.5f); if (theText != null) theText.alignment = TextAnchor.MiddleLeft; } else if (theType == WMGpivotTypes.Right) { theSprite.pivot = new Vector2(1f, 0.5f); if (theText != null) theText.alignment = TextAnchor.MiddleRight; } else if (theType == WMGpivotTypes.Top) { theSprite.pivot = new Vector2(0.5f, 1f); if (theText != null) theText.alignment = TextAnchor.UpperCenter; } else if (theType == WMGpivotTypes.TopLeft) { theSprite.pivot = new Vector2(0f, 1f); if (theText != null) theText.alignment = TextAnchor.UpperLeft; } else if (theType == WMGpivotTypes.TopRight) { theSprite.pivot = new Vector2(1f, 1f); if (theText != null) theText.alignment = TextAnchor.UpperRight; } }
public void changeAllLinePivots(WMGpivotTypes newPivot) { for (int j = 0; j < lineSeries.Count; j++) { if (!activeInHierarchy(lineSeries[j])) continue; WMG_Series aSeries = lineSeries[j].GetComponent<WMG_Series>(); List<GameObject> lines = aSeries.getLines(); for (int i = 0; i < lines.Count; i++) { changeSpritePivot(lines[i], newPivot); WMG_Link aLink = lines[i].GetComponent<WMG_Link>(); aLink.Reposition(); } } }