HoudiniEngineUnity.HEU_AttributeData.IsColorAttribute C# (CSharp) Method

IsColorAttribute() public method

public IsColorAttribute ( ) : bool
return bool
	public bool IsColorAttribute() { return _name.Equals(HEU_HAPIConstants.HAPI_ATTRIB_COLOR) || _attributeInfo.typeInfo == HAPI_AttributeTypeInfo.HAPI_ATTRIBUTE_TYPE_COLOR; }

Usage Example

Esempio n. 1
0
		private void DrawPaintAttributeValues()
		{
			// Display the values as editable fields

			if (_selectedAttributeData == null)
			{
				return;
			}

			if(!_selectedAttributesStore.HasMeshForPainting())
			{
				HEU_EditorUI.DrawWarningLabel(_noMeshForPainting);
				return;
			}

			SerializedProperty selectedToolsValuesProperty = null;

			if (_selectedAttributeData._attributeType == HEU_AttributeData.AttributeType.INT)
			{
				selectedToolsValuesProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_paintIntValue");
				if (selectedToolsValuesProperty != null)
				{
					ResizeSerializedPropertyArray(selectedToolsValuesProperty, _selectedAttributeData._attributeInfo.tupleSize);
					HEU_EditorUtility.EditorDrawArrayProperty(selectedToolsValuesProperty, HEU_EditorUtility.EditorDrawIntProperty, _paintValuesLabel);
				}
			}
			else if (_selectedAttributeData._attributeType == HEU_AttributeData.AttributeType.FLOAT)
			{
				selectedToolsValuesProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_paintFloatValue");
				if (selectedToolsValuesProperty != null)
				{
					ResizeSerializedPropertyArray(selectedToolsValuesProperty, _selectedAttributeData._attributeInfo.tupleSize);
					HEU_EditorUtility.EditorDrawArrayProperty(selectedToolsValuesProperty, HEU_EditorUtility.EditorDrawFloatProperty, _paintValuesLabel);
				}

				// Display paint color selector if this is a color attribute
				if (_selectedAttributeData.IsColorAttribute())
				{
					Color color = Color.white;

					if (selectedToolsValuesProperty.arraySize >= 3)
					{
						color.r = selectedToolsValuesProperty.GetArrayElementAtIndex(0).floatValue;
						color.g = selectedToolsValuesProperty.GetArrayElementAtIndex(1).floatValue;
						color.b = selectedToolsValuesProperty.GetArrayElementAtIndex(2).floatValue;

						if (selectedToolsValuesProperty.arraySize >= 4)
						{
							color.a = selectedToolsValuesProperty.GetArrayElementAtIndex(3).floatValue;
						}
					}

					Color newColor = EditorGUILayout.ColorField(_paintColorLabel, color);
					if (color != newColor)
					{
						if (selectedToolsValuesProperty.arraySize >= 3)
						{
							selectedToolsValuesProperty.GetArrayElementAtIndex(0).floatValue = newColor.r;
							selectedToolsValuesProperty.GetArrayElementAtIndex(1).floatValue = newColor.g;
							selectedToolsValuesProperty.GetArrayElementAtIndex(2).floatValue = newColor.b;

							if (selectedToolsValuesProperty.arraySize >= 4)
							{
								selectedToolsValuesProperty.GetArrayElementAtIndex(3).floatValue = newColor.a;
							}
						}
					}
				}

			}
			else if (_selectedAttributeData._attributeType == HEU_AttributeData.AttributeType.STRING)
			{
				selectedToolsValuesProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_paintStringValue");
				if (selectedToolsValuesProperty != null)
				{
					ResizeSerializedPropertyArray(selectedToolsValuesProperty, _selectedAttributeData._attributeInfo.tupleSize);
					HEU_EditorUtility.EditorDrawArrayProperty(selectedToolsValuesProperty, HEU_EditorUtility.EditorDrawTextProperty, _paintValuesLabel);
				}
			}

			if (!_selectedAttributeData.IsColorAttribute())
			{
				HEU_EditorUtility.EditorDrawSerializedProperty(_toolsInfoSerializedObject, "_affectedAreaPaintColor", _affectedAreaColorLabel, "Color to show painted area.");
			}
		}