Hi @Kyuseok11,
Your idea is good, when you have an object with a change of several materials at the same time.
The @paulocp39 suggestion is also achievable when you combine multiple materials. In this case, which you mentioned in your photo, you can prepare a diffuse texture with three colors in the following way, and arrange a Unwrap map of your parts in them.
However, the combination white - sky blue - white, it is difficult to replace the combination yellow - red - blue in this way, if the elements are in that order.
Best regards!