Inheritance: ScriptableObject, IEquivable
示例#1
0
		private void ClearCache()
		{
			if (_toolsInfoSerializedObject != null)
			{
				SerializedProperty isPaintingProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_isPainting");
				PaintingFinished(isPaintingProperty);
			}

			_selectedAttributesStore = null;
			_selectedAttributeData = null;

			_attributesStores.Clear();
			_serializedAttributesStoresCache.Clear();

			if(_editPointBoxMaterial != null)
			{
				HEU_MaterialFactory.DestroyNonAssetMaterial(_editPointBoxMaterial, false);
				_editPointBoxMaterial = null;
			}

			DestroyEditPointBoxMesh();

			_dragMouseDown = false;

			_asset = null;

			_toolsInfo = null;
		}
示例#2
0
		// LOGIC ------------------------------------------------------------------------------------------------------


		private void OnEnable()
		{
			// This forces UI cache to be regenerated
			_toolsInfo = null;
			_toolsInfoSerializedObject = null;

			// Callback will be used to disable this tool and reset state
			Selection.selectionChanged += SelectionChangedCallback;
		}
示例#3
0
		public void PaintAttribute(HEU_AttributeData attributeData, HEU_ToolsInfo sourceTools, int attributeIndex, float paintFactor, SetAttributeValueFunc setAttrFunc)
		{
			if(attributeData._attributeState == HEU_AttributeData.AttributeState.INVALID)
			{
				return;
			}

			int targetIndex = attributeIndex * attributeData._attributeInfo.tupleSize;
			setAttrFunc(attributeData, targetIndex, sourceTools, 0, paintFactor);

			SetAttributeDataDirty(attributeData);
		}
		// LOGIC ------------------------------------------------------------------------------------------------------


		private void OnEnable()
		{
			// This forces UI cache to be regenerated
			_toolsInfo = null;
			_toolsInfoSerializedObject = null;

			GUISkin heuSkin = HEU_EditorUI.LoadHEUSkin();
			_toolsBGStyle = heuSkin.GetStyle("toolsbg"); 

			// Callback will be used to disable this tool and reset state
			Selection.selectionChanged += SelectionChangedCallback;
		}
示例#5
0
	private void DrawPaintModeInfo()
	{
	    bool bFillInvoked = false;

	    float uiWidth = _editorUIRect.width * _infoPanelSettingsWidth;

	    using (var verticalSpace = new GUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.MaxWidth(uiWidth)))
	    {
		// Attribute Selection, and paint values

		DrawAttributeSelection();

		DrawPaintAttributeValues();

		SerializedProperty paintMeshProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_paintMeshVisiblity");
		if (paintMeshProperty != null)
		{
		    int currentVisibility = paintMeshProperty.enumValueIndex;
		    EditorGUILayout.PropertyField(paintMeshProperty, new GUIContent("Paint Mesh Visiblity"));
		    if (currentVisibility != paintMeshProperty.enumValueIndex)
		    {
			ChangePaintMeshVisiblity((HEU_ToolsInfo.PaintMeshVisibility)paintMeshProperty.enumValueIndex);
		    }
		}
	    }

	    using (var verticalSpace = new GUILayout.VerticalScope(EditorStyles.helpBox))
	    {
		// Tool Settings

		HEU_EditorUtility.EditorDrawBoolProperty(_toolsInfoSerializedObject, "_liveUpdate", _cookOnMouseReleaseLabel, "Auto-cook on mouse release when painting.");

		HEU_EditorUtility.EditorDrawFloatProperty(_toolsInfoSerializedObject, "_paintBrushSize", _brushSizeLabel, "Change brush size via Shift + drag or Shift + mouse scroll.");
		HEU_EditorUtility.EditorDrawFloatProperty(_toolsInfoSerializedObject, "_paintBrushOpacity", _brushOpacityLabel, "Blending factor when merging source and destination colors.");

		HEU_EditorUtility.EditorDrawSerializedProperty(_toolsInfoSerializedObject, "_paintMergeMode", _brushMergeMode, "How paint color is applied to surface.");

		HEU_EditorUtility.EditorDrawSerializedProperty(_toolsInfoSerializedObject, "_brushHandleColor", _brushHandleColor, "Color of the brush handle in Scene.");

		bFillInvoked = GUILayout.Button(_paintFillLabel, GUILayout.Height(_buttonHeight));
	    }

	    if (_selectedAttributesStore != null)
	    {
		if (bFillInvoked)
		{
		    HEU_ToolsInfo toolsInfo = _toolsInfoSerializedObject.targetObject as HEU_ToolsInfo;
		    _selectedAttributesStore.FillAttribute(_selectedAttributeData, toolsInfo);

		    _GUIChanged = true;
		}
	    }
	}
