- Home /
How to store data in script and attach it later?
I original asked the generic part of this here.
I have two sets of data for each object. Let these be A and B. I get A first. Then I use it. And then I get Part B later. I want these data these two sets accessible together after I get both. I currently create two classes to store A and B which reference each other but this seems to be a bad design choice. Here B is a Script. The problem is I can only attach it after I get both data.
This problem would be solved easily if I could create a single MonoBehavior GodScript class that is first instanced empty. Add A. Use A. Add B. Finally attach GodScript.
As we know instancing GodScript without attaching it is not supported. Is there a way to still achieve this somehow? In the link I mentioned someone's answer says it's possible but couldn't really understand how.
Your answer
Follow this Question
Related Questions
Using AddComponent to add a Sub Class using a String 4 Answers
C# Inheritance, base class attributes, override and null object 1 Answer
Inheritance and Component Types in C# 2 Answers
Assigning Serializable child class, not visible in Editor 1 Answer
Making a static class derive from MonoBehaviour in C# 3 Answers