コード例 #1
0
    /// <summary>
    /// 1회 Spawn 수행.
    /// </summary>
    public override void Start()
    {
        var pool = PoolManager.GetOrCreate(PrefabName);

        Vector3    position = SpawnPosition;
        Quaternion rotation = SpawnRotation;

        if (RelativeToOwner)
        {
            position += owner.transform.position;
            rotation *= owner.transform.rotation;
        }

        //풀에서 ISpawnable 객체를 가져온다.
        asPooledObject  = pool.Instantiate(position, rotation);
        asSpawnedObject = asPooledObject.gameObject.GetComponent <FieldObject>() as ISpawnable;

        if (asSpawnedObject == null)
        {
            Debug.LogError("ISpawnable을 구현하지 않은 FieldObject는 Spawn할 수 없습니다 ");
            pool.Dispose(asPooledObject);

            asPooledObject = null;
            return;
        }

        asSpawnedObject.SpawnOwner = owner;
        asSpawnedObject.OnSpawn(owner);

        IsActive = true;
    }
コード例 #2
0
        public override T Create(Vector3 position = default, Quaternion rotation = default, Transform parent = null)
        {
            T newObj = base.Create(position, rotation, parent);

            ISpawnable spawnable = newObj as ISpawnable;

            spawnable.OnSpawn(this);

            return(newObj);
        }