void Awake()
 {
     trans = GetComponent<Transform>();
     rend = GetComponent<Renderer>();
     col = GetComponent<Collider>();
     gc = GameController.Instance;
 }
 void Awake()
 {
     #region Singleton
     if (_instance == null)
     {
         _instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         if (_instance != this)
         {
             Debug.Log("Duplicate of '" + this.GetType() + "' script was removed from '" + gameObject.name + "' gameobject");
             Destroy(this);
         }
         return;
     }
     #endregion
     sc = new MyScene(sceneSizes);
     StartCoroutine(load(assetFileName, 1));
     sg = new SpheresGenerator(sceneSizes, sphereSize, texBufferSize);
     ui = new MyUI();
     cam = Camera.main;
     cam.transform.position = camPosition;
 }
        public SpheresGenerator(Vector3 _sceneSizes, float _sphereSize, int _texBufferSize)
        {
            gc = GameController.Instance;
            sphereSize = _sphereSize;
            texBufferSize = _texBufferSize;

            spheresHolderTrans = new GameObject().GetComponent<Transform>();
            spheresHolderTrans.name = "SpheresHolder";
            spheresHolderTrans.position = new Vector3(-_sceneSizes.x / 2 + _sphereSize, _sceneSizes.y, _sphereSize);
            sphereSpawnGenSize = new Vector3(_sceneSizes.x - 2 * _sphereSize, _sceneSizes.y, _sceneSizes.z - 2 * _sphereSize);

            spheresPoolTrans = new GameObject().GetComponent<Transform>();
            spheresPoolTrans.name = "SpheresPool";

            textures = new Texture[2, texBufferSize];
            for (int i = 0; i < texBufferSize; i++)
                GenSphereTexForNextLevel(i);

            spPool = new Stack<SphereController>(gc.spBufferSize);
            for (int i = 0; i < gc.spBufferSize; i++)
                GenNewSphereToPool(i);
        }