Exemplo n.º 1
0
    /// <summary>
    /// Creates a TerrainMaterial from a JSON object. Does NOT recreate mesh data automatically or link materials!
    /// </summary>
    /// <param name="aJSON">A parsed JSON value containing PathTerrain and Path data</param>
    public void           FromJSON(Ferr_JSONValue aJSON)
    {
        fill             = (Ferr2DT_FillMode)Enum.Parse(typeof(Ferr2DT_FillMode), aJSON["fill", "Closed"]);
        fillY            = aJSON["fillY", 0];
        fillZ            = aJSON["fillZ", 0.2f];
        splitCorners     = aJSON["splitCorners", true];
        smoothPath       = aJSON["smoothPath", false];
        splitDist        = aJSON["splitDist", 4];
        pixelsPerUnit    = aJSON["pixelsPerUnit", 32];
        stretchThreshold = aJSON["stretchThreshold", 0.5f];
        vertexColor      = Ferr_Color.FromHex(aJSON["vertexColor", "FFFFFF"]);
        createCollider   = aJSON["createCollider", true];
        create3DCollider = aJSON["create3DCollider", false];
        depth            = aJSON["depth", 4];
        surfaceOffset[0] = aJSON["surfaceOffset.0", 0];
        surfaceOffset[1] = aJSON["surfaceOffset.1", 0];
        surfaceOffset[2] = aJSON["surfaceOffset.2", 0];
        surfaceOffset[3] = aJSON["surfaceOffset.3", 0];
        collidersBottom  = aJSON["colliders.bottom", true];
        collidersTop     = aJSON["colliders.top", true];
        collidersLeft    = aJSON["colliders.left", true];
        collidersRight   = aJSON["colliders.right", true];

        Ferr_JSONValue overrides = aJSON["directionOverrides"];

        for (int i = 0; i < overrides.Length; i++)
        {
            directionOverrides.Add((Ferr2DT_TerrainDirection)Enum.Parse(typeof(Ferr2DT_TerrainDirection), overrides[i, "None"]));
        }

        path.FromJSON(aJSON["path"]);
    }