示例#6
0
		public void GenerateCache()
		{
			_toolsInfo = _asset.ToolsInfo;
			_toolsInfo._recacheRequired = false;
			_toolsInfoSerializedObject = new SerializedObject(_toolsInfo);

			CacheAttributesStores();

			if (_interactionMode == ToolInteractionMode.EDIT)
			{
				UpdateShowOnlyEditGeometry();
			}
		}
示例#7
0
		public void FillAttribute(HEU_AttributeData attributeData, HEU_ToolsInfo sourceTools)
		{
			if(attributeData._attributeState == HEU_AttributeData.AttributeState.INVALID)
			{
				return;
			}

			HEU_AttributesStore.SetAttributeValueFunc setAttrFunc = HEU_AttributesStore.GetAttributeSetValueFunction(attributeData._attributeType, sourceTools._paintMergeMode);
			if (setAttrFunc == null)
			{
				return;
			}

			int tupleSize = attributeData._attributeInfo.tupleSize;
			int count = attributeData._attributeInfo.count;
			for (int pt = 0; pt < count; ++pt)
			{
				setAttrFunc(attributeData, pt * tupleSize, sourceTools, 0, sourceTools._paintBrushOpacity);
			}

			SetAttributeDataDirty(attributeData);
		}
示例#8
0
		public static void SetAttributeValueString(HEU_AttributeData attributeData, int targetIndex, HEU_ToolsInfo sourceTools, int sourceIndex, float factor)
		{
			int numValues = sourceTools._paintStringValue.Length;
			for (int i = 0; i < numValues; ++i)
			{
				attributeData._stringValues[targetIndex + i] = sourceTools._paintStringValue[sourceIndex + i];
			}
		}
示例#9
0
		public static void MultiplyAttributeValueFloat(HEU_AttributeData attributeData, int targetIndex, HEU_ToolsInfo sourceTools, int sourceIndex, float factor)
		{
			int numValues = sourceTools._paintFloatValue.Length;
			for (int i = 0; i < numValues; ++i)
			{
				attributeData._floatValues[targetIndex + i] = Mathf.Lerp(attributeData._floatValues[targetIndex + i], attributeData._floatValues[targetIndex + i] * sourceTools._paintFloatValue[sourceIndex + i], factor);
			}
		}
示例#10
0
		public static void SubtractAttributeValueFloat(HEU_AttributeData attributeData, int targetIndex, HEU_ToolsInfo sourceTools, int sourceIndex, float factor)
		{
			int numValues = sourceTools._paintFloatValue.Length;
			for (int i = 0; i < numValues; ++i)
			{
				attributeData._floatValues[targetIndex + i] -= sourceTools._paintFloatValue[sourceIndex + i] * factor;
			}
		}
示例#11
0
		public static void MultiplyAttributeValueInt(HEU_AttributeData attributeData, int targetIndex, HEU_ToolsInfo sourceTools, int sourceIndex, float factor)
		{
			int numValues = sourceTools._paintIntValue.Length;
			for (int i = 0; i < numValues; ++i)
			{
				attributeData._intValues[targetIndex + i] = Mathf.RoundToInt(Mathf.Lerp((float)attributeData._intValues[targetIndex + i], (float)attributeData._intValues[targetIndex + i] * (float)sourceTools._paintIntValue[sourceIndex + i], factor));
			}
		}
示例#12
0
		public static void SubtractAttributeValueInt(HEU_AttributeData attributeData, int targetIndex, HEU_ToolsInfo sourceTools, int sourceIndex, float factor)
		{
			int numValues = sourceTools._paintIntValue.Length;
			for (int i = 0; i < numValues; ++i)
			{
				attributeData._intValues[targetIndex + i] -= Mathf.RoundToInt((float)sourceTools._paintIntValue[sourceIndex + i] * factor);
			}
		}