H
H
Haddle Haddle2021-01-24 13:53:44
Unity
Haddle Haddle, 2021-01-24 13:53:44

I want to create a strip of xp when an enemy appears. I know how to do it in general, but there are problems?

I've been busy with Unity for a week.
When I create Image xp strips via script it is obviously not visible in the game. it is created without canvas.
How can I create an object and immediately put it into the canvas I need through the script?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
Haddle Haddle, 2021-01-24
@Haddle

I solved it like this

public GameObject myPrefab;
void Start(){
GameObject prefab = Instantiate(myPrefab , new Vector3(0,0,0), Quaternion.identity ) as GameObject;
prefab.transform.SetParent(GameObject.FindGameObjectWithTag("Пишем сюда тег канваса или другого объекта").transform, false)
}

F
freeExec, 2021-01-24
@freeExec

When you create an object, there is a parameter where to put it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question