public void Load(LevelDef def) { if (IsLoaded) { Debug.LogError("trying to load again."); return; } _levelDef = def; _map = MapGenerator.Generate(def); _starsLeft = new HashSet<Star>(_map.Stars); Star.OnGetStar += OnGetStar; _getStarRegistered = true; _ball = MapFactory.InstantiateBall(_map.StartPoisition); _ball.transform.SetParent(transform, false); var ballController = _ball.gameObject.AddComponent<BallController>(); ballController.Ball = _ball; }