R
R
RandomProgrammer2021-12-01 16:49:38
Unity
RandomProgrammer, 2021-12-01 16:49:38

Is it possible to use an instancer inside a constructor?

Is it possible to do this, or is it a bad idea?

public class Example : MonoBehaviour
{
    Example(params)
    {
        Instantiate(this.gameObject);
        // some code here
    }
}

And then when creating an object, just call the constructor?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2021-12-01
@RandomProgrammer

Bad exactly because MonoBehaviour descendants cannot use a constructor. And the phrase "call the constructor" put me personally in a stupor))

N
Nekit Medvedev, 2021-12-02
@NIKROTOS

https://qna.habr.com/q/439175

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question