- MainCanvas(screenspace-camera, с расстоянием между плоскостями 0,31 (около плоскости) равно 0,3))
EmptyPanel
UI_A (с прямоугольным преобразованием)
UI_B(с прямоугольным преобразованием)
Emptypanel содержит скрипт, который создает UI_A во время выполнения и родительский UI_A для себя
Код: Выделить всё
GameObject UI_A= Instantiate(g);
UI_A.transform.position = transform.position;
UI_A.transform.SetParent(transform);
UI_A.transform.localScale = transform.localScale;
Код: Выделить всё
//script in UI_A
void Start () {
//float width = GetComponent().rect.width;
//float height = GetComponent().rect.height;
Vector3 pos = transform.position;
pos += new Vector3(offsetFromEdge.x, offsetFromEdge.y, 0f);
_UI_B = new UI_B(transform, pos);
}
Код: Выделить всё
public UI_B(Transform parent, Vector3 pos)
{
GameObject obj = new GameObject();
obj.AddComponent();
var comp = obj.GetComponent();
comp.pivot = Vector2.zero;
comp.anchorMin = Vector2.zero;
comp.anchorMax = Vector2.zero;
obj.transform.position = pos;
obj.SetParent(parent);
obj.localScale = scale;
}
Эти значения отображается в Pos X и Pos Y компонента RectTransform, которые, я считаю, совпадают с Transform.localPosition UI_B.
I понятия не имею, что вызывает такое поведение.
Подробнее здесь: https://stackoverflow.com/questions/319 ... -parenting