コード例 #1
0
 private void InitObjectPool()
 {
     for (int i = 0; i < objectPrefabs.Length; i++)
     {
         GameObject newObj = Instantiate(objectPrefabs[i], transform);
         newObj.SetActive(false);
         ObjectScrollBehaviour obj = newObj.GetComponent <ObjectScrollBehaviour>();
         obj.Init(layerScrollIndex, color, startPointPosition, endPointPosition, layerScrollSpeed);
         objectPool.Add(obj);
     }
 }
コード例 #2
0
        private void Update()
        {
            if (isPause.Value)
            {
                return;
            }

            if (lastObject.transform.position.x + lastObject.GetWidth() + layerScrollGapSize <= startPointPosition.x)
            {
                lastObject = GetRandomObject();
                lastObject.transform.position = startPointPosition;
                lastObject.gameObject.SetActive(true);
            }
        }
コード例 #3
0
 private void OnEnable()
 {
     InitObjectPool();
     lastObject = GetRandomObject();
     lastObject.gameObject.SetActive(true);
 }