Skip to content

Commit

Permalink
AlwaysUpdate flag was not being copied during the serialization process
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaimi committed Apr 13, 2021
1 parent 4db4fa6 commit deaca5c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static bool OnGUI(UMAMaterialPropertyBlock umpb)
GUILayout.Label("Shader Properties",GUILayout.ExpandWidth(true));
GUILayout.Label("Always Update",GUILayout.ExpandWidth(false));
umpb.alwaysUpdate = GUILayout.Toggle(umpb.alwaysUpdate, "",GUILayout.ExpandWidth(false));

GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();

Expand Down
6 changes: 6 additions & 0 deletions UMAProject/Assets/UMA/Core/Scripts/UMAPackedRecipeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ public class PackedOverlayColorDataV3
// Put everything in one array
public short[] colors;
public string[] ShaderParms;
public bool alwaysUpdate;

public PackedOverlayColorDataV3()
{
Expand Down Expand Up @@ -383,6 +384,10 @@ public PackedOverlayColorDataV3(OverlayColorData colorData)
colors[colorIndex++] = (short)Mathf.FloorToInt(additiveMaskColor.a * 255f);
}
}
if (colorData.HasPropertyBlock)
{
alwaysUpdate = colorData.PropertyBlock.alwaysUpdate;
}
if (colorData.HasProperties)
{
ShaderParms = new string[colorData.PropertyBlock.shaderProperties.Count];
Expand Down Expand Up @@ -421,6 +426,7 @@ public void SetOverlayColorData(OverlayColorData overlayColorData)
if (ShaderParms.Length > 0)
{
overlayColorData.PropertyBlock = new UMAMaterialPropertyBlock();
overlayColorData.PropertyBlock.alwaysUpdate = alwaysUpdate;
for(int i=0;i<ShaderParms.Length;i++)
{
overlayColorData.PropertyBlock.shaderProperties.Add(UMAProperty.FromString(ShaderParms[i]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public OverlayColorData Duplicate()
if (PropertyBlock != null)
{
res.PropertyBlock = new UMAMaterialPropertyBlock();
res.PropertyBlock.alwaysUpdate = PropertyBlock.alwaysUpdate;
res.PropertyBlock.shaderProperties = new List<UMAProperty>(PropertyBlock.shaderProperties.Count);
for(int i=0;i<PropertyBlock.shaderProperties.Count;i++)
{
Expand Down Expand Up @@ -142,6 +143,13 @@ public bool HasColors
}
}

public bool HasPropertyBlock
{
get
{
return PropertyBlock != null;
}
}
public bool HasProperties
{
get
Expand Down Expand Up @@ -357,6 +365,7 @@ public void AssignFrom(OverlayColorData src)
PropertyBlock = new UMAMaterialPropertyBlock();
if (src.PropertyBlock != null)
{
PropertyBlock.alwaysUpdate = src.PropertyBlock.alwaysUpdate;
PropertyBlock.shaderProperties = new List<UMAProperty>(src.PropertyBlock.shaderProperties.Count);
for (int i = 0; i < src.PropertyBlock.shaderProperties.Count; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ public UMAProperty property
}

[Serializable]
public class UMAMaterialPropertyBlock : ISerializationCallbackReceiver
public class UMAMaterialPropertyBlock : ScriptableObject, ISerializationCallbackReceiver
{
// If this is checked, the color will always update the
public bool alwaysUpdate;
Expand Down

0 comments on commit deaca5c

Please sign in to comment.