public void Setup(AsteroidSettings asteroidSettings) { _initialVelocity = asteroidSettings.InitialVelocity; _maxVelocity = asteroidSettings.MaxVelocity; _maxTorque = asteroidSettings.MaxTorque; _scorePoints = asteroidSettings.ScorePoints; if (asteroidSettings.SpawnOnDestroy) { _spawnSettings = asteroidSettings.SpawnOnDestroySettings; _spawner.Activate(_spawnSettings); } else { _spawnSettings = null; } Activate(); }
void CreateTexts() { changes = new NativeQueue <int2>(Allocator.Persistent); launches = new NativeQueue <int>(Allocator.Persistent); cache = new string[101]; for (int i = 1; i < 100; i++) { cache[i + 1] = i.ToString(); } cache[0] = "E"; cache[1] = ""; texts = null; settings = GameObject.FindObjectOfType <AsteroidSettings>(); state = GameObject.FindObjectOfType <GameState>(); shipPrefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(settings.shipPrefab, World); var mgr = EntityManager; var q = mgr.CreateEntityQuery(typeof(Translation), typeof(Asteroid)); JobHandle jh; var ents = q.ToEntityArray(Allocator.TempJob, out jh); jh.Complete(); texts = new TextMeshPro[ents.Length]; for (int i = 0; i < ents.Length; i++) { var pos = mgr.GetComponentData <Translation>(ents[i]).Value; var go = GameObject.Instantiate(settings.textPrefab, pos, Quaternion.identity, settings.transform); texts[i] = go.GetComponent <TextMeshPro>(); var ast = mgr.GetComponentData <Asteroid>(ents[i]); ast.index = i; mgr.SetComponentData(ents[i], ast); } entities = ents.ToArray(); ents.Dispose(); q = mgr.CreateEntityQuery(typeof(MotherShip)); ents = q.ToEntityArray(Allocator.TempJob, out jh); jh.Complete(); target = ents[0]; ents.Dispose(); }