Great script.
I also made a reverse script!
import bpy def linearrgb_to_srgb(c): if c < 0: return 0 elif c < 0.0031308: return 12.92 * c else: return 1.055 * (c ** (1/2.4)) - 0.055 def rgb_to_hex(r, g, b,a): r = int(linearrgb_to_srgb(r) * 255 + 0.5) g = int(linearrgb_to_srgb(g) * 255 + 0.5) b = int(linearrgb_to_srgb(b) * 255 + 0.5) return (r << 16) + (g << 8) + b hex_color = rgb_to_hex(*bpy.context.object.material_slots[0].material.diffuse_color) print(hex(hex_color))



Also created a script to output 8-bit RBG at the same time
import bpy def linearrgb_to_srgb(c): if c < 0: return 0 elif c < 0.0031308: return 12.92 * c else: return 1.055 * (c ** (1/2.4)) - 0.055 def rgb_to_rgb_ganma(r, g, b,a): r_value = int(linearrgb_to_srgb(r) * 255 + 0.5) g_value = int(linearrgb_to_srgb(g) * 255 + 0.5) b_value = int(linearrgb_to_srgb(b) * 255 + 0.5) r_normalized_value = int(linearrgb_to_srgb(r) * 255 + 0.5) / 255 g_normalized_value = int(linearrgb_to_srgb(g) * 255 + 0.5) / 255 b_normalized_value = int(linearrgb_to_srgb(b) * 255 + 0.5) / 255 return (r_value,g_value,b_value), (r_normalized_value,g_normalized_value,b_normalized_value) hex_color = rgb_to_rgb_ganma(*bpy.data.materials['Material_test'].node_tree.nodes["Principled BSDF"].inputs[0].default_value) print('###0-0###mat name', bpy.context.object.material_slots[0].name) print(hex_color)
Results in Console
###0-0###mat name Material_test ((230, 31, 0), (0.9019607843137255, 0.12156862745098039, 0.0))
'Material_test' of the material name "'Material_test'". 'Principled BSDF' of the material name 'Material_test' has been changed with reference to the gamma value.

Try to enter the colors manually displayed by other external software. (0.9019607843137255, 0.12156862745098039, 0.0) input. In this software, the input ranges from 0 to 1.

It actually turned out to be the same color, but just to be sure, I'll check if the values are the same in the color picker. No problem.
(230, 31, 0) value.
I'll check Blender just to be sure.

We see that the value is (230, 31, 0) without any problem.
I'll check with UNITY as well.

Let's set the shedder to UNIT for easy color picker.

Of course, but it is definitely a value of (230, 31, 0). That is, the same as the color on Blender's color picker.