- Home /
Question by
formygames280 · Oct 02, 2018 at 02:56 PM ·
2dgameobjectpositioncopy
Problem with Instantiate 2D object to right position C#
My problem is: I can't copy my object to right position, can somebody tell me how can I repair it?
My script:
using UnityEngine;
public class Core : MonoBehaviour {
public GameObject panel;
public GameObject holder;
public Vector2 panelPosition;
public Quaternion panelRotation;
![alt text][1]
public void Pressed()
{
panel = Instantiate(panel, panelPosition, panelRotation, holder.transform);
}
}
Image is position where I want to copy this game object.
https://answers.unity.com/storage/attachments/125491-vystrmbmbnmizek.png
is where it is when I call Pressed() with button.
https://answers.unity.com/storage/attachments/125490-vystrizelk.png
(It's not in position where I wanted to)
vystrizelk.png
(10.7 kB)
vystrmbmbnmizek.png
(16.7 kB)
Comment
because this is UI Object So use Recttransform.Anchoredposition