Question by
SkymaxPlay · Dec 19, 2017 at 10:14 PM ·
c#positionvector3
Bug? Wrong changing position of gameobject
Hello, I have a problem, I have Unity version 5.6.4. (Game 2D) When I creating new instantiate of object everythings work good (position: {x: -6, y: 118, z: 0} using C# script.
Line#1 GameObject obj = Instantiate(ProfilePrefab, ListContent.transform);
But when I'm trying change position of object, position wrong changing. For example:
Line#2: RectTransform rectTransform = (RectTransform) obj.transform;
Line#3 obj.transform.position = new Vector3(rectTransform .transform.position.x, rectTransform .transform.position.y - 1F);
Position Y should be 117, but he is -330 (rounding). Second thing, I dont edit anywhere position Z. After executed script (line #3), position is edited to -3900. How to fix it?
Comment
Answer by MaxOR_PrimE · Jan 25, 2019 at 04:33 AM
have same problem here i set transform.position = new Vector2(transform.position.x, 2.5f); and it set it to 2.36f why ? and how to fix it !!!