Ejemplo n.º 1
0
    public void MMnewBuilding(IconController Prefab, Transform location, Buildings parent)
    {
        //Calculates Location
        float x = location.position.x;
        float z = location.position.z;

        x = Mathf.InverseLerp((mapGenerator.mapWidth * 10) / -2, (mapGenerator.mapWidth * 10) / 2, x);
        z = Mathf.InverseLerp((mapGenerator.mapHeight * 10) / -2, (mapGenerator.mapHeight * 10) / 2, z);
        //Apply Location
        Vector3 rectrans = new Vector3(Mathf.Lerp(mimimapWidth / -2, mimimapWidth / 2, x), Mathf.Lerp(mimimapHeight / -2, mimimapHeight / 2, z), 1);

        //GameObject icon =
        IconController instance = Instantiate(Prefab, rectrans, Quaternion.identity, map.transform);

        instance.GetComponent <RectTransform>().anchoredPosition = rectrans;
        instance.referenceBuilding = parent;
    }