예제 #1
0
    public (GameObject, Spawned) SpawnNewInstance(Transform matchPositionAndRotation, Spawner context)
    {
        if (this.target == null)
        {
            return(null, null);
        }

        GameObject result = Object.Instantiate(this.target, matchPositionAndRotation.position, matchPositionAndRotation.rotation, matchPositionAndRotation);

        if (result == null)
        {
            Debug.LogError("Instantiate returned null", context.gameObject);
            return(null, null);
        }

        Spawned spawned = result.AddComponent(typeof(Spawned)) as Spawned;

        if (spawned != null)
        {
            spawned.SetTargetRenderersEnabled(true);

            result.SetActive(true);
        }

        return(result, spawned);
    }