- Home /
Instantiate scripts with class relationships
I want to create clones of my behaviours (by using GameObject.Instantiate()), but sometimes they have relationship with objects that are not behaviour. In this case, Instantiate would create a game object with null references for these relationships. I can make these classes serializable and use the SerializeField attribute, but they'd show up in the editor, which would be a mess. Is there another way to do this?
Example:
public class CloningTests : MonoBehaviour
{
[SerializeField]
private SimpleObject SimpleObject;
...
}
[Serializable()]
public class SimpleObject
{
public int number = 0;
...
}
That would work but SimpleObject would appear in the editor.
Your answer
Follow this Question
Related Questions
Crash when using GameObject.Instantiate 2 Answers
Unity object cloning and public/private variables 0 Answers
Cloned interactivecloth not acting like original interactivecloth. 0 Answers
Cloning Objects with Instantiate() - variables/references for added Components not stored? 3 Answers
How to Parent a Cloned Object to Another Cloned Object 1 Answer