Beispiel #1
0
    GameObject getPrefabFromTileZoneAndTileName(Tile.Zone tileZone, Tile.Type type)
    {
        GameObject tilePrefab = Resources.Load <GameObject>("Prefabs/Environment/Tiles/"
                                                            + tileZone.ToString() +
                                                            "/" +
                                                            tileZone.ToString() + "_" + type) as GameObject;

        return(tilePrefab);
    }
Beispiel #2
0
    GameObject getPrefabFromScreenZoneAndTileName(Tile.Zone screenZone, string tileName)
    {
        GameObject tilePrefab = Resources.Load <GameObject>("Prefabs/Environment/Tiles/"
                                                            + screenZone.ToString() +
                                                            "/" +
                                                            screenZone.ToString() + tileName) as GameObject;

        return(tilePrefab);
    }
Beispiel #3
0
    GameObject createAuthoringInstanceFromPrefab(GameObject prefab, Tile tile, Tile.Type type, Tile.Zone tileZone)
    {
        GameObject instance = PrefabUtility.InstantiatePrefab(prefab, SceneManager.GetActiveScene()) as GameObject;

        Undo.RegisterCreatedObjectUndo(instance, "Create instance");
        instance.transform.position = tile.transform.position;
        instance.transform.parent   = tile.transform.parent;
        Tile instanceTile = instance.GetComponent <Tile> ();

        instanceTile.position = tile.position;
        instanceTile.type     = type;
        instanceTile.zone     = tileZone;
        if (tile.transform.parent.GetComponent <Screen> () == null)
        {
            instance.GetComponent <BoxCollider2D> ().isTrigger = true;
        }
        return(instance);
    }