BB.MapFactory.InstantiateBall C# (CSharp) Method

InstantiateBall() public static method

public static InstantiateBall ( Coor position ) : Ball
position Coor
return Ball
        public static Ball InstantiateBall(Coor position)
        {
            var go = (GameObject)GameObject.Instantiate(LevelDB._.Ball.gameObject, position.ToVector2(), Quaternion.identity);
            return go.GetComponent<Ball>();
        }

Usage Example

        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;
        }