An object inside an object class
Hey! I'm having an issue and I'm not sure if I'm doing this correct or if I can't do this at all.
So I have a generation class which basically you can make an object from that class and you would have a generator in which you can set its values as usual in objects. In that object however I generate another object which is the pool which is run in a separate class where you can create a pool object and set its values just like the generator object but this happens automatically in the generator object. The issue I'm having is when I create an Generator object unity crashes. Here's an example:
public class MainClass : MonoBehaviour { public Generator g;
void Start() { Generate(); }
void Generate() { g = new Generator(); g.setvalues(info); } }
public class Generator : MonoBehaviour { Pool pool;
void SetValues(Gameobject object,stuff,stuff) { pool = new Pool; pool.CreatePool(object, size); } // MORE STUFF }
// NEXT CLASS public class Pool : MonoBehaviour { void CreatePool(Gameobject object,int size) { // DOES STUFF } // MORE STUFF }
This is a rough example but this is what it does and it just crashes unity. Im not sure what to do since I get no information because unity crashes. Thanks!