A method of fixing a lens unit (21, 31) of an optical sensor during assembly processing of the sensor, the lens unit (21, 31) being included in a light projecting unit or a light receiving unit of the sensor, comprising the steps of: fixing at least a pair of columnar bodies (121, 122, 131, 132, 133, 134) around a position on a support plate provided within a casing of the sensor, the position being where the lens unit (21, 31) is to be disposed, wherein the columnar bodies (121, 122, 131, 132, 133, 134) are fixed such that the columnar bodies (121, 122, 131, 132, 133, 134) are perpendicular to a surface of the support plate and the columnar bodies (121, 122, 131, 132, 133, 134) face each other with a space for inserting the lens unit (21, 31) interposed between the columnar bodies (121, 122, 131, 132, 133, 134); fixing an optical element paired with the lens unit (21, 31) to a predetermined position on said support plate; inserting the lens unit (21, 31) into the space between the columnar bodies (121, 122, 131, 132, 133, 134); adjusting a position and an orientation of the lens unit (21, 31) with respect to the optical element to match optical axes of the lens unit (21, 31) and the optical element; fixing the lens unit (21, 31) by injecting adhesive resin into a gap between the lens unit (21, 31) and each columnar body (121, 122, 131, 132, 133, 134) with an adjusted state of the lens unit (21, 31) being maintained; and curing the adhesive resin, wherein ultraviolet curable resin is used as the adhesive resin, and the adhesive resin injected into the gap between the lens unit (21, 31) and each columnar body (121, 122, 131, 132, 133, 134) is cured by emitting ultraviolet light toward the support plate, and wherein each columnar body (121, 122, 131, 132, 133, 134) has a tapered shape with a width that narrows towards the gap to guide the emitted ultraviolet light along surfaces of each columnar body (121, 122, 131, 132, 133, 134) to the gap between the lens unit (21, 31) and each columnar body (121, 122, 131, 132, 133, 134). fixing at least a pair of columnar bodies (121, 122, 131, 132, 133, 134) around a position on a support plate provided within a casing of the sensor, the position being where the lens unit (21, 31) is to be disposed, wherein the columnar bodies (121, 122, 131, 132, 133, 134) are fixed such that the columnar bodies (121, 122, 131, 132, 133, 134) are perpendicular to a surface of the support plate and the columnar bodies (121, 122, 131, 132, 133, 134) face each other with a space for inserting the lens unit (21, 31) interposed between the columnar bodies (121, 122, 131, 132, 133, 134); fixing an optical element paired with the lens unit (21, 31) to a predetermined position on said support plate; inserting the lens unit (21, 31) into the space between the columnar bodies (121, 122, 131, 132, 133, 134); adjusting a position and an orientation of the lens unit (21, 31) with respect to the optical element to match optical axes of the lens unit (21, 31) and the optical element; fixing the lens unit (21, 31) by injecting adhesive resin into a gap between the lens unit (21, 31) and each columnar body (121, 122, 131, 132, 133, 134) with an adjusted state of the lens unit (21, 31) being maintained; and curing the adhesive resin, wherein ultraviolet curable resin is used as the adhesive resin, and the adhesive resin injected into the gap between the lens unit (21, 31) and each columnar body (121, 122, 131, 132, 133, 134) is cured by emitting ultraviolet light toward the support plate, and wherein each columnar body (121, 122, 131, 132, 133, 134) has a tapered shape with a width that narrows towards the gap to guide the emitted ultraviolet light along surfaces of each columnar body (121, 122, 131, 132, 133, 134) to the gap between the lens unit (21, 31) and each columnar body (121, 122, 131, 132, 133, 134).