Ejemplo n.º 1
0
    private void Load()
    {
        blockPlacer = FindObjectOfType <BlockPlacer>();

        var list = blockPlacer.LoadArray();

        for (int i = 0; i < list.Count; i = i + 2)
        {
            Debug.Log("x: " + list[i] + ", y: " + list[i + 1]);
        }
    }
Ejemplo n.º 2
0
    private void InstantiateBlocks()
    {
        string path = "Assets/Prefabs";
        //string prefabName = "Block";
        GameObject parent = GameObject.FindGameObjectWithTag("Blocks");

        blockPlacer = FindObjectOfType <BlockPlacer>();
        var list  = blockPlacer.LoadArray();
        var names = blockPlacer.LoadNames();

        for (int i = 0, j = 0; i < list.Count; i = i + 2, j++)
        {
            Object prefab = AssetDatabase.LoadAssetAtPath(path + "/"
                                                          + names[j].Substring(0, names[j].Length - 7)
                                                          + ".prefab", typeof(GameObject));
            if (prefab != null)
            {
                GameObject obj = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
                obj.transform.SetParent(parent.transform);
                obj.transform.position = new Vector2(list[i], list[i + 1]);
            }
        }
    }