WallManager.ResizeRoom C# (CSharp) Method

ResizeRoom() protected method

protected ResizeRoom ( ) : void
return void
    protected void ResizeRoom()
    {

        var t = transformRoom;

        var width = Mathf.Lerp(wallWidthRange.x, wallWidthRange.y, t);
        var height = Mathf.Lerp(wallHeightRange.x, wallHeightRange.y, t);

        var scaler = new Vector3(width, height, 1f);

        for (var i = 0; i < walls.Length; i++)
        {
            var wall = walls[i];

            if (wall.transform == null || wall.mesh == null) continue;

            wall.transform.position = transform.position - wall.transform.forward * Mathf.Lerp(wallOffsetRange.x, wallOffsetRange.y, t);

//            var wallMeshPos = wall.mesh.localPosition;
//            // wallMeshPos.y = height * 0.5f;
//            wall.mesh.localPosition = wallMeshPos;

            wall.mesh.localScale = scaler;

            if (wall.attachedObjects == null) continue;

            foreach (var attachedObject in wall.attachedObjects)
            {
                if (attachedObject == null) continue;
                if (attachedObject.transform == null) continue;

                attachedObject.transform.localPosition = Vector3.Scale(attachedObject.initLocalPos, new Vector3(1 + t, 1, 1));
            }
        }

        ceiling.position = transform.position + Vector3.up * height;

        ceilingMesh.localScale = new Vector3(width, width, 1);
    }
}