6
« on: June 18, 2014, 04:33:32 PM »
Well I just realized, if it's advanced, I will need to set the relatives as well. sorry for the confusion. Is this the correct way?
/// <summary>
/// Anchor this rectangle to the specified transform using the advanced system. Relative values are a scale from 0 to 1, 0 being left/bottom, 1 being right/top.
/// </summary>
public void SetAnchor (GameObject leftGO, int leftA, float leftR, GameObject bottomGO, int bottomA, float bottomR,
GameObject rightGO, int rightA, float rightR, GameObject topGO, int topA, float topR)
{
Transform tl = (leftGO != null) ? leftGO.transform : null;
Transform tr = (rightGO != null) ? rightGO.transform : null;
Transform tt = (topGO != null) ? topGO.transform : null;
Transform tb = (bottomGO != null) ? bottomGO.transform : null;
leftAnchor.target = tl;
rightAnchor.target = tr;
topAnchor.target = tt;
bottomAnchor.target = tb;
leftAnchor.relative = leftR ;
rightAnchor.relative = rightR ;
bottomAnchor.relative = bottomR ;
topAnchor.relative = topR ;
leftAnchor.absolute = leftA;
rightAnchor.absolute = rightA;
bottomAnchor.absolute = bottomA;
topAnchor.absolute = topA;
ResetAnchors();
UpdateAnchors();
}