X
X
XDecent2020-07-03 09:08:37
Mobile development
XDecent, 2020-07-03 09:08:37

How to spawn an object relative to Canvas, and also so that it would be higher in the hierarchy?

I want my object to always spawn relative to the Canvasa coordinates that I set for it when I change the screen resolution. And because I have prefabs spawning, I need them to spawn higher in the hierarchy than other objects

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zZaKko, 2020-07-03
@XDecent

When creating an object via Instantive(); you can specify which object will be the parent object. You throw a prefab in the canvas script, and when creating the fourth variable, you specify cansvas.transform. Like this:

public GameObject obj;
public Vector3 vec;
public GameObject can

void Start(){
Instantive(obj, vec, Quaternion.identity, can.transform);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question