Skip to content
This repository was archived by the owner on Feb 12, 2023. It is now read-only.

Commit 4bf264b

Browse files
committed
Fix: attr colors to linear color space
1 parent b3008b5 commit 4bf264b

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

examples/Assets/Scenes/SampleScene.unity

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 705507994}
41-
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
41+
m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1}
4242
m_UseRadianceAmbientProbe: 0
4343
--- !u!157 &3
4444
LightmapSettings:
@@ -346,6 +346,7 @@ MonoBehaviour:
346346
panelTransform: {fileID: 0}
347347
enableLiveUpdates: 0
348348
_root: {fileID: -6750239444755058063, guid: fb7a34ebf6310fc468db4e32a57d1d40, type: 3}
349+
colorsInLinearColorSpace: 0
349350
--- !u!114 &664391324
350351
MonoBehaviour:
351352
m_ObjectHideFlags: 0

examples/ProjectSettings/ProjectSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ PlayerSettings:
4747
defaultScreenWidthWeb: 960
4848
defaultScreenHeightWeb: 600
4949
m_StereoRenderingPath: 0
50-
m_ActiveColorSpace: 0
50+
m_ActiveColorSpace: 1
5151
m_MTRendering: 1
5252
m_StackTraceTypes: 010000000100000001000000010000000100000001000000
5353
iosShowActivityIndicatorOnLoading: -1

packages/com.mkmarek.uielements.react/Runtime/Bridge/Styles/StyleMapper.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,32 @@ public static Color ParseColor(string hexColor)
134134

135135
if (hexInString.Length == 6)
136136
{
137-
return new Color32(
137+
Color col = new Color32(
138138
(byte)(color >> 16 & 0xFF),
139139
(byte)((color >> 8) & 0xFF),
140140
(byte)(color & 0xFF),
141141
0xFF);
142+
143+
if (ReactRenderer.Current.colorsInLinearColorSpace) {
144+
return col.linear;
145+
}
146+
147+
return col;
142148
}
143149

144150
if (hexInString.Length == 8)
145151
{
146-
return new Color32(
152+
Color col = new Color32(
147153
(byte)(color >> 24 & 0xFF),
148154
(byte)(color >> 16 & 0xFF),
149155
(byte)((color >> 8) & 0xFF),
150156
(byte)(color & 0xFF));
157+
158+
if (ReactRenderer.Current.colorsInLinearColorSpace) {
159+
return col.linear;
160+
}
161+
162+
return col;
151163
}
152164

153165
throw new FormatException($"Color can't have {hexInString.Length} digits");

packages/com.mkmarek.uielements.react/Runtime/ReactRenderer.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ public class ReactRenderer : PanelRenderer
2121

2222
public static ReactRenderer Current { get; private set; }
2323

24-
[SerializeField]
2524
#pragma warning disable 649
25+
[SerializeField]
2626
private JSFileObject _root;
27+
28+
[SerializeField]
29+
internal bool colorsInLinearColorSpace;
2730
#pragma warning restore 649
2831

2932
private new void Awake()

0 commit comments

Comments
 (0)