void OnEnable() { if (Image1 != null) { Vector3 lifeImage2Pos = Image1.GetComponent <RectTransform>().position; lifeImage2Pos.y -= Image1.GetComponent <RectTransform>().GetHeight(); Image2.GetComponent <RectTransform>().position = lifeImage2Pos; StartingPos = Image1.GetComponent <RectTransform>().position; CutMaskStartingY = CutMask.transform.position.y; CutMaskHeight = CutMask.GetComponent <RectTransform>().GetHeight(); } }
void Update() { if (Image1 != null) { Vector3 pos1 = Image1.GetComponent <RectTransform>().position; pos1.y += 0.5f; Image1.GetComponent <RectTransform>().position = pos1; Vector3 pos2 = Image2.GetComponent <RectTransform>().position; pos2.y += 0.5f; Image2.GetComponent <RectTransform>().position = pos2; if (pos2.y >= StartingPos.y) { Image1.GetComponent <RectTransform>().position = StartingPos; Vector3 tmp = StartingPos; tmp.y -= Image1.GetComponent <RectTransform>().GetHeight(); Image2.GetComponent <RectTransform>().position = tmp; } } }