Exemplo n.º 1
0
    public void SetSpawn()
    {
        foreach (Transform child in ennemisFolder)
        {
            //print("Foreach loop: " + child);

            EnnemiSpawner newSpawn = Instantiate(spawnPrefab, child.position, child.rotation).GetComponent <EnnemiSpawner>() as EnnemiSpawner;
            newSpawn.transform.parent = gameObject.transform;

            newSpawn.thisEnnemi = child.GetComponent <Ennemis>() as Ennemis;

            //TODO: trouver un moyen automatique d'initialiser le prefab
            //Debug.Log(PrefabUtility.FindPrefabRoot(child.gameObject));
            //newSpawn.ennemi = PrefabUtility.FindPrefabRoot(child.gameObject).transform;

            //Set the path as within the Assets folder, and name it as the GameObject's name with the .prefab format

            /*
             * string localPath = "Assets/Prefabs/Ennemi" + child.name + ".prefab";
             * Debug.Log(localPath);
             *
             * GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(localPath, typeof(GameObject));
             * newSpawn.ennemi = prefab.transform;
             */
        }
    }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        EnnemiSpawner myScript = (EnnemiSpawner)target;

        if (GUILayout.Button("Spawn one ennemi"))
        {
            myScript.SpawnEnnemi();
        }
    }