// Start is called before the first frame update void Start() { DirectionsInitialize(); _length = _xWidth * _yWidth * _zWidth; _gameObjectArray = new GameObject[_length]; _meshRendererArray = new MeshRenderer[_length]; _allBoolData = new NativeArray <int>(_length, Allocator.Persistent); var _aroundLifesIndexDataArray = new AroundStructData[_length]; _aroundIndexList = new NativeArray <AroundStructData>(_length, Allocator.Persistent); //i*j*kの直方体区間にLifeを配置 for (int k = 0; k < _zWidth; k++) { for (int j = 0; j < _yWidth; j++) { for (int i = 0; i < _xWidth; i++) { var Pos = new V3(i, j, k); var thisLifesIndex = Pos.GetIndex(_xWidth, _yWidth); var tr = Instantiate(_prefab, new Vector3(Pos.X, Pos.Y, Pos.Z), transform.rotation); _gameObjectArray[thisLifesIndex] = tr.gameObject; _meshRendererArray[thisLifesIndex] = tr.GetComponent <MeshRenderer>(); bool startIsAlive = Random.value > birthThreshold; if (!startIsAlive) { if (!isTest) { _gameObjectArray[thisLifesIndex].SetActive(false); } else { _meshRendererArray[thisLifesIndex].enabled = false; } } _allBoolData[thisLifesIndex] = startIsAlive ? 1 : 0; _aroundLifesIndexDataArray[thisLifesIndex] = new AroundStructData(new int[26]); _aroundIndexList[thisLifesIndex] = new AroundStructData(new int[26]); for (var aroundsIndex = 0; aroundsIndex < _arounds.Length; aroundsIndex++) { V3 newPos = Pos + _arounds[aroundsIndex]; _aroundLifesIndexDataArray[thisLifesIndex].SetValue(aroundsIndex, newPos.GetRoundIndex(_xWidth, _yWidth, _zWidth, _xDoRound, _yDoRound, _zDoRound)); _aroundIndexList[thisLifesIndex] = _aroundLifesIndexDataArray[thisLifesIndex]; } } } /* * sw = new System.Diagnostics.Stopwatch(); * sw.Start(); * //*/ } }