|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Explicit)] |
|
|
|
struct Data |
|
|
|
struct ClassData |
|
|
|
[FieldOffset(0)] |
|
|
|
public Color colorValue; |
|
|
|
[FieldOffset(0)] |
|
|
|
public Texture textureValue; |
|
|
|
[FieldOffset(0)] |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Explicit)] |
|
|
|
struct StructData |
|
|
|
{ |
|
|
|
|
|
|
|
[FieldOffset(0)] |
|
|
|
public Color colorValue; |
|
|
|
[FieldOffset(0)] |
|
|
|
public Vector4 vector4Value; |
|
|
|
[FieldOffset(0)] |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Data m_Data; |
|
|
|
ClassData m_ClassData; |
|
|
|
StructData m_StructData; |
|
|
|
|
|
|
|
public Color colorValue |
|
|
|
{ |
|
|
|
|
|
|
throw new ArgumentException(string.Format(k_GetErrorMessage, PropertyType.Color, propType)); |
|
|
|
return m_Data.colorValue; |
|
|
|
return m_StructData.colorValue; |
|
|
|
m_Data.colorValue = value; |
|
|
|
m_StructData.colorValue = value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
if (propType != PropertyType.Texture2D && propType != PropertyType.Texture2DArray && propType != PropertyType.Texture3D) |
|
|
|
throw new ArgumentException(string.Format(k_GetErrorMessage, PropertyType.Texture2D, propType)); |
|
|
|
return m_Data.textureValue; |
|
|
|
return m_ClassData.textureValue; |
|
|
|
m_Data.textureValue = value; |
|
|
|
m_ClassData.textureValue = value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
if (propType != PropertyType.Cubemap) |
|
|
|
throw new ArgumentException(string.Format(k_GetErrorMessage, PropertyType.Cubemap, propType)); |
|
|
|
return m_Data.cubemapValue; |
|
|
|
return m_ClassData.cubemapValue; |
|
|
|
m_Data.cubemapValue = value; |
|
|
|
m_ClassData.cubemapValue = value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
if (propType != PropertyType.Gradient) |
|
|
|
throw new ArgumentException(string.Format(k_GetErrorMessage, PropertyType.Gradient, propType)); |
|
|
|
return m_Data.gradientValue; |
|
|
|
return m_ClassData.gradientValue; |
|
|
|
m_Data.gradientValue = value; |
|
|
|
m_ClassData.gradientValue = value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
if (propType != PropertyType.Vector2 && propType != PropertyType.Vector3 && propType != PropertyType.Vector4) |
|
|
|
throw new ArgumentException(string.Format(k_GetErrorMessage, PropertyType.Vector4, propType)); |
|
|
|
return m_Data.vector4Value; |
|
|
|
return m_StructData.vector4Value; |
|
|
|
} |
|
|
|
set |
|
|
|
{ |
|
|
|
|
|
|
m_Data.vector4Value = value; |
|
|
|
m_StructData.vector4Value = value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
if (propType != PropertyType.Vector1) |
|
|
|
throw new ArgumentException(string.Format(k_GetErrorMessage, PropertyType.Vector1, propType)); |
|
|
|
return m_Data.floatValue; |
|
|
|
return m_StructData.floatValue; |
|
|
|
m_Data.floatValue = value; |
|
|
|
m_StructData.floatValue = value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
if (propType != PropertyType.Boolean) |
|
|
|
throw new ArgumentException(string.Format(k_GetErrorMessage, PropertyType.Boolean, propType)); |
|
|
|
return m_Data.booleanValue; |
|
|
|
return m_StructData.booleanValue; |
|
|
|
m_Data.booleanValue = value; |
|
|
|
m_StructData.booleanValue = value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
public void SetMaterialPropertyBlockValue(MaterialPropertyBlock block) |
|
|
|
{ |
|
|
|
if ((propType == PropertyType.Texture2D || propType == PropertyType.Texture2DArray || propType == PropertyType.Texture3D) && textureValue != null) |
|
|
|
block.SetTexture(name, m_Data.textureValue); |
|
|
|
block.SetTexture(name, m_ClassData.textureValue); |
|
|
|
block.SetTexture(name, m_Data.cubemapValue); |
|
|
|
block.SetTexture(name, m_ClassData.cubemapValue); |
|
|
|
block.SetColor(name, m_Data.colorValue); |
|
|
|
block.SetColor(name, m_StructData.colorValue); |
|
|
|
block.SetVector(name, m_Data.vector4Value); |
|
|
|
block.SetVector(name, m_StructData.vector4Value); |
|
|
|
block.SetFloat(name, m_Data.floatValue); |
|
|
|
block.SetFloat(name, m_StructData.floatValue); |
|
|
|
block.SetFloat(name, m_Data.booleanValue ? 1 : 0); |
|
|
|
block.SetFloat(name, m_StructData.booleanValue ? 1 : 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|