示例#1
0
		public override void OnInspectorGUI()
		{
			if (_geoSync == null)
			{
				AcquireTarget();
			}

			using (new EditorGUILayout.VerticalScope())
			{
				bool bSyncing = _geoSync.IsSyncing;

				EditorGUILayout.LabelField(_fileLabelContent);

				using (new EditorGUILayout.HorizontalScope())
				{
					_geoSync._filePath = EditorGUILayout.DelayedTextField(_geoSync._filePath);

					GUIStyle buttonStyle = HEU_EditorUI.GetNewButtonStyle_MarginPadding(0, 0);
					if (GUILayout.Button("...", buttonStyle, GUILayout.Width(30), GUILayout.Height(18)))
					{
						string filePattern = "*.bgeo";
						_geoSync._filePath = EditorUtility.OpenFilePanel("Select File", _geoSync._filePath, filePattern);
					}
				}

				HEU_EditorUI.DrawSeparator();

				if (bSyncing)
				{
					EditorGUILayout.LabelField(_statusSyncContent);

					if (GUILayout.Button(_stopContent))
					{
						_geoSync.StopSync();
					}
				}
				else
				{
					EditorGUILayout.LabelField(_statusIdleContent);

					using (new EditorGUILayout.HorizontalScope())
					{
						bool bLoaded = _geoSync.IsLoaded();

						if (GUILayout.Button(_syncContent))
						{
							_geoSync.StartSync();
						}

						//GUILayout.FlexibleSpace();

						using (new EditorGUI.DisabledScope(!bLoaded))
						{
							if (GUILayout.Button(_unloadContent))
							{
								_geoSync.Unload();
							}
						}
					}
				}

				if (!string.IsNullOrEmpty(_geoSync._logStr))
				{
					EditorGUILayout.LabelField("Log: " + _geoSync._logStr);
				}
			}
		}
		public void DrawToolsEditor(HEU_HoudiniAsset asset)
		{
			_currentCamera = Camera.current;

			_controlID = GUIUtility.GetControlID(FocusType.Passive);

			_currentEvent = Event.current;
			_mousePosition = HEU_EditorUI.GetMousePosition(ref _currentEvent, _currentCamera);
			_mouseWithinSceneView = HEU_GeneralUtility.IsMouseWithinSceneView(_currentCamera, _mousePosition);

			float pixelsPerPoint = HEU_EditorUI.GetPixelsPerPoint();
			_screenWidth = Screen.width / pixelsPerPoint;
			_screenHeight = Screen.height / pixelsPerPoint;

			_editorUIRect = new Rect(10, _screenHeight - (_infoPanelHeight + 45), _screenWidth - 25, _infoPanelHeight);

			_mouseOverInfoPanel = HEU_GeneralUtility.IsMouseOverRect(_currentCamera, _mousePosition, ref _editorUIRect);

			if (_asset == null || (_asset != asset) || DoesCacheNeedRegeneration())
			{
				ClearCache();

				_asset = asset;

				GenerateCache();
			}

			_GUIChanged = false;

			EditorGUI.BeginChangeCheck();

			// Draw the info panel first. This gets the user selected node and attribute.
			DrawInfoPanel();

			// Now update the scene with tool handles (e.g. paint brush) and geo (edit box mesh)
			if (_interactionMode == ToolInteractionMode.VIEW)
			{
				DrawViewModeScene();
			}
			else if (_interactionMode == ToolInteractionMode.PAINT)
			{
				DrawPaintModeScene();
			}
			else if (_interactionMode == ToolInteractionMode.EDIT)
			{
				DrawEditModeScene();
			}

			if (EditorGUI.EndChangeCheck() || _GUIChanged)
			{
				// Presume that if a serialized object was cached, then most likely it was modified
				foreach (var attributeStoresPair in _serializedAttributesStoresCache)
				{
					attributeStoresPair.Value.ApplyModifiedProperties();
				}

				_toolsInfoSerializedObject.ApplyModifiedProperties();
			}

			
			// Ignoe deselect if over info panel
			if(_mouseOverInfoPanel && _currentEvent.type == EventType.MouseDown && (!_currentEvent.control && !_currentEvent.alt && !_currentEvent.shift))
			{
				GUIUtility.hotControl = _controlID;
				_currentEvent.Use();
			}
		}
		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.");
			}
		}
		private bool DrawDetailsCooking()
		{
			bool bChanged = false;

			{
				bool oldValue = HEU_PluginSettings.CookingEnabled;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Enable Cooking");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.CookingEnabled = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.CookingTriggersDownstreamCooks;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Cooking Triggers Downstream Cooks");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.CookingTriggersDownstreamCooks = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.PushUnityTransformToHoudini;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Push Unity Transform To Houdini");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.PushUnityTransformToHoudini = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.TransformChangeTriggersCooks;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Transform Change Triggers Cooks");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.TransformChangeTriggersCooks = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.CookTemplatedGeos;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Import Templated Geos");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.CookTemplatedGeos = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.SupportHoudiniBoxType;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Support Houdini Box Type");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.SupportHoudiniBoxType = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.SupportHoudiniSphereType;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Support Houdini Sphere Type");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.SupportHoudiniSphereType = newValue;
					bChanged = true;
				}
			}

			return bChanged;
		}
		private bool DrawSessionSettings()
		{
			bool bChanged = false;

			HEU_EditorUI.DrawSeparator();

			EditorGUIUtility.labelWidth = 250;
			{
				string oldValue = HEU_PluginSettings.Session_PipeName;
				string newValue = EditorGUILayout.DelayedTextField("Pipe Session Name", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.Session_PipeName = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.Session_Localhost;
				string newValue = EditorGUILayout.DelayedTextField("Socket Session Host Name", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.Session_Localhost = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				int oldValue = HEU_PluginSettings.Session_Port;
				int newValue = EditorGUILayout.DelayedIntField("Socket Session Port", oldValue);
				if (oldValue != newValue)
				{
					HEU_PluginSettings.Session_Port = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				float oldValue = HEU_PluginSettings.Session_Timeout;
				float newValue = EditorGUILayout.DelayedFloatField("Session Timeout", oldValue);
				if (oldValue != newValue)
				{
					HEU_PluginSettings.Session_Timeout = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.Session_AutoClose;
				bool newValue = EditorGUILayout.Toggle("Session Auto Close", oldValue);
				if (oldValue != newValue)
				{
					HEU_PluginSettings.Session_AutoClose = newValue;
					bChanged = true;
				}
			}

			EditorGUIUtility.labelWidth = 0;

			return bChanged;
		}
		private void DrawSelectedTOPNode()
		{
			HEU_TOPNetworkData topNetworkData = _assetLink.GetSelectedTOPNetwork();
			if (topNetworkData == null)
			{
				return;
			}

			using(new EditorGUILayout.VerticalScope(_backgroundStyle))
			{
				//HEU_EditorUI.DrawHeadingLabel("Internal TOP Nodes");

				int numTopNodes = topNetworkData._topNodeNames.Length;
				if (numTopNodes > 0)
				{
					using (new EditorGUILayout.HorizontalScope())
					{
						EditorGUILayout.PrefixLabel(_topNodeChooseLabel);

						int selectedIndex = Mathf.Clamp(topNetworkData._selectedTOPIndex, 0, numTopNodes);
						int newSelectedIndex = EditorGUILayout.Popup(selectedIndex, topNetworkData._topNodeNames);
						if (newSelectedIndex != selectedIndex)
						{
							_assetLink.SelectTOPNode(topNetworkData, newSelectedIndex);
						}

						//EditorGUILayout.Space();
					}
				}
				else
				{
					EditorGUILayout.PrefixLabel(_topNodeNoneLabel);
				}

				EditorGUILayout.Space();

				HEU_TOPNodeData topNode = _assetLink.GetSelectedTOPNode();
				if (topNode != null)
				{
					topNode._tags._autoload = EditorGUILayout.Toggle(_autoloadContent, topNode._tags._autoload);

					bool showResults = topNode._showResults;
					showResults = EditorGUILayout.Toggle(_showHideResultsContent, showResults);
					if (showResults != topNode._showResults)
					{
						topNode._showResults = showResults;
						_assetLink.UpdateTOPNodeResultsVisibility(topNode);
					}

					EditorGUILayout.Space();

					using (new EditorGUILayout.HorizontalScope())
					{
						//GUILayout.Space(15);

						if (GUILayout.Button(_buttonDirtyContent))
						{
							_assetLink.DirtyTOPNode(topNode);
						}

						if (GUILayout.Button(_buttonCookContent))
						{
							_assetLink.CookTOPNode(topNode);
						}

						//GUILayout.Space(15);
					}

					EditorGUILayout.Space();

					using (new EditorGUILayout.VerticalScope(HEU_EditorUI.GetSectionStyle()))
					{
						EditorGUILayout.LabelField("TOP Node State: " + _assetLink.GetTOPNodeStatus(topNode));

						EditorGUILayout.Space();

						EditorGUILayout.LabelField(_topNodeStatusLabel);
						DrawWorkItemTally(topNode._workItemTally);
					}
				}
			}
		}
        private static Vector3 DoDragHandleAxis(DragAxisInfo axisInfo, Vector3 position, ref DragHandleResult result)
        {
            // Must request a control ID for each interactible control in the GUI that can respond to events
            int id = GUIUtility.GetControlID(axisInfo._handleHash, FocusType.Passive);

            float handleSize = HandleUtility.GetHandleSize(position);

            Camera camera = Camera.current;

            Event currentEvent = Event.current;

            Vector2 mousePos = HEU_EditorUI.GetMousePosition(ref currentEvent, camera);

            Vector3   handlePosition     = Handles.matrix.MultiplyPoint(position);
            Matrix4x4 cachedHandleMatrix = Handles.matrix;

            int mouseButtonID = Event.current.button;

            // Process events (using GetTypeForControl to filter events relevant to this control)
            switch (currentEvent.GetTypeForControl(id))
            {
            case EventType.MouseDown:
            {
                if (HandleUtility.nearestControl == id && (mouseButtonID == 0 || mouseButtonID == 1))
                {
                    GUIUtility.hotControl = id;

                    axisInfo._dragMouseCurrent = axisInfo._dragMouseStart = mousePos;
                    axisInfo._dragWorldStart   = position;
                    axisInfo._handleHasMoved   = false;

                    currentEvent.Use();
                    EditorGUIUtility.SetWantsMouseJumping(1);

                    if (mouseButtonID == 0)
                    {
                        result = DragHandleResult.LMB_PRESS;
                    }
                    else if (mouseButtonID == 1)
                    {
                        result = DragHandleResult.RMB_PRESS;
                    }
                }

                break;
            }

            case EventType.MouseUp:
            {
                if (GUIUtility.hotControl == id && (mouseButtonID == 0 || mouseButtonID == 1))
                {
                    GUIUtility.hotControl = 0;
                    currentEvent.Use();
                    EditorGUIUtility.SetWantsMouseJumping(0);

                    if (mouseButtonID == 0)
                    {
                        result = DragHandleResult.LMB_RELEASE;
                    }
                    else if (mouseButtonID == 1)
                    {
                        result = DragHandleResult.RMB_RELEASE;
                    }

                    // Double-click
                    if (mousePos == axisInfo._dragMouseStart)
                    {
                        bool doubleClick = (axisInfo._handleClickID == id) && (Time.realtimeSinceStartup - axisInfo._handleClickTime < _handleDoubleClikcInterval);

                        axisInfo._handleClickID   = id;
                        axisInfo._handleClickTime = Time.realtimeSinceStartup;

                        if (mouseButtonID == 0)
                        {
                            result = doubleClick ? DragHandleResult.LMB_DOUBLECLICK : DragHandleResult.LMB_CLICK;
                        }
                        else if (mouseButtonID == 1)
                        {
                            result = doubleClick ? DragHandleResult.RMB_DOUBLECLICK : DragHandleResult.RMB_CLICK;
                        }
                    }
                }

                break;
            }

            case EventType.MouseDrag:
            {
                if (GUIUtility.hotControl == id)
                {
                    if (axisInfo._dragAxis == DragAxis.ALL_AXIS)
                    {
                        // Free movement - (all axis)
                        // Flip y because Unity is inverted
                        axisInfo._dragMouseCurrent += new Vector2(currentEvent.delta.x, -currentEvent.delta.y);

                        Vector3 position2 = camera.WorldToScreenPoint(Handles.matrix.MultiplyPoint(axisInfo._dragWorldStart))
                                            + (Vector3)(axisInfo._dragMouseCurrent - axisInfo._dragMouseStart);

                        position = Handles.matrix.inverse.MultiplyPoint(camera.ScreenToWorldPoint(position2));
                    }
                    else
                    {
                        // Linear movement (constraint to current axis)

                        axisInfo._dragMouseCurrent += new Vector2(currentEvent.delta.x, currentEvent.delta.y);

                        float mag = HandleUtility.CalcLineTranslation(axisInfo._dragMouseStart, axisInfo._dragMouseCurrent, axisInfo._dragWorldStart, axisInfo._direction);
                        position = axisInfo._dragWorldStart + axisInfo._direction * mag;
                    }

                    if (mouseButtonID == 0)
                    {
                        result = DragHandleResult.LMB_DRAG;
                    }
                    else if (mouseButtonID == 1)
                    {
                        result = DragHandleResult.RMB_DRAG;
                    }

                    axisInfo._handleHasMoved = true;

                    GUI.changed = true;
                    currentEvent.Use();
                }

                break;
            }

            case EventType.MouseMove:
            case EventType.Repaint:
            {
                Color handleColor = Handles.color;
                if ((GUIUtility.hotControl == id && axisInfo._handleHasMoved) || (HandleUtility.nearestControl == id))
                {
                    Handles.color = Color.yellow;
                }
                else
                {
                    Handles.color = axisInfo._axisColor;
                }

                Handles.matrix = Matrix4x4.identity;
                if (axisInfo._dragAxis == DragAxis.ALL_AXIS)
                {
                    HEU_EditorUI.DrawCubeCap(id, handlePosition, Quaternion.identity, handleSize * 0.25f);
                }
                else
                {
                    HEU_EditorUI.DrawArrowCap(id, handlePosition, Quaternion.LookRotation(axisInfo._direction), handleSize);
                }
                Handles.matrix = cachedHandleMatrix;

                Handles.color = handleColor;

                // This forces a Repaint. We want this when we change the axis color due to being cursor being nearest.
                if (currentEvent.type == EventType.MouseMove && HandleUtility.nearestControl == id)
                {
                    SceneView.RepaintAll();
                }

                break;
            }

            case EventType.Layout:
            {
                // AddControl tells Unity where each Handle is relative to the current mouse position

                Handles.matrix = Matrix4x4.identity;
                if (axisInfo._dragAxis == DragAxis.ALL_AXIS)
                {
                    float distance = handleSize * 0.3f;
                    HandleUtility.AddControl(id, HandleUtility.DistanceToCircle(handlePosition, distance));
                }
                else
                {
                    HandleUtility.AddControl(id, HandleUtility.DistanceToLine(handlePosition, handlePosition + axisInfo._direction * handleSize) * 0.4f);
                }
                Handles.matrix = cachedHandleMatrix;
                break;
            }
            }

            return(position);
        }
示例#8
0
	private void DrawPointCaps(HEU_Curve curve, Color capColor)
	{
	    List<Vector3> points = curve.GetAllPoints();

	    Color defaultColor = Handles.color;
	    Handles.color = capColor;
	    for (int i = 0; i < points.Count; ++i)
	    {
		Vector3 pointPos = curve.GetTransformedPosition(points[i]);
		HEU_EditorUI.DrawSphereCap(GUIUtility.GetControlID(FocusType.Passive), pointPos, Quaternion.identity, HEU_EditorUI.GetHandleSize(pointPos));
	    }
	    Handles.color = defaultColor;
	}
示例#9
0
	private void DrawSelectionBox(Vector3 mousePosition, bool bAutoSelectPoints)
	{
	    // First draw the selection box from drag start to current mouse position.

	    // Calculating the bounding box in screenspace then converting to world seems to
	    // produce the best lines in the Scene view regardless of camera orientation.
	    Vector3 xVec = new Vector3((mousePosition.x - _dragMouseStart.x), 0, 0);
	    Vector3 yVec = new Vector3(0, (mousePosition.y - _dragMouseStart.y), 0);

	    Vector3 s00 = _dragMouseStart;
	    Vector3 s01 = _dragMouseStart + xVec;
	    Vector3 s10 = _dragMouseStart + yVec;
	    Vector3 s11 = _dragMouseStart + xVec + yVec;

	    Vector3 camFwd = _currentCamera.transform.forward;
	    float depth = Mathf.Abs((_currentCamera.transform.position + camFwd * 2f).z);
	    Vector3 w00 = _currentCamera.ScreenToWorldPoint(new Vector3(s00.x, s00.y, depth));
	    Vector3 w01 = _currentCamera.ScreenToWorldPoint(new Vector3(s01.x, s01.y, depth));
	    Vector3 w10 = _currentCamera.ScreenToWorldPoint(new Vector3(s10.x, s10.y, depth));
	    Vector3 w11 = _currentCamera.ScreenToWorldPoint(new Vector3(s11.x, s11.y, depth));

	    Color defaultColor = Handles.color;
	    Handles.color = Color.white;
	    Vector3[] lines = new Vector3[]
	    {
				w00, w01, w11, w10, w00
	    };
	    Handles.DrawSolidRectangleWithOutline(lines, _selectionBoxFillColor, _selectionBoxOutlineColor);
	    Handles.color = defaultColor;

	    if (bAutoSelectPoints)
	    {
		// Now we select points withing the selection box

		DeselectAllPoints();

		// We'll use a rect to test against each curve point
		Rect selectionRect = new Rect(_dragMouseStart.x, _dragMouseStart.y, (mousePosition.x - _dragMouseStart.x), (mousePosition.y - _dragMouseStart.y));

		foreach (HEU_Curve curve in _curves)
		{
		    int numPoints = curve.GetNumPoints();

		    for (int i = 0; i < numPoints; ++i)
		    {
			Vector3 pointPosition = curve.GetTransformedPoint(i);

			Vector3 pointScreenPosition = HEU_EditorUI.GetHandleWorldToScreenPosition(pointPosition, _currentCamera);

			if (selectionRect.Contains(pointScreenPosition, true))
			{
			    SelectAddPoint(curve, i);

			    Handles.color = _selectedPointColor;
			}
			else
			{
			    Handles.color = _unselectedPointColor;
			}

			HEU_EditorUI.DrawSphereCap(i, pointPosition, Quaternion.identity, HEU_EditorUI.GetHandleSize(pointPosition));
			Handles.color = defaultColor;
		    }
		}
	    }
	}
示例#10
0
		private void DrawCurvesSection(HEU_HoudiniAsset asset, SerializedObject assetObject)
		{
			if (asset.GetEditableCurveCount() <= 0)
			{
				return;
			}

			GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);
			buttonStyle.fontSize = 11;
			buttonStyle.alignment = TextAnchor.MiddleCenter;
			buttonStyle.fixedHeight = 24;
			buttonStyle.margin.left = 34;

			HEU_EditorUI.BeginSection();
			{
				SerializedProperty showCurvesProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_showCurvesSection");
				if (showCurvesProperty != null)
				{
					showCurvesProperty.boolValue = HEU_EditorUI.DrawFoldOut(showCurvesProperty.boolValue, "CURVES");
					if (showCurvesProperty.boolValue)
					{
						SerializedProperty curveEditorProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveEditorEnabled");
						if (curveEditorProperty != null)
						{
							EditorGUILayout.PropertyField(curveEditorProperty);
						}

						HEU_EditorUI.DrawHeadingLabel("Collision Settings");
						EditorGUI.indentLevel++;

						string projectLabel = "Project Curves To ";
						List<HEU_Curve> curves = asset.GetCurves();

						SerializedProperty curveCollisionProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveDrawCollision");
						if (curveCollisionProperty != null)
						{
							EditorGUILayout.PropertyField(curveCollisionProperty, new GUIContent("Collision Type"));
							if (curveCollisionProperty.enumValueIndex == (int)HEU_Curve.CurveDrawCollision.COLLIDERS)
							{
								HEU_EditorUtility.EditorDrawSerializedProperty(assetObject, "_curveDrawColliders", label: "Colliders");
								projectLabel += "Colliders";
							}
							else if (curveCollisionProperty.enumValueIndex == (int)HEU_Curve.CurveDrawCollision.LAYERMASK)
							{
								HEU_EditorUtility.EditorDrawSerializedProperty(assetObject, "_curveDrawLayerMask", label: "Layer Mask");
								projectLabel += "Layer";
							}

							HEU_EditorUI.DrawSeparator();

							EditorGUI.indentLevel--;
							HEU_EditorUI.DrawHeadingLabel("Projection Settings");
							EditorGUI.indentLevel++;

							HEU_EditorUtility.EditorDrawSerializedProperty(assetObject, "_curveProjectDirection", label: "Project Direction", tooltip: "The ray cast direction for projecting the curve points.");
							HEU_EditorUtility.EditorDrawFloatProperty(assetObject, "_curveProjectMaxDistance", label: "Project Max Distance", tooltip: "The maximum ray cast distance for projecting the curve points.");

							_projectCurvePointsButton.text = projectLabel;
							if (GUILayout.Button(_projectCurvePointsButton, buttonStyle, GUILayout.MaxWidth(180)))
							{
								SerializedProperty projectDirProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveProjectDirection");
								SerializedProperty maxDistanceProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_curveProjectMaxDistance");

								Vector3 projectDir = projectDirProperty != null ? projectDirProperty.vector3Value : Vector3.down;
								float maxDistance = maxDistanceProperty != null ? maxDistanceProperty.floatValue : 0;

								for (int i = 0; i < curves.Count; ++i)
								{
									curves[i].ProjectToColliders(asset, projectDir, maxDistance);
								}
							}
						}

						EditorGUI.indentLevel--;

						HEU_EditorUI.DrawSeparator();

						for (int i = 0; i < curves.Count; ++i)
						{
							if (curves[i].Parameters != null)
							{
								DrawParameters(curves[i].Parameters, ref _curveParameterEditor);
							}
						}
					}
				}
			}
			HEU_EditorUI.EndSection();

			HEU_EditorUI.DrawSeparator();
		}
示例#11
0
		private void DrawTerrainSection(HEU_HoudiniAsset asset, SerializedObject assetObject)
		{
			int numVolumes = asset.GetVolumeCacheCount();
			if(numVolumes <= 0)
			{
				return;
			}

			HEU_EditorUI.BeginSection();
			{
				SerializedProperty showTerrainProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_showTerrainSection");
				if (showTerrainProperty != null)
				{
					showTerrainProperty.boolValue = HEU_EditorUI.DrawFoldOut(showTerrainProperty.boolValue, "TERRAIN");
					if (showTerrainProperty.boolValue)
					{
						// Draw each volume layer
						List<HEU_VolumeCache> volumeCaches = asset.GetVolumeCaches();
						int numCaches = volumeCaches.Count;
						for (int i = 0; i < numCaches; ++i)
						{
							SerializedObject cacheObjectSerialized = new SerializedObject(volumeCaches[i]);
							bool bChanged = false;
							bool bStrengthChanged = false;

							SerializedProperty layersProperty = cacheObjectSerialized.FindProperty("_layers");
							if (layersProperty == null || layersProperty.arraySize == 0)
							{
								continue;
							}

							string heading = string.Format("{0}-{1}:", volumeCaches[i].ObjectName, volumeCaches[i].GeoName);

							if (HEU_EditorUI.DrawFoldOutSerializedProperty(HEU_EditorUtility.GetSerializedProperty(cacheObjectSerialized, "_uiExpanded"), heading, ref bChanged))
							{
								EditorGUI.indentLevel++;

								int numlayers = layersProperty.arraySize;
								for (int j = 0; j < numlayers; ++j)
								{
									SerializedProperty layerProperty = layersProperty.GetArrayElementAtIndex(j);
									if (layerProperty == null)
									{
										continue;
									}

									// Skipping "height" layer on UI since its treated as Houdini-specific layer
									string layerName = layerProperty.FindPropertyRelative("_layerName").stringValue;
									if (layerName.Equals(HEU_Defines.HAPI_HEIGHTFIELD_LAYERNAME_HEIGHT))
									{
										continue;
									}
									layerName = string.Format("Layer: {0}", layerName);

									SerializedProperty uiExpandedProperty = layerProperty.FindPropertyRelative("_uiExpanded");
									bool bExpanded = uiExpandedProperty != null ? uiExpandedProperty.boolValue : true;
									bool bNewExpanded = HEU_EditorUI.DrawFoldOut(bExpanded, layerName);
									if (uiExpandedProperty != null && bExpanded != bNewExpanded)
									{
										bChanged = true;
										uiExpandedProperty.boolValue = bNewExpanded;
									}

									if (!bNewExpanded)
									{
										continue;
									}

									if (HEU_EditorUtility.EditorDrawFloatSliderProperty(layerProperty, "_strength", "Strength", "Amount to multiply the layer values by on import."))
									{
										bStrengthChanged = true;
									}

									HEU_EditorUI.DrawSeparator();
								}

								EditorGUI.indentLevel--;
							}

							if (bStrengthChanged)
							{
								SerializedProperty dirtyProperty = cacheObjectSerialized.FindProperty("_isDirty");
								if (dirtyProperty != null)
								{
									dirtyProperty.boolValue = true;
									bChanged = true;
								}
							}

							if(bChanged)
							{
								cacheObjectSerialized.ApplyModifiedProperties();
							}
						}
					}
				}
			}
			HEU_EditorUI.EndSection();

			HEU_EditorUI.DrawSeparator();
		}
示例#12
0
		/// <summary>
		/// Draw the Generate section.
		/// </summary>
		private static bool DrawGenerateSection(HEU_HoudiniAssetRoot assetRoot, SerializedObject assetRootSerializedObject, HEU_HoudiniAsset asset, SerializedObject assetObject)
		{
			bool bSkipDrawing = false;

			float separatorDistance = 5f;

			float screenWidth = EditorGUIUtility.currentViewWidth;

			float buttonHeight = 30f;
			float widthPadding = 55f;
			float doubleButtonWidth = Mathf.Round(screenWidth - widthPadding + separatorDistance);
			float singleButtonWidth = Mathf.Round((screenWidth - widthPadding) * 0.5f);

			GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);
			buttonStyle.fontStyle = FontStyle.Bold;
			buttonStyle.fontSize = 11;
			buttonStyle.alignment = TextAnchor.MiddleLeft;
			buttonStyle.fixedHeight = buttonHeight;
			buttonStyle.padding.left = 6;
			buttonStyle.padding.right = 6;
			buttonStyle.margin.left = 0;
			buttonStyle.margin.right = 0;

			GUIStyle centredButtonStyle = new GUIStyle(buttonStyle);
			centredButtonStyle.alignment = TextAnchor.MiddleCenter;

			GUIStyle buttonSetStyle = new GUIStyle(GUI.skin.box);
			RectOffset br = buttonSetStyle.margin;
			br.left = 4;
			br.right = 4;
			buttonSetStyle.margin = br;

			GUIStyle boxStyle = new GUIStyle(GUI.skin.GetStyle("ColorPickerBackground"));
			br = boxStyle.margin;
			br.left = 4;
			br.right = 4;
			boxStyle.margin = br;
			boxStyle.padding = br;

			GUIStyle promptButtonStyle = new GUIStyle(GUI.skin.button);
			promptButtonStyle.fontSize = 11;
			promptButtonStyle.alignment = TextAnchor.MiddleCenter;
			promptButtonStyle.fixedHeight = 30;
			promptButtonStyle.margin.left = 34;
			promptButtonStyle.margin.right = 34;

			_recookhdaContent.text = "  Recook Asset";

			HEU_HoudiniAsset.AssetBuildAction pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.NONE;
			SerializedProperty pendingBuildProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_requestBuildAction");
			if (pendingBuildProperty != null)
			{
				pendingBuildAction = (HEU_HoudiniAsset.AssetBuildAction)pendingBuildProperty.enumValueIndex;
			}

			// Track changes for the build and bake targets
			EditorGUI.BeginChangeCheck();

			HEU_HoudiniAsset.AssetCookStatus cookStatus = GetCookStatusFromSerializedAsset(assetObject);

			if (cookStatus == HEU_HoudiniAsset.AssetCookStatus.SELECT_SUBASSET)
			{
				// Prompt user to select subasset

				GUIStyle promptStyle = new GUIStyle(GUI.skin.label);
				promptStyle.fontStyle = FontStyle.Bold;
				promptStyle.normal.textColor = HEU_EditorUI.IsEditorDarkSkin() ? Color.green : Color.blue;
				EditorGUILayout.LabelField("SELECT AN ASSET TO INSTANTIATE:", promptStyle);

				EditorGUILayout.Separator();

				int selectedIndex = -1;
				string[] subassetNames = asset.SubassetNames;

				for (int i = 0; i < subassetNames.Length; ++i)
				{
					if (GUILayout.Button(subassetNames[i], promptButtonStyle))
					{
						selectedIndex = i;
						break;
					}

					EditorGUILayout.Separator();
				}

				if (selectedIndex >= 0)
				{
					SerializedProperty selectedIndexProperty = HEU_EditorUtility.GetSerializedProperty(assetObject, "_selectedSubassetIndex");
					if (selectedIndexProperty != null)
					{
						selectedIndexProperty.intValue = selectedIndex;
					}
				}

				bSkipDrawing = true;
			}
			else
			{
				HEU_EditorUI.BeginSection();
				{
					if (cookStatus == HEU_HoudiniAsset.AssetCookStatus.COOKING || cookStatus == HEU_HoudiniAsset.AssetCookStatus.POSTCOOK)
					{
						_recookhdaContent.text = "  Cooking Asset";
					}
					else if (cookStatus == HEU_HoudiniAsset.AssetCookStatus.LOADING || cookStatus == HEU_HoudiniAsset.AssetCookStatus.POSTLOAD)
					{
						_reloadhdaContent.text = "  Loading Asset";
					}

					SerializedProperty showGenerateProperty = assetObject.FindProperty("_showGenerateSection");

					showGenerateProperty.boolValue = HEU_EditorUI.DrawFoldOut(showGenerateProperty.boolValue, "GENERATE");
					if (showGenerateProperty.boolValue)
					{
						//bool bHasPendingAction = (pendingBuildAction != HEU_HoudiniAsset.AssetBuildAction.NONE) || (cookStatus != HEU_HoudiniAsset.AssetCookStatus.NONE);

						HEU_EditorUI.DrawSeparator();

						//EditorGUI.BeginDisabledGroup(bHasPendingAction);

						using (var hs = new EditorGUILayout.HorizontalScope(boxStyle))
						{
							if (GUILayout.Button(_reloadhdaContent, buttonStyle, GUILayout.Width(singleButtonWidth)))
							{
								pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.RELOAD;
								bSkipDrawing = true;
							}

							GUILayout.Space(separatorDistance);

							if (!bSkipDrawing && GUILayout.Button(_recookhdaContent, buttonStyle, GUILayout.Width(singleButtonWidth)))
							{
								pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.COOK;
								bSkipDrawing = true;
							}
						}

						using (var hs = new EditorGUILayout.HorizontalScope(boxStyle))
						{
							float tripleButtonWidth = Mathf.Round((screenWidth - widthPadding) * 0.33f);

							if (GUILayout.Button(_removeheContent, buttonStyle, GUILayout.Width(tripleButtonWidth)))
							{
								pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.STRIP_HEDATA;
								bSkipDrawing = true;
							}

							GUILayout.Space(separatorDistance);

							if (GUILayout.Button(_duplicateContent, buttonStyle, GUILayout.Width(tripleButtonWidth)))
							{
								pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.DUPLICATE;
								bSkipDrawing = true;
							}

							GUILayout.Space(separatorDistance);

							if (GUILayout.Button(_resetParamContent, buttonStyle, GUILayout.Width(tripleButtonWidth)))
							{
								pendingBuildAction = HEU_HoudiniAsset.AssetBuildAction.RESET_PARAMS;
								bSkipDrawing = true;
							}
						}

						//EditorGUI.EndDisabledGroup();

						HEU_EditorUI.DrawSeparator();
					}
				}

				HEU_EditorUI.EndSection();

				HEU_EditorUI.DrawSeparator();

				HEU_EditorUI.BeginSection();
				{
					SerializedProperty showBakeProperty = assetObject.FindProperty("_showBakeSection");

					showBakeProperty.boolValue = HEU_EditorUI.DrawFoldOut(showBakeProperty.boolValue, "BAKE");
					if (showBakeProperty.boolValue)
					{
						if (!bSkipDrawing)
						{
							// Bake -> New Instance, New Prefab, Existing instance or prefab

							using (var vs = new EditorGUILayout.HorizontalScope(boxStyle))
							{
								if (GUILayout.Button(_bakegameobjectContent, buttonStyle, GUILayout.Width(singleButtonWidth)))
								{
									asset.BakeToNewStandalone();
								}

								GUILayout.Space(separatorDistance);

								if (GUILayout.Button(_bakeprefabContent, buttonStyle, GUILayout.Width(singleButtonWidth)))
								{
									asset.BakeToNewPrefab();
								}
							}

							HEU_EditorUI.DrawSeparator();

							using (var hs2 = new EditorGUILayout.VerticalScope(boxStyle))
							{
								if (GUILayout.Button(_bakeandreplaceContent, centredButtonStyle, GUILayout.Width(doubleButtonWidth)))
								{
									if (assetRoot._bakeTargets == null || assetRoot._bakeTargets.Count == 0)
									{
										// No bake target means user probably forgot to set one. So complain!
										HEU_EditorUtility.DisplayDialog("No Bake Targets", "Bake Update requires atleast one valid GameObject.\n\nDrag a GameObject or Prefab onto the Drag and drop GameObjects / Prefabs field!", "OK");
									}
									else
									{
										int numTargets = assetRoot._bakeTargets.Count;
										for (int i = 0; i < numTargets; ++i)
										{
											GameObject bakeGO = assetRoot._bakeTargets[i];
											if (bakeGO != null)
											{
												if (HEU_EditorUtility.IsPrefabAsset(bakeGO))
												{
													// Prefab asset means its the source prefab, and not an instance of it
													asset.BakeToExistingPrefab(bakeGO);
												}
												else
												{
													// This is for all standalone (including prefab instances)
													asset.BakeToExistingStandalone(bakeGO);
												}
											}
											else
											{
												Debug.LogWarning("Unable to bake to null target at index " + i);
											}
										}
									}
								}

								using (var hs = new EditorGUILayout.VerticalScope(buttonSetStyle))
								{
									SerializedProperty bakeTargetsProp = assetRootSerializedObject.FindProperty("_bakeTargets");
									if (bakeTargetsProp != null)
									{
										EditorGUILayout.PropertyField(bakeTargetsProp, _dragAndDropField, true, GUILayout.Width(doubleButtonWidth - 9f));
									}
								}
							}
						}
					}
				}
				HEU_EditorUI.EndSection();

				HEU_EditorUI.DrawSeparator();

				if (pendingBuildAction != HEU_HoudiniAsset.AssetBuildAction.NONE)
				{
					// Sanity check to make sure the asset is part of the AssetUpater
					HEU_AssetUpdater.AddAssetForUpdate(asset);

					// Apply pending build action based on user UI interaction above
					pendingBuildProperty.enumValueIndex = (int)pendingBuildAction;

					if (pendingBuildAction == HEU_HoudiniAsset.AssetBuildAction.COOK)
					{
						// Recook should only update parameters that haven't changed. Otherwise if not checking and updating parameters,
						// then buttons will trigger callbacks on Recook which is not desired.
						SerializedProperty checkParameterChange = HEU_EditorUtility.GetSerializedProperty(assetObject, "_checkParameterChangeForCook");
						if (checkParameterChange != null)
						{
							checkParameterChange.boolValue = true;
						}

						// But we do want to always upload input geometry on user hitting Recook expliclity
						SerializedProperty forceUploadInputs = HEU_EditorUtility.GetSerializedProperty(assetObject, "_forceUploadInputs");
						if (forceUploadInputs != null)
						{
							forceUploadInputs.boolValue = true;
						}
					}
				}
			}
			
			if (EditorGUI.EndChangeCheck())
			{
				assetRootSerializedObject.ApplyModifiedProperties();
				assetObject.ApplyModifiedProperties();
			}

			return bSkipDrawing;
		}
示例#13
0
		/// <summary>
		/// Draw asset options for given asset.
		/// </summary>
		/// <param name="asset">The HDA asset</param>
		/// <param name="assetObject">Serialized HDA asset object</param>
		private void DrawAssetOptions(HEU_HoudiniAsset asset, SerializedObject assetObject)
		{
			GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);
			buttonStyle.fontSize = 11;
			buttonStyle.alignment = TextAnchor.MiddleCenter;
			buttonStyle.fixedHeight = 24;
			buttonStyle.margin.left = 34;

			HEU_EditorUI.BeginSection();
			{
				SerializedProperty showHDAOptionsProperty = assetObject.FindProperty("_showHDAOptions");

				showHDAOptionsProperty.boolValue = HEU_EditorUI.DrawFoldOut(showHDAOptionsProperty.boolValue, "ASSET OPTIONS");
				if (showHDAOptionsProperty.boolValue)
				{
					EditorGUI.indentLevel++;
					HEU_EditorUI.DrawPropertyField(assetObject, "_autoCookOnParameterChange", "Auto-Cook On Parameter Change", "Automatically cook when a parameter changes. If off, must use Recook to cook.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_pushTransformToHoudini", "Push Transform To Houdini", "Send the asset's transform to Houdini and apply to object.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_transformChangeTriggersCooks", "Transform Change Triggers Cooks", "Changing the transform (e.g. moving) the asset in Unity will invoke cook in Houdini.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_cookingTriggersDownCooks", "Cooking Triggers Downstream Cooks", "Cooking this asset will trigger dependent assets' to also cook.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateUVs", "Generate UVs", "Force Unity to generate UVs for output geometry.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateTangents", "Generate Tangents", "Generate tangents in Unity for output geometry.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateNormals", "Generate Normals", "Generate normals in Unity for output geometry.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_generateMeshUsingPoints", "Generate Mesh Using Points", "Use point attributes instead of vertex attributes for geometry. Ignores vertex attributes.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_useLODGroups", "Use LOD Groups", "Automatically create Unity LOD group if found.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_ignoreNonDisplayNodes", "Ignore NonDisplay Nodes", "Only display node geometry will be created.");
					HEU_EditorUI.DrawPropertyField(assetObject, "_splitGeosByGroup", "Split Geos By Group", "Split geometry into separate gameobjects by group. Deprecated feature and only recommended for simple use cases.");

					if (asset.NumAttributeStores() > 0)
					{
						HEU_EditorUI.DrawPropertyField(assetObject, "_editableNodesToolsEnabled", "Enable Editable Node Tools", "Displays Editable Node Tools and generates the node's geometry, if asset has editable nodes.");
					}

					if (asset.NumHandles() > 0)
					{
						HEU_EditorUI.DrawPropertyField(assetObject, "_handlesEnabled", "Enable Handles", "Creates Houdini Handles if asset has them.");
					}

					EditorGUILayout.Space();

					using (var hs = new EditorGUILayout.HorizontalScope())
					{
						if (GUILayout.Button(_savePresetButton, buttonStyle, GUILayout.MaxWidth(160)))
						{
							string fileName = asset.AssetName;
							string filePattern = "preset";
							string newPath = EditorUtility.SaveFilePanel("Save HDA preset", "", fileName + "." + filePattern, filePattern);
							if (newPath != null && !string.IsNullOrEmpty(newPath))
							{
								HEU_AssetPresetUtility.SaveAssetPresetToFile(asset, newPath);
							}
						}

						if (GUILayout.Button(_loadPresetButton, buttonStyle, GUILayout.MaxWidth(160)))
						{
							string fileName = asset.AssetName;
							string filePattern = "preset";
							string newPath = EditorUtility.OpenFilePanel("Load HDA preset", "", filePattern);
							if (newPath != null && !string.IsNullOrEmpty(newPath))
							{
								HEU_AssetPresetUtility.LoadPresetFileIntoAssetAndCook(asset, newPath);
							}
						}
					}

					EditorGUILayout.Space();

					if(GUILayout.Button(_resetMaterialOverridesButton, buttonStyle, GUILayout.MaxWidth(160)))
					{
						asset.ResetMaterialOverrides();
					}

					EditorGUI.indentLevel--;
				}
			}
			HEU_EditorUI.EndSection();

			HEU_EditorUI.DrawSeparator();
		}
示例#14
0
		public override void OnInspectorGUI()
		{
			// Try acquiring asset reference in here again due to Undo.
			// Eg. After a delete, Undo requires us to re-acquire references.
			TryAcquiringAsset();

			string msg = "Houdini Engine Asset Error\n" +
				"No HEU_HoudiniAsset found!";
			if (_houdiniAsset == null || !_houdiniAsset.IsValidForInteraction(ref msg))
			{
				DrawHDAUIMessage(msg);
				return;
			}

			// Always hook into asset UI callback. This could have got reset on code refresh.
			_houdiniAsset._refreshUIDelegate = RefreshUI;

			serializedObject.Update();
			_houdiniAssetSerializedObject.Update();

			bool guiEnabled = GUI.enabled;

			GUIStyle backgroundStyle = new GUIStyle(GUI.skin.GetStyle("box"));
			RectOffset br = backgroundStyle.margin;
			br.top = 10;
			br.bottom = 6;
			br.left = 4;
			br.right = 4;
			backgroundStyle.margin = br;

			br = backgroundStyle.padding;
			br.top = 8;
			br.bottom = 8;
            br.left = 8;
            br.right = 8;
			backgroundStyle.padding = br;

			using (var hs = new EditorGUILayout.VerticalScope(backgroundStyle))
			{
				HEU_EditorUI.DrawSeparator();

                DrawHeaderSection();

				DrawLicenseInfo();

				bool bSkipDraw = DrawGenerateSection(_houdiniAssetRoot, serializedObject, _houdiniAsset, _houdiniAssetSerializedObject); ;
				if (!bSkipDraw)
				{
					SerializedProperty assetCookStatusProperty = HEU_EditorUtility.GetSerializedProperty(_houdiniAssetSerializedObject, "_cookStatus");
					if (assetCookStatusProperty != null)
					{
						// Track changes to Houdini Asset gameobject
						EditorGUI.BeginChangeCheck();

						DrawEventsSection(_houdiniAsset, _houdiniAssetSerializedObject);

						DrawAssetOptions(_houdiniAsset, _houdiniAssetSerializedObject);

						DrawCurvesSection(_houdiniAsset, _houdiniAssetSerializedObject);

						DrawInputNodesSection(_houdiniAsset, _houdiniAssetSerializedObject);

						DrawTerrainSection(_houdiniAsset, _houdiniAssetSerializedObject);

						// If this is a Curve asset, we don't need to draw parameters as its redundant
						if (_houdiniAsset.AssetType != HEU_HoudiniAsset.HEU_AssetType.TYPE_CURVE)
						{
							DrawParameters(_houdiniAsset.Parameters, ref _parameterEditor);
						}

						DrawInstanceInputs(_houdiniAsset, _houdiniAssetSerializedObject);

						// Check if any changes occurred, and if so, trigger a recook
						if (EditorGUI.EndChangeCheck())
						{
							_houdiniAssetSerializedObject.ApplyModifiedProperties();
							serializedObject.ApplyModifiedProperties();

							// Do recook if values have changed
							if (HEU_PluginSettings.CookingEnabled && _houdiniAsset.AutoCookOnParameterChange && _houdiniAsset.DoesAssetRequireRecook())
							{
								_houdiniAsset.RequestCook(bCheckParametersChanged: true, bAsync: false, bSkipCookCheck: false, bUploadParameters: true);
							}
						}
					}
				}
			}

			GUI.enabled = guiEnabled;
		}
示例#15
0
	/// <summary>
	/// Draw the given asset's input instances.
	/// Caches initially, then draws in paginized format.
	/// </summary>
	/// <param name="asset">Asset's input instances to draw</param>
	/// <param name="assetObject">Serialized object of assset</param>
	public void DrawInstanceInputs(HEU_HoudiniAsset asset, SerializedObject assetObject)
	{
	    if (!_populated)
	    {
		// Create cache
		PopulateInstanceInputCache(asset, assetObject);
	    }

	    if (_instanceObjects.Count == 0)
	    {
		//Debug.Log("No instance objects");
		return;
	    }

	    HEU_EditorUI.DrawSeparator();

	    int numObjInstances = _instanceObjects.Count;

	    // Display input section if at least have 1 input field
	    if (numObjInstances > 0)
	    {
		HEU_EditorUI.BeginSection();

		_showInstanceInputsProperty.boolValue = HEU_EditorUI.DrawFoldOut
			(_showInstanceInputsProperty.boolValue, "INSTANCE INPUTS");
		if (_showInstanceInputsProperty.boolValue)
		{
		    EditorGUI.BeginChangeCheck();

		    // Number to display per page
		    EditorGUILayout.DelayedIntField(_numInputsToShowProperty, new GUIContent("Display Per Page"));

		    int numInputsToShow = Mathf.Clamp(_numInputsToShowProperty.intValue, 1, numObjInstances);
		    _numInputsToShowProperty.intValue = numInputsToShow;

		    int inputsPageIndex = _inputsPageIndexProperty.intValue;

		    int totalPages = numObjInstances / numInputsToShow;

		    using (new GUILayout.HorizontalScope())
		    {
			EditorGUILayout.DelayedIntField(_inputsPageIndexProperty, new GUIContent("Page"));

			// Current page
			inputsPageIndex = Mathf.Clamp(_inputsPageIndexProperty.intValue, 0, totalPages - 1);

			// Previous page
			EditorGUI.BeginDisabledGroup(inputsPageIndex <= 0);
			if (GUILayout.Button("<<"))
			{
			    inputsPageIndex--;
			}
			EditorGUI.EndDisabledGroup();

			// Next page
			EditorGUI.BeginDisabledGroup(inputsPageIndex >= (totalPages - 1));
			if (GUILayout.Button(">>"))
			{
			    inputsPageIndex++;
			}
			EditorGUI.EndDisabledGroup();

			_inputsPageIndexProperty.intValue = inputsPageIndex;
		    }

		    inputsPageIndex = inputsPageIndex < totalPages ? inputsPageIndex : totalPages - 1;

		    int startIndex = inputsPageIndex * numInputsToShow;
		    int validNumInputs = numInputsToShow <= numObjInstances ? numInputsToShow : numObjInstances;

		    if (EditorGUI.EndChangeCheck())
		    {
			// Only apply change to the UI object so don't need to cook entire asset
			_serializedObject.ApplyModifiedProperties();
		    }

		    EditorGUI.BeginChangeCheck();

		    // Draw instanced input info for current page
		    for (int i = 0; i < validNumInputs; ++i)
		    {
			EditorGUILayout.BeginVertical();

			int currentIndex = startIndex + i;

			if (_instanceObjects[currentIndex]._instancedInputsProperty != null)
			{
			    int inputCount = _instanceObjects[currentIndex]._instancedInputsProperty.arraySize;
			    EditorGUILayout.PropertyField(_instanceObjects[currentIndex]._instancedInputsProperty,
				    new GUIContent(_instanceObjects[currentIndex]._inputName), true);

			    // When input size increases, Unity creates default values for HEU_InstancedInput which results in
			    // zero value for scale offset. This fixes it up.
			    int newInputCount = _instanceObjects[currentIndex]._instancedInputsProperty.arraySize;
			    if (inputCount < newInputCount)
			    {
				for (int inputIndex = inputCount; inputIndex < newInputCount; ++inputIndex)
				{
				    SerializedProperty scaleProperty = _instanceObjects[currentIndex]._instancedInputsProperty.GetArrayElementAtIndex(inputIndex).FindPropertyRelative("_scaleOffset");
				    scaleProperty.vector3Value = Vector3.one;
				}
			    }
			}

			_instanceObjects[currentIndex]._objInstanceSerialized.ApplyModifiedProperties();

			EditorGUILayout.EndVertical();
		    }

		    if (EditorGUI.EndChangeCheck())
		    {
			asset.RequestCook(bCheckParametersChanged: true, bAsync: true, bSkipCookCheck: false, bUploadParameters: true);
		    }
		}

		HEU_EditorUI.EndSection();
	    }
	}
示例#16
0
	private void DrawSceneInfo()
	{
	    float pixelsPerPoint = HEU_EditorUI.GetPixelsPerPoint();
	    float screenWidth = Screen.width / pixelsPerPoint;
	    float screenHeight = Screen.height / pixelsPerPoint;

	    float screenPosHalf = screenWidth * 0.5f;
	    float wx = 120;
	    float height = 80;
	    float height_subtract = 140;

	    SetupUIElements();

	    Handles.BeginGUI();

	    _curveEditorUIRect = new Rect(screenPosHalf - wx, screenHeight - height_subtract, wx * 2f, height);
	    using (new GUILayout.AreaScope(_curveEditorUIRect, "", _toolsBGStyle))
	    {
		using (new GUILayout.VerticalScope())
		{
		    using (new GUILayout.HorizontalScope())
		    {
			GUILayout.FlexibleSpace();

			GUILayout.Label(_curveEditorLabel);

			GUILayout.FlexibleSpace();
		    }

		    HEU_Curve.Interaction newInteraction = (HEU_Curve.Interaction)GUILayout.Toolbar((int)_interactionMode, InteractionModeLabels, GUILayout.MinHeight(30));
		    if (newInteraction != _interactionMode)
		    {
			// Reset selection and do new
			SwitchToMode(newInteraction);
		    }

		    using (new GUILayout.HorizontalScope())
		    {
			GUILayout.FlexibleSpace();

			GUILayout.Label(_infoLabel);

			GUILayout.FlexibleSpace();
		    }
		}

	    }

	    if (_showInfoRepaint)
	    {
		using (new GUILayout.AreaScope(_infoRect, "", _toolsBGStyle))
		{
		    GUILayout.Label(_infoHeaderLabel);

		    // Help text
		    if (_interactionMode == HEU_Curve.Interaction.VIEW)
		    {
			GUILayout.Label(_curveViewHelp);
		    }
		    else if (_interactionMode == HEU_Curve.Interaction.ADD)
		    {
			DrawHelpLineGridBox("Left Mouse", "Add point to end of curve.");
			DrawHelpLineGridBox("A", "Toggle where to add new point (Start, Inside, End).");
			DrawHelpLineGridBox("Hold " + HEU_Defines.HEU_KEY_CTRL, "Grid snapping.");
			DrawHelpLineGridBox("Backspace", "Delete last new point.");
			DrawHelpLineGridBox("Space", "Edit mode.");
			DrawHelpLineGridBox("Esc / Enter", "View mode.");

			GUILayout.Space(5);

			using (new GUILayout.VerticalScope())
			{
			    GUILayout.Label(_curveNewPointModeLabel);

			    // Mode of adding new point (at start, middle, or end)
			    _newPointMode = (CurveNewPointMode)GUILayout.Toolbar((int)_newPointMode, NewPointModeLabels, GUILayout.MaxWidth(300), GUILayout.MinHeight(20));
			}
		    }
		    else if (_interactionMode == HEU_Curve.Interaction.EDIT)
		    {
			DrawHelpLineGridBox("Left Mouse", "Select point.");
			DrawHelpLineGridBox(HEU_Defines.HEU_KEY_CTRL + " + Left Mouse", "Multi-select point.");
			DrawHelpLineGridBox(string.Format("Hold {0} + Left Mouse", HEU_Defines.HEU_KEY_CTRL), "Grid snapping when moving points.");
			DrawHelpLineGridBox("Backspace", "Delete selected points.");
			DrawHelpLineGridBox("Space", "Add mode.");
			DrawHelpLineGridBox("Esc / Enter", "View mode.");
		    }

		}
	    }

	    Handles.EndGUI();
	}
示例#17
0
		private void DrawPaintModeScene()
		{
			if(_selectedAttributesStore == null || _selectedAttributeData == null)
			{
				// Nothing to do if no attribute selected
				return;
			}

			if(!_selectedAttributesStore.HasMeshForPainting())
			{
				// Painting requires a mesh so nothing to do
				return;
			}

			if (!_mouseWithinSceneView)
			{
				return;
			}

			float brushRadius = GetBrushRadius();

			// TODO: use Handles.DrawingScope
			Color originalHandleColor = Handles.color;
			Color newHandleColor = originalHandleColor;
			
			SerializedProperty handleColorProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_brushHandleColor");
			if(handleColorProperty != null)
			{
				newHandleColor = handleColorProperty.colorValue;
			}

			HEU_ToolsInfo.PaintMergeMode paintMergeMode = HEU_ToolsInfo.PaintMergeMode.REPLACE;
			SerializedProperty paintMergeProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_paintMergeMode");
			if (paintMergeProperty != null)
			{
				paintMergeMode = (HEU_ToolsInfo.PaintMergeMode)paintMergeProperty.intValue;
			}

			SerializedProperty isPaintingProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_isPainting");

			// Enable the mesh collider so that we can raycast to paint using brush
			MeshCollider collider = _selectedAttributesStore.GetPaintMeshCollider();
			if (collider != null)
			{
				Ray ray = _currentCamera.ScreenPointToRay(_mousePosition);
				ray.origin = _currentCamera.transform.position;

				RaycastHit hit;
				if (collider.Raycast(ray, out hit, _intersectionRayLength))
				{
					if (_currentEvent.type == EventType.ScrollWheel && _currentEvent.shift)
					{
						// Brush resize
						brushRadius -= _currentEvent.delta.y * _mouseWheelBrushSizeMultiplier;
						brushRadius = UpdateBrushSize(brushRadius);

						_GUIChanged = true;
						_currentEvent.Use();
					}
					else if (_currentEvent.type == EventType.MouseDrag && _currentEvent.shift)
					{
						// Brush resize
						brushRadius += _currentEvent.delta.x * _mouseWheelBrushSizeMultiplier;
						brushRadius = UpdateBrushSize(brushRadius);

						_GUIChanged = true;
						_currentEvent.Use();
					}
					else if (_currentEvent.button == 0 && !_currentEvent.shift && !_currentEvent.alt && !_currentEvent.control && !_mouseOverInfoPanel)
					{
						// Painting

						if (_currentEvent.type == EventType.MouseDown && !isPaintingProperty.boolValue)
						{
							PaintingStarted(isPaintingProperty);
						}

						if (isPaintingProperty.boolValue)
						{
							if(_currentEvent.type == EventType.MouseDown || _currentEvent.type == EventType.MouseDrag)
							{
								HandlePaintEvent(hit, brushRadius, paintMergeMode);

								_currentEvent.Use();
							}
						}
					}

					if (!_mouseOverInfoPanel)
					{
						Handles.color = newHandleColor;
						Vector3 endPt = hit.point + (Vector3.Normalize(hit.normal) * brushRadius);
						Handles.DrawAAPolyLine(2f, new Vector3[] { hit.point, endPt });

						HEU_EditorUI.DrawCircleCap(_controlID, hit.point, Quaternion.FromToRotation(Vector3.forward, hit.normal), brushRadius);
					}
				}
			}

			switch (_currentEvent.type)
			{
				case EventType.MouseDown:
				{
					// Don't use event here as it will ignore mouse camera controls
					break;
				}
				case EventType.MouseUp:
				{
					if (_currentEvent.button == 0)
					{
						if(!_currentEvent.shift && !_currentEvent.alt && !_currentEvent.control)
						{
							if (isPaintingProperty != null && isPaintingProperty.boolValue)
							{
								_currentEvent.Use();
							}

							PaintingFinished(isPaintingProperty);
						}
					}
					break;
				}
				case EventType.MouseMove:
				{
					// Use the mouse move event will force a repaint allowing for much more responsive UI
					_currentEvent.Use();
					break;
				}
				case EventType.Layout:
				{
					// This disables deselection on asset while in Edit mode
					HandleUtility.AddDefaultControl(_controlID);

					break;
				}
				case EventType.Repaint:
				{
					
					break;
				}
			}

			Handles.color = originalHandleColor;
		}
示例#18
0
	/// <summary>
	/// Update and draw the curves for the specified asset.
	/// Manages the interaction modes.
	/// </summary>
	/// <param name="asset"></param>
	public void UpdateSceneCurves(HEU_HoudiniAsset asset)
	{
	    _serializedCurvesCache.Clear();

	    // Filter out non-editable curves
	    _curves.Clear();
	    foreach (Object targetObject in targets)
	    {
		HEU_Curve curve = targetObject as HEU_Curve;
		if (curve != null && curve.IsEditable())
		{
		    _curves.Add(curve);
		}
	    }

	    if (_curves.Count == 0)
	    {
		return;
	    }

	    _currentCamera = Camera.current;

	    Color defaultHandleColor = Handles.color;

	    Event currentEvent = Event.current;
	    Vector3 mousePosition = HEU_EditorUI.GetMousePosition(ref currentEvent, _currentCamera);

	    int controlID = GUIUtility.GetControlID(FocusType.Keyboard);
	    EventType eventType = currentEvent.GetTypeForControl(controlID);

	    EditorGUI.BeginChangeCheck();

	    // Keep track of curves that were updated so we can apply changes via serialization
	    List<SerializedObject> updatedCurves = new List<SerializedObject>();

	    if (_interactionMode == HEU_Curve.Interaction.VIEW)
	    {
		UpdateViewMode(asset, controlID, eventType, mousePosition, updatedCurves);
	    }
	    else if (_interactionMode == HEU_Curve.Interaction.ADD)
	    {
		UpdateAddMode(asset, controlID, eventType, mousePosition, updatedCurves);
	    }
	    else if (_interactionMode == HEU_Curve.Interaction.EDIT)
	    {
		UpdateEditMode(asset, controlID, eventType, mousePosition, updatedCurves);
	    }

	    if (EditorGUI.EndChangeCheck())
	    {
		foreach (SerializedObject serializedCurve in updatedCurves)
		{
		    serializedCurve.ApplyModifiedProperties();
		}
	    }

	    Handles.color = defaultHandleColor;

	    if (eventType == EventType.Layout)
	    {
		// Delay update the show info so that the error doesn't popup trying to draw elements during drawing.
		_showInfoRepaint = _showInfo;
	    }

	    DrawSceneInfo();
	}
		private void DrawAssetLink()
		{
			HEU_PDGAssetLink.LinkState validState = _assetLink.AssetLinkState;

			using (new EditorGUILayout.VerticalScope(_backgroundStyle))
			{
				EditorGUILayout.Space();

				SerializedProperty assetGOProp = HEU_EditorUtility.GetSerializedProperty(serializedObject, "_assetGO");
				if (assetGOProp != null)
				{
					EditorGUILayout.PropertyField(assetGOProp, _assetGOLabel, false);
				}

				EditorGUILayout.Space();

				using (new EditorGUILayout.HorizontalScope())
				{
					if (GUILayout.Button(_refreshContent, GUILayout.MaxHeight(_largButtonHeight)))
					{
						_assetLink.Refresh();
					}

					if (GUILayout.Button(_resetContent, GUILayout.MaxHeight(_largButtonHeight)))
					{
						_assetLink.Reset();
					}
				}

				_assetLink._autoCook = EditorGUILayout.Toggle(_autocookContent, _assetLink._autoCook);
				_assetLink._useHEngineData = EditorGUILayout.Toggle(_useHEngineDataContent, _assetLink._useHEngineData);

				EditorGUILayout.Space();

				using (new EditorGUILayout.VerticalScope(HEU_EditorUI.GetSectionStyle()))
				{
					EditorGUILayout.LabelField("Asset is " + validState);

					if (validState == HEU_PDGAssetLink.LinkState.ERROR_NOT_LINKED)
					{
						EditorGUILayout.LabelField("Failed to link with HDA. Unable to proceed. Try rebuilding asset.");
					}
					else if (validState == HEU_PDGAssetLink.LinkState.LINKED)
					{
						EditorGUILayout.Space();

						EditorGUILayout.LabelField(_assetStatusLabel);

						DrawWorkItemTally(_assetLink._workItemTally);

						EditorGUILayout.Space();
					}
				}
			}

			if (validState == HEU_PDGAssetLink.LinkState.INACTIVE)
			{
				_assetLink.Refresh();
			}
			else if (validState == HEU_PDGAssetLink.LinkState.LINKED)
			{
				using (new EditorGUILayout.VerticalScope(_backgroundStyle))
				{
					EditorGUILayout.Space();

					// Dropdown list of TOP network names
					DrawSelectedTOPNetwork();

					EditorGUILayout.Space();

					// Dropdown list of TOP nodes
					DrawSelectedTOPNode();
				}
			}
		}
示例#20
0
	private void UpdateAddMode(HEU_HoudiniAsset asset, int controlID, EventType eventType, Vector3 mousePosition, List<SerializedObject> updatedCurves)
	{
	    Event currentEvent = Event.current;

	    Color defaultHandleColor = Handles.color;

	    switch (eventType)
	    {
		case EventType.MouseDown:
		{
		    if (!currentEvent.alt && currentEvent.button == 0 && _closestCurveName != null && _closestPointIndex >= 0)
		    {
			AddPoint(_closestCurveName, _closestPointIndex, _newPointPosition, updatedCurves);
			_closestCurveName = null;

			currentEvent.Use();
		    }

		    break;
		}
		case EventType.MouseUp:
		{

		    break;
		}
		case EventType.MouseMove:
		{
		    // Use the mouse move event will force a repaint allowing for much more responsive UI
		    currentEvent.Use();
		    break;
		}
		case EventType.KeyUp:
		{
		    if (currentEvent.keyCode == KeyCode.Space && !currentEvent.alt)
		    {
			// Toggle modes
			SwitchToMode(HEU_Curve.Interaction.EDIT);
		    }
		    else if (currentEvent.keyCode == KeyCode.Escape || currentEvent.keyCode == KeyCode.Return || currentEvent.keyCode == KeyCode.KeypadEnter)
		    {
			SwitchToMode(HEU_Curve.Interaction.VIEW);
			currentEvent.Use();
		    }

		    break;
		}
		case EventType.KeyDown:
		{
		    if (currentEvent.keyCode == KeyCode.Backspace || currentEvent.keyCode == KeyCode.Delete)
		    {
			// Delete last added point
			if (_latestPointAddedCurve != null)
			{
			    HEU_Curve latestAddCurve = GetCurve(_latestPointAddedCurve);
			    if (latestAddCurve != null && _latestPointsAdded.Count > 0)
			    {
				SelectSinglePoint(latestAddCurve, _latestPointsAdded.Pop());
				DeleteSelectedPoints(updatedCurves);
			    }
			}

			currentEvent.Use();
		    }
		    else if (currentEvent.keyCode == KeyCode.A)
		    {
			int mode = (int)_newPointMode + 1;
			if (mode > (int)CurveNewPointMode.END)
			{
			    mode = (int)CurveNewPointMode.START;
			}
			_newPointMode = (CurveNewPointMode)mode;
		    }
		    else if (currentEvent.keyCode == KeyCode.F1)
		    {
			_showInfo = !_showInfo;
		    }

		    break;
		}
		case EventType.Layout:
		{
		    // This disables deselection on asset while in Add mode
		    HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));

		    break;
		}
		case EventType.Repaint:
		{
		    bool bMouseInDrawArea = HEU_GeneralUtility.IsMouseWithinSceneView(_currentCamera, mousePosition)
			    && !HEU_GeneralUtility.IsMouseOverRect(_currentCamera, mousePosition, ref _curveEditorUIRect)
			    && (!_showInfoRepaint || !HEU_GeneralUtility.IsMouseOverRect(_currentCamera, mousePosition, ref _infoRect));

		    // Plane for default collider
		    Plane collisionPlane = new Plane(Vector3.up, Vector3.zero);
		    //Ray mouseRay = _currentCamera.ScreenPointToRay(mousePosition);
		    //Vector3 planePosition = mouseRay.origin + mouseRay.direction * 100f;
		    //Plane collisionPlane = new Plane(-_currentCamera.transform.forward, planePosition);

		    HEU_Curve.CurveDrawCollision drawCollision = asset.CurveDrawCollision;
		    List<Collider> drawColliders = null;
		    LayerMask drawLayerMask = Physics.DefaultRaycastLayers;
		    if (drawCollision == HEU_Curve.CurveDrawCollision.LAYERMASK)
		    {
			drawLayerMask = asset.GetCurveDrawLayerMask();
		    }
		    else if (drawCollision == HEU_Curve.CurveDrawCollision.COLLIDERS)
		    {
			drawColliders = asset.GetCurveDrawColliders();
		    }

		    // Adding new point between line segments

		    _closestPointIndex = -1;
		    _closestCurveName = null;
		    _newPointPosition = Vector3.zero;

		    float closestDistance = float.MaxValue;

		    foreach (HEU_Curve curve in _curves)
		    {
			// Draw the cooked curve using its vertices
			DrawCurveUsingVertices(curve, _selectedCurveColor);

			DrawPointCaps(curve, _addModeDefaultPointColor);

			List<Vector3> points = curve.GetAllPoints();
			int numPoints = points.Count;

			if (_currentCamera != null && bMouseInDrawArea)
			{
			    Ray ray = _currentCamera.ScreenPointToRay(mousePosition);
			    RaycastHit[] results = null;

			    if (numPoints > 0 && (_newPointMode == CurveNewPointMode.INSIDE))
			    {
				// Control -> add point between closest line segment

				for (int i = 0; i < numPoints - 1; ++i)
				{
				    Vector3 pointPos0 = curve.GetTransformedPosition(points[i]);
				    Vector3 pointPos1 = curve.GetTransformedPosition(points[i + 1]);

				    Vector3 screenPos0 = HEU_EditorUI.GetHandleWorldToScreenPosition(pointPos0, _currentCamera);
				    Vector3 screenPos1 = HEU_EditorUI.GetHandleWorldToScreenPosition(pointPos1, _currentCamera);

				    float distance = HandleUtility.DistancePointToLineSegment(mousePosition, screenPos0, screenPos1);
				    if (distance < closestDistance)
				    {
					closestDistance = distance;
					_closestPointIndex = i + 1;
					_closestCurveName = curve.CurveName;
				    }
				}
			    }
			    else
			    {
				// Show new point from either end of curve, whichever is closest.
				// Use collision to find new point.

				Vector3 hitPoint = Vector3.zero;
				bool bHit = false;

				if (drawCollision == HEU_Curve.CurveDrawCollision.LAYERMASK)
				{
				    // Using layermask
				    RaycastHit hitInfo;
				    if (Physics.Raycast(ray, out hitInfo, _rayCastMaxDistance, drawLayerMask))
				    {
					hitPoint = hitInfo.point;
					bHit = true;
				    }
				}
				else if (drawColliders != null && drawColliders.Count > 0)
				{
				    // Using colliders
				    results = Physics.RaycastAll(ray, _rayCastMaxDistance, drawLayerMask);
				    foreach (RaycastHit hit in results)
				    {
					foreach (Collider drawCollider in drawColliders)
					{
					    if (hit.collider == drawCollider)
					    {
						hitPoint = hit.point;
						bHit = true;
						break;
					    }
					}
				    }
				}
				else
				{
				    // Using identity plane
				    float collisionEnter = 0f;
				    if (collisionPlane.Raycast(ray, out collisionEnter))
				    {
					collisionEnter = Mathf.Clamp(collisionEnter, _currentCamera.nearClipPlane, _currentCamera.farClipPlane);
					hitPoint = ray.origin + ray.direction * collisionEnter;
					bHit = true;
				    }
				}

				if (bHit)
				{
				    Vector3 hitPointScreenPosition = HEU_EditorUI.GetHandleWorldToScreenPosition(hitPoint, _currentCamera);

				    // Find the closest point to add from (either first or last point)

				    // Empty curve:
				    // If its just a single curve, we can use the hit point as closest point.
				    // For multiple curves, it gets trickier since we don't have an existing point
				    // to check for closest point. So we'll just use the parent's transform position
				    // as our anchor point.

				    Vector3 checkPoint = Vector3.zero;
				    int curveClosestPointIndex = 0;

				    if (numPoints == 0)
				    {
					if (_curves.Count > 1)
					{
					    // Multiple curves -> use position of asset
					    checkPoint = curve._targetGameObject.transform.position;
					}
					else
					{
					    // Single curve -> use hit point as closest
					    checkPoint = hitPoint;
					}
				    }
				    else if (_newPointMode == CurveNewPointMode.START)
				    {
					// Curve with at least 1 point + shift held -> use first point
					checkPoint = HEU_EditorUI.GetHandleWorldToScreenPosition(curve.GetTransformedPoint(0), _currentCamera);
					curveClosestPointIndex = 0;
				    }
				    else
				    {
					// Curve with at least 1 point -> use last point
					checkPoint = HEU_EditorUI.GetHandleWorldToScreenPosition(curve.GetTransformedPoint(numPoints - 1), _currentCamera);
					curveClosestPointIndex = numPoints;
				    }

				    float curveClosestPointDistance = Vector3.Distance(checkPoint, hitPointScreenPosition);
				    if (curveClosestPointDistance < closestDistance)
				    {
					closestDistance = curveClosestPointDistance;
					_closestPointIndex = curveClosestPointIndex;
					_closestCurveName = curve.CurveName;
					_newPointPosition = hitPoint;
				    }

				    // Snap to grid
				    _newPointPosition = HEU_EditorUI.GetSnapPosition(_newPointPosition);
				}
			    }
			}
		    }

		    // Note that curve name can be empty for valid empty curves
		    if (_closestCurveName != null && _closestPointIndex >= 0)
		    {
			HEU_Curve closestCurve = GetCurve(_closestCurveName);
			if (closestCurve != null)
			{
			    int numPoints = closestCurve.GetNumPoints();
			    if ((_newPointMode == CurveNewPointMode.INSIDE) && !currentEvent.alt && numPoints >= 2)
			    {
				// Handle adding new point at projected mouse cursor between points

				// First draw the curve line segments
				DrawCurveUsingPoints(closestCurve, Color.yellow);

				// Draw the caps again to hid the ends of line segments above (visually pleasing)
				DrawPointCaps(closestCurve, _addModeDefaultPointColor);

				Vector3 pointPos0 = closestCurve.GetTransformedPoint(_closestPointIndex - 1);
				Vector3 pointPos1 = closestCurve.GetTransformedPoint(_closestPointIndex);

				Vector3 screenPos0 = HEU_EditorUI.GetHandleWorldToScreenPosition(pointPos0, _currentCamera);
				Vector3 screenPos1 = HEU_EditorUI.GetHandleWorldToScreenPosition(pointPos1, _currentCamera);

				Vector3 curveNewPointPosition = HandleUtility.ProjectPointLine(mousePosition, screenPos0, screenPos1);

				Vector2 deltaNew = curveNewPointPosition - screenPos0;
				Vector2 deltaLine = screenPos1 - screenPos0;
				float ratio = Mathf.Clamp01(deltaNew.magnitude / deltaLine.magnitude);

				Vector3 newDir = (pointPos1 - pointPos0);
				curveNewPointPosition = pointPos0 + (newDir.normalized * newDir.magnitude * ratio);

				Handles.color = _selectedPointColor;
				HEU_EditorUI.DrawSphereCap(GUIUtility.GetControlID(FocusType.Passive), curveNewPointPosition, Quaternion.identity, HEU_EditorUI.GetHandleSize(curveNewPointPosition));

				Handles.color = Color.yellow;
				HEU_EditorUI.DrawCircleCap(0, pointPos0, Quaternion.LookRotation(_currentCamera.transform.forward), HEU_EditorUI.GetHandleSize(pointPos0));
				HEU_EditorUI.DrawCircleCap(0, pointPos1, Quaternion.LookRotation(_currentCamera.transform.forward), HEU_EditorUI.GetHandleSize(pointPos1));
				Handles.color = defaultHandleColor;

				_newPointPosition = curveNewPointPosition;

				SceneView.RepaintAll();
			    }
			    else if (!currentEvent.alt)
			    {
				// Handle adding new point at closest curve's end points

				if (closestCurve.GetNumPoints() > 0)
				{
				    // Draw dotted line from last point to newPointPosition
				    int connectionPoint = (_closestPointIndex > 0) ? _closestPointIndex - 1 : 0;
				    Vector3 pointPos0 = closestCurve.GetTransformedPoint(connectionPoint);
				    Vector3[] dottedLineSegments = new Vector3[] { pointPos0, _newPointPosition };

				    Handles.color = _dottedLineColor;
				    Handles.DrawDottedLines(dottedLineSegments, 4f);
				}

				Handles.color = _selectedPointColor;
				HEU_EditorUI.DrawSphereCap(GUIUtility.GetControlID(FocusType.Passive), _newPointPosition, Quaternion.identity, HEU_EditorUI.GetHandleSize(_newPointPosition));
				Handles.color = defaultHandleColor;

				SceneView.RepaintAll();
			    }
			}
		    }

		    break;
		}
	    }
	}
		private bool DrawDetailsGeneral()
		{
			bool bChanged = false;
			{
				float oldValue = HEU_PluginSettings.PinSize;
				float newValue = EditorGUILayout.DelayedFloatField("Pin Size", oldValue);
				if (newValue != oldValue)
				{
					HEU_PluginSettings.PinSize = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				Color oldValue = HEU_PluginSettings.PinColor;
				Color newValue = EditorGUILayout.ColorField("Pin Color", oldValue);
				if (newValue != oldValue)
				{
					HEU_PluginSettings.PinColor = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				float oldValue = HEU_PluginSettings.ImageGamma;
				float newValue = EditorGUILayout.DelayedFloatField("Texture Gamma", oldValue);
				if (newValue != oldValue)
				{
					HEU_PluginSettings.ImageGamma = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				Color oldValue = HEU_PluginSettings.LineColor;
				Color newValue = EditorGUILayout.ColorField("Line Color", oldValue);
				if (newValue != oldValue)
				{
					HEU_PluginSettings.LineColor = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldPath = HEU_PluginSettings.AssetCachePath;
				string newPath = EditorGUILayout.TextField("Houdini Asset Cache Path", oldPath);
				if (!newPath.Equals(oldPath))
				{
					HEU_PluginSettings.AssetCachePath = newPath;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.UseFullPathNamesForOutput;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Use Full Path Names For Output");
				if (!newValue.Equals(oldValue))
				{
					HEU_PluginSettings.UseFullPathNamesForOutput = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				bool oldValue = HEU_PluginSettings.SetCurrentThreadToInvariantCulture;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Set Current Thread To Invariant Culture", "Enabling this sets to use InvariantCutulre which fixes locale-specific parsing issues such as using comma instead of dot for decimals.");
				if (!newValue.Equals(oldValue))
				{
					HEU_PluginSettings.SetCurrentThreadToInvariantCulture = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldPath = HEU_PluginSettings.HoudiniDebugLaunchPath;
				string fileExt = "";

				EditorGUILayout.LabelField(new GUIContent("Houdini Debug Executable:", "Set Houdini executable to launch when opening debug scenes."));
				using (new EditorGUILayout.HorizontalScope())
				{
					string newPath = EditorGUILayout.DelayedTextField(oldPath);

					GUIStyle buttonStyle = HEU_EditorUI.GetNewButtonStyle_MarginPadding(0, 0);
					if (GUILayout.Button("...", buttonStyle, GUILayout.Width(30), GUILayout.Height(18)))
					{
						string panelMsg = "Select Houdini Executable";
#if UNITY_EDITOR_OSX
						panelMsg += " (.app)";
#endif

						string openFilePath = UnityEditor.EditorUtility.OpenFilePanel(panelMsg, newPath, fileExt);
						if (!string.IsNullOrEmpty(openFilePath))
						{
							newPath = openFilePath;
						}
					}

					if (!newPath.Equals(oldPath))
					{
						HEU_PluginSettings.HoudiniDebugLaunchPath = newPath;
						bChanged = true;
					}
				}
#if UNITY_EDITOR_OSX
				GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
				labelStyle.wordWrap = true;
				EditorGUILayout.LabelField("  On macOS, you'll need to select the path to the .app folder.\n  E.g. /Applications/Houdini/Houdini16.5.616/Houdini Core 16.5.616.app", labelStyle);
#endif
			}

			return bChanged;
		}
示例#22
0
	private void EditModeDrawCurvePoints(Event currentEvent, EventType eventType, ref int numSelectedPoints, ref Bounds bounds, ref bool bInteractionOcurred)
	{
	    Color defaultHandleColor = Handles.color;

	    // First we draw all the curves, while drawing each point as button
	    // and collecting the selected points.
	    foreach (HEU_Curve curve in _curves)
	    {
		if (eventType == EventType.Repaint)
		{
		    // Draw the cooked curve using its vertices
		    DrawCurveUsingVertices(curve, _selectedCurveColor);
		}

		// During dragging, we draw the points in the drag logic later
		if (_dragMouseDown)
		{
		    continue;
		}

		// Now draw all the points, but tailor their visual style according to interaction
		List<Vector3> points = curve.GetAllPoints();

		List<int> selectedPoints = new List<int>();
		_selectedCurvePoints.TryGetValue(curve.CurveName, out selectedPoints);

		for (int i = 0; i < points.Count; ++i)
		{
		    Vector3 pointPos = curve.GetTransformedPosition(points[i]);
		    float pointSize = HEU_EditorUI.GetHandleSize(pointPos);
		    float pickSize = pointSize * 2f;

		    if (selectedPoints != null && selectedPoints.Contains(i))
		    {
			// Selected point
			numSelectedPoints++;

			if (numSelectedPoints == 1)
			{
			    bounds = new Bounds(pointPos, Vector3.zero);
			}
			else
			{
			    bounds.Encapsulate(pointPos);
			}

			if (selectedPoints.Count > 1 || _selectedCurvePoints.Keys.Count > 1)
			{
			    Handles.color = _selectedPointColor;
			    if (HEU_EditorUI.DrawSphereCapButton(pointPos, Quaternion.identity, pointSize, pickSize))
			    {
				if (currentEvent.control)
				{
				    DeselectPoint(curve.CurveName, i);
				}
				else
				{
				    SelectSinglePoint(curve, i);
				}
				bInteractionOcurred = true;
			    }
			    Handles.color = defaultHandleColor;
			}
		    }
		    else
		    {
			// Unselected point

			Handles.color = _unselectedPointColor;
			if (HEU_EditorUI.DrawSphereCapButton(pointPos, Quaternion.identity, pointSize, pickSize))
			{
			    if (currentEvent.control)
			    {
				SelectAddPoint(curve, i);
			    }
			    else
			    {
				SelectSinglePoint(curve, i);
			    }

			    bInteractionOcurred = true;
			}
		    }
		}
	    }
	}
		private bool DrawDetailsGeometry()
		{
			bool bChanged = false;

			EditorGUIUtility.labelWidth = 250;

			{
				bool oldValue = HEU_PluginSettings.Curves_ShowInSceneView;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Show Curves in Scene View");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.Curves_ShowInSceneView = newValue;
					HEU_HoudiniAsset.SetCurvesVisibilityInScene(newValue);
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				float oldValue = HEU_PluginSettings.NormalGenerationThresholdAngle;
				float newValue = EditorGUILayout.DelayedFloatField("Normal Generation Threshold Angle", oldValue);
				if (newValue != oldValue)
				{
					HEU_PluginSettings.NormalGenerationThresholdAngle = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.TerrainSplatTextureDefault;
				string newValue = EditorGUILayout.DelayedTextField("Terrain Default Splat Texture", oldValue);
				if (!newValue.Equals(oldValue))
				{
					HEU_PluginSettings.TerrainSplatTextureDefault = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.DefaultStandardShader;
				string newValue = EditorGUILayout.DelayedTextField("Default Standard Shader", oldValue);
				if (!newValue.Equals(oldValue))
				{
					HEU_PluginSettings.DefaultStandardShader = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.DefaultTransparentShader;
				string newValue = EditorGUILayout.DelayedTextField("Default Transparent Shader", oldValue);
				if (!newValue.Equals(oldValue))
				{
					HEU_PluginSettings.DefaultTransparentShader = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.DefaultVertexColorShader;
				string newValue = EditorGUILayout.DelayedTextField("Default Vertex Color Shader", oldValue);
				if (!newValue.Equals(oldValue))
				{
					HEU_PluginSettings.DefaultVertexColorShader = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.DefaultCurveShader;
				string newValue = EditorGUILayout.DelayedTextField("Default Curve Shader", oldValue);
				if (!newValue.Equals(oldValue))
				{
					HEU_PluginSettings.DefaultCurveShader = newValue;
					bChanged = true;
				}
			}

			HEU_EditorUI.DrawSeparator();

			EditorGUIUtility.labelWidth = 0;

			return bChanged;
		}
		private bool DrawDetailsGeometry()
		{
			bool bChanged = false;

			EditorGUIUtility.labelWidth = 250;

			{
				bool oldValue = HEU_PluginSettings.Curves_ShowInSceneView;
				bool newValue = HEU_EditorUI.DrawToggleLeft(oldValue, "Show Curves in Scene View");
				if (newValue != oldValue)
				{
					HEU_PluginSettings.Curves_ShowInSceneView = newValue;
					HEU_HoudiniAsset.SetCurvesVisibilityInScene(newValue);
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				float oldValue = HEU_PluginSettings.NormalGenerationThresholdAngle;
				float newValue = EditorGUILayout.DelayedFloatField("Normal Generation Threshold Angle", oldValue);
				if (newValue != oldValue)
				{
					HEU_PluginSettings.NormalGenerationThresholdAngle = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.DefaultTerrainMaterial;
				if (_terrainMaterial == null && !string.IsNullOrEmpty(oldValue))
				{
					//Debug.Log("Loading terrain material at: " + oldValue);
					_terrainMaterial = HEU_MaterialFactory.LoadUnityMaterial(oldValue);
				}

				Material newMaterial = EditorGUILayout.ObjectField("Default Terrain Material", _terrainMaterial, typeof(Material), false) as Material;
				if (newMaterial != _terrainMaterial)
				{
					string materialPath = "";
					if (newMaterial != null)
					{
						materialPath = HEU_AssetDatabase.GetAssetPathWithSubAssetSupport(newMaterial);
						if (!string.IsNullOrEmpty(materialPath) && (materialPath.StartsWith(HEU_Defines.DEFAULT_UNITY_BUILTIN_RESOURCES)))
						{
							// Default materials need to be specially handled
							materialPath = HEU_AssetDatabase.GetUniqueAssetPathForUnityAsset(newMaterial);
							newMaterial = HEU_AssetDatabase.LoadUnityAssetFromUniqueAssetPath<Material>(materialPath);
						}
					}

					HEU_PluginSettings.DefaultTerrainMaterial = materialPath;
					_terrainMaterial = newMaterial;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.TerrainSplatTextureDefault;
				string newValue = EditorGUILayout.DelayedTextField("Default Terrain Splat Texture", oldValue);
				if (!newValue.Equals(oldValue))
				{
					HEU_PluginSettings.TerrainSplatTextureDefault = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.DefaultStandardShader;
				string newValue = EditorGUILayout.DelayedTextField("Default Standard Shader", oldValue);
				if (!newValue.Equals(oldValue))
				{
					HEU_PluginSettings.DefaultStandardShader = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.DefaultTransparentShader;
				string newValue = EditorGUILayout.DelayedTextField("Default Transparent Shader", oldValue);
				if (!newValue.Equals(oldValue))
				{
					HEU_PluginSettings.DefaultTransparentShader = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.DefaultVertexColorShader;
				string newValue = EditorGUILayout.DelayedTextField("Default Vertex Color Shader", oldValue);
				if (!newValue.Equals(oldValue))
				{
					HEU_PluginSettings.DefaultVertexColorShader = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.DefaultCurveShader;
				string newValue = EditorGUILayout.DelayedTextField("Default Curve Shader", oldValue);
				if (!newValue.Equals(oldValue))
				{
					HEU_PluginSettings.DefaultCurveShader = newValue;
					bChanged = true;
				}
			}

			HEU_EditorUI.DrawSeparator();

			EditorGUIUtility.labelWidth = 0;

			return bChanged;
		}
		private bool DrawAdvancedSettings()
		{
			bool bChanged = false;

			GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
			labelStyle.normal.textColor = HEU_EditorUI.GetUISafeTextColorYellow();
			EditorGUILayout.LabelField("Warning: Changing these values from default might result in HDAs not loading properly!", labelStyle, GUILayout.MinHeight(30));
			HEU_EditorUI.DrawSeparator();

			EditorGUIUtility.labelWidth = 250;
			{
				string oldValue = HEU_PluginSettings.HDAData_Name;
				string newValue = EditorGUILayout.DelayedTextField("HDA Data GameObject Name", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.HDAData_Name = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.EditorOnly_Tag;
				string newValue = EditorGUILayout.DelayedTextField("HDA Data GameObject Tag", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.EditorOnly_Tag = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.CollisionGroupName;
				string newValue = EditorGUILayout.DelayedTextField("Collision Group", oldValue);
				if(oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.CollisionGroupName = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.RenderedCollisionGroupName;
				string newValue = EditorGUILayout.DelayedTextField("Rendered Collision Group", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.RenderedCollisionGroupName = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.UnityMaterialAttribName;
				string newValue = EditorGUILayout.DelayedTextField("Unity Material Attribute", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.UnityMaterialAttribName = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.UnitySubMaterialAttribName;
				string newValue = EditorGUILayout.DelayedTextField("Unity Substance Material Attribute", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.UnitySubMaterialAttribName = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.UnityTagAttributeName;
				string newValue = EditorGUILayout.DelayedTextField("Unity Tag Attribute", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.UnityTagAttributeName = newValue;
					bChanged = true;
				}
			}
			HEU_EditorUI.DrawSeparator();
			{
				string oldValue = HEU_PluginSettings.UnityScriptAttributeName;
				string newValue = EditorGUILayout.DelayedTextField("Unity Script Attribute", oldValue);
				if (oldValue != newValue && !string.IsNullOrEmpty(newValue))
				{
					HEU_PluginSettings.UnityScriptAttributeName = newValue;
					bChanged = true;
				}
			}

			EditorGUIUtility.labelWidth = 0;

			return bChanged;
		}
示例#26
0
		/// <summary>
		/// Main function to display linked asset's info, and functions.
		/// </summary>
		private void DrawAssetLink()
		{
			HEU_PDGAssetLink.LinkState validState = _assetLink.AssetLinkState;

			using (new EditorGUILayout.VerticalScope(_backgroundStyle))
			{
				EditorGUILayout.Space();

				// Linked asset
				SerializedProperty assetGOProp = HEU_EditorUtility.GetSerializedProperty(serializedObject, "_assetGO");
				if (assetGOProp != null)
				{
					EditorGUILayout.PropertyField(assetGOProp, _assetGOLabel, false);
				}

				EditorGUILayout.Space();

				using (new EditorGUILayout.HorizontalScope())
				{
					// Refresh button re-poplates the UI data from linked asset
					if (GUILayout.Button(_refreshContent, GUILayout.MaxHeight(_largButtonHeight)))
					{
						_assetLink.Refresh();
					}

					// Reset button resets and recreates the HEU_PDGAssetLink
					if (GUILayout.Button(_resetContent, GUILayout.MaxHeight(_largButtonHeight)))
					{
						_assetLink.Reset();
					}
				}

				// Autocook allows to automatically cook the TOP network when input assets are cooked
				_assetLink._autoCook = EditorGUILayout.Toggle(_autocookContent, _assetLink._autoCook);

				// Whether to use HEngine meta data to filter TOP networks and nodes
				_assetLink._useHEngineData = EditorGUILayout.Toggle(_useHEngineDataContent, _assetLink._useHEngineData);

				EditorGUILayout.Space();

				// Asset status
				using (new EditorGUILayout.VerticalScope(HEU_EditorUI.GetSectionStyle()))
				{
					EditorGUILayout.LabelField("Asset is " + validState);

					if (validState == HEU_PDGAssetLink.LinkState.ERROR_NOT_LINKED)
					{
						EditorGUILayout.LabelField("Failed to link with HDA. Unable to proceed. Try rebuilding asset.");
					}
					else if (validState == HEU_PDGAssetLink.LinkState.LINKED)
					{
						EditorGUILayout.Space();

						EditorGUILayout.LabelField(_assetStatusLabel);

						DrawWorkItemTally(_assetLink._workItemTally);

						EditorGUILayout.Space();
					}
				}
			}

			if (validState == HEU_PDGAssetLink.LinkState.INACTIVE)
			{
				_assetLink.Refresh();
			}
			else if (validState == HEU_PDGAssetLink.LinkState.LINKED)
			{
				using (new EditorGUILayout.VerticalScope(_backgroundStyle))
				{
					EditorGUILayout.Space();

					DrawSelectedTOPNetwork();

					EditorGUILayout.Space();

					DrawSelectedTOPNode();
				}
			}

			// Display cook event messages
			string eventMsgs = "<color=#c0c0c0ff>Cook event messages and errors will be displayed here...</color>";
			HEU_PDGSession pdgSession = HEU_PDGSession.GetPDGSession();
			if (pdgSession != null)
			{
				string actualMsgs = pdgSession.GetEventMessages();
				if (!string.IsNullOrEmpty(actualMsgs))
				{
					eventMsgs = string.Format("{0}", actualMsgs);
				}
			}

			using (new EditorGUILayout.VerticalScope(_backgroundStyle))
			{
				EditorGUILayout.Space();

				_eventMessageScrollPos = EditorGUILayout.BeginScrollView(_eventMessageScrollPos, false, false);
				Vector2 textSize = _eventMessageStyle.CalcSize(new GUIContent(eventMsgs));
				EditorGUILayout.PrefixLabel(_eventMessageContent);
				EditorGUILayout.SelectableLabel(eventMsgs, _eventMessageStyle, GUILayout.ExpandHeight(true), 
					GUILayout.ExpandWidth(true), GUILayout.MinWidth(textSize.x), GUILayout.MinHeight(textSize.y));
				EditorGUILayout.EndScrollView();
			}
		}
		private void DrawViewModeInfo()
		{
			float uiWidth = _editorUIRect.width * _infoPanelSettingsWidth;

			char upArrow = '\u25B2';
			char downArrow = '\u25BC';
			float arrayWidth = 25;

			GUIStyle editNodesBoxStyle = new GUIStyle(GUI.skin.textArea);
			GUIStyle entryStyle = new GUIStyle(GUI.skin.box);

			using (var hs = new EditorGUILayout.HorizontalScope())
			{
				using (var vs = new EditorGUILayout.VerticalScope(EditorStyles.helpBox, GUILayout.MaxWidth(uiWidth)))
				{
					EditorGUILayout.LabelField("This tool allows to Paint & Edit POINT attributes of Editable nodes.");
					EditorGUILayout.LabelField("Painting vertex colors is directly supported if a Paint SOP is made editable.");
					EditorGUILayout.LabelField("Use node list on the right to re-order editable nodes by order of edit operations.");
					EditorGUILayout.LabelField("Nodes that take inputs from other editable nodes should come after them in the list.");
				}

				using (var vs = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
				{
					// Draw each editable node (attribute store), along with buttons to re-order the node.

					using (var hs2 = new EditorGUILayout.HorizontalScope())
					{
						HEU_EditorUI.DrawHeadingLabel("EDIT ORDER");

						SerializedProperty cookUpstreamSerializedProperty = HEU_EditorUtility.GetSerializedProperty(_toolsInfoSerializedObject, "_alwaysCookUpstream");
						if (cookUpstreamSerializedProperty != null)
						{
							EditorGUILayout.PropertyField(cookUpstreamSerializedProperty,
								new GUIContent("Always Cook Inputs", "For multiple editable nodes, this forces each one to always cook upstream inputs first before applying edits."),
								GUILayout.Width(168));
						}
					}

					using (var vs2 = new EditorGUILayout.VerticalScope(editNodesBoxStyle))
					{
						using (var scrollScope = new EditorGUILayout.ScrollViewScope(_editNodeScrollPos))
						{
							_editNodeScrollPos = scrollScope.scrollPosition;

							int numStores = _attributesStores.Count;
							for (int i = 0; i < numStores; ++i)
							{
								using (var hsi = new EditorGUILayout.HorizontalScope(entryStyle))
								{
									if (GUILayout.Button(upArrow.ToString(), GUILayout.MaxWidth(arrayWidth)))
									{
										if (i > 0)
										{
											_asset.ReorderAttributeStore(i, i - 1);
										}
									}

									if (GUILayout.Button(downArrow.ToString(), GUILayout.MaxWidth(arrayWidth)))
									{
										if (i < numStores - 1)
										{
											_asset.ReorderAttributeStore(i, i + 1);
										}
									}

									EditorGUILayout.LabelField(_attributesStores[i].GeoName);
								}
							}

						}
					}
				}
			}
		}
示例#28
0
        /// <summary>
        /// Draw the UI for the given input node
        /// </summary>
        /// <param name="inputNode"></param>
        public static void EditorDrawInputNode(HEU_InputNode inputNode)
        {
            int plusButtonWidth = 20;

            //GUIStyle boldLabelStyle = new GUIStyle(EditorStyles.boldLabel);
            //boldLabelStyle.alignment = TextAnchor.UpperLeft;

            GUIContent inputTypeLabel = new GUIContent("Input Type");

            GUIContent translateLabel = new GUIContent("    Translate");
            GUIContent rotateLabel    = new GUIContent("    Rotate");
            GUIContent scaleLabel     = new GUIContent("    Scale");

            PopulateCache(inputNode);

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            string labelName = inputNode.LabelName;

            if (!string.IsNullOrEmpty(labelName))
            {
                EditorGUILayout.LabelField(labelName);
            }

            EditorGUI.indentLevel++;

            HEU_InputNode.InputObjectType inputObjectType             = (HEU_InputNode.InputObjectType)inputNode._uiCache._inputObjectTypeProperty.intValue;
            HEU_InputNode.InputObjectType userSelectedInputObjectType = (HEU_InputNode.InputObjectType)EditorGUILayout.EnumPopup(inputTypeLabel, inputObjectType);
            if (userSelectedInputObjectType != inputObjectType)
            {
                SerializedProperty pendingInputObjectTypeProperty = HEU_EditorUtility.GetSerializedProperty(inputNode._uiCache._inputNodeSerializedObject, "_pendingInputObjectType");
                if (pendingInputObjectTypeProperty != null)
                {
                    pendingInputObjectTypeProperty.intValue = (int)userSelectedInputObjectType;
                }
            }
            else
            {
                EditorGUILayout.PropertyField(inputNode._uiCache._keepWorldTransformProperty);
                EditorGUILayout.PropertyField(inputNode._uiCache._packBeforeMergeProperty);

                if (inputObjectType == HEU_InputNode.InputObjectType.HDA)
                {
                    SerializedProperty inputAssetsProperty = inputNode._uiCache._inputAssetsProperty;
                    if (inputAssetsProperty != null)
                    {
                        int  inputCount    = inputAssetsProperty.arraySize;
                        bool bSkipElements = false;

                        HEU_EditorUI.DrawSeparator();

                        EditorGUILayout.LabelField(string.Format("{0} input objects", inputCount));

                        using (var hs1 = new EditorGUILayout.HorizontalScope())
                        {
                            if (GUILayout.Button("Add Slot"))
                            {
                                inputAssetsProperty.InsertArrayElementAtIndex(inputCount);
                                bSkipElements = true;
                            }

                            if (GUILayout.Button("Add Selection"))
                            {
                                HEU_SelectionWindow.ShowWindow(inputNode.HandleSelectedObjectsForInputHDAs, typeof(HEU_HoudiniAssetRoot));
                            }

                            if (GUILayout.Button("Clear"))
                            {
                                inputAssetsProperty.ClearArray();
                                bSkipElements = true;
                            }
                        }

                        if (!bSkipElements)
                        {
                            using (var vs1 = new EditorGUILayout.VerticalScope())
                            {
                                for (int i = 0; i < inputCount; ++i)
                                {
                                    using (var hs2 = new EditorGUILayout.HorizontalScope())
                                    {
                                        EditorGUILayout.LabelField("Input " + (i + 1));

                                        if (GUILayout.Button("+", GUILayout.Width(plusButtonWidth)))
                                        {
                                            inputAssetsProperty.InsertArrayElementAtIndex(i);
                                            break;
                                        }

                                        if (GUILayout.Button("-", GUILayout.Width(plusButtonWidth)))
                                        {
                                            inputAssetsProperty.DeleteArrayElementAtIndex(i);
                                            break;
                                        }
                                    }

                                    EditorGUI.indentLevel++;
                                    using (var vs4 = new EditorGUILayout.VerticalScope())
                                    {
                                        if (i < inputNode._uiCache._inputAssetCache.Count)
                                        {
                                            HEU_InputNodeUICache.HEU_InputAssetUICache assetCache = inputNode._uiCache._inputAssetCache[i];

                                            UnityEngine.Object setObject = EditorGUILayout.ObjectField(assetCache._gameObjectProperty.objectReferenceValue, typeof(HEU_HoudiniAssetRoot), true);
                                            if (setObject != assetCache._gameObjectProperty.objectReferenceValue)
                                            {
                                                GameObject inputGO = setObject != null ? (setObject as HEU_HoudiniAssetRoot).gameObject : null;
                                                // Check not setting same asset as self
                                                if (inputGO == null || inputGO != inputNode.ParentAsset.RootGameObject)
                                                {
                                                    assetCache._gameObjectProperty.objectReferenceValue = inputGO;
                                                }
                                            }
                                        }
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }
                        }
                    }
                }
                //else if (inputObjectType == HEU_InputNode.InputObjectType.CURVE)
                //{
                //	TODO INPUT CURVE
                //}
                else if (inputObjectType == HEU_InputNode.InputObjectType.UNITY_MESH)
                {
                    SerializedProperty inputObjectsProperty = inputNode._uiCache._inputObjectsProperty;
                    if (inputObjectsProperty != null)
                    {
                        bool bSkipElements = false;

                        HEU_EditorUI.DrawSeparator();

                        EditorGUILayout.LabelField(string.Format("{0} input objects", inputObjectsProperty.arraySize));

                        using (var hs1 = new EditorGUILayout.HorizontalScope())
                        {
                            if (GUILayout.Button("Add Slot"))
                            {
                                inputObjectsProperty.arraySize++;
                                FixUpScaleProperty(inputObjectsProperty, inputObjectsProperty.arraySize - 1);
                                bSkipElements = true;
                            }

                            if (GUILayout.Button("Add Selection"))
                            {
                                HEU_SelectionWindow.ShowWindow(inputNode.HandleSelectedObjectsForInputObjects, typeof(GameObject));
                            }

                            if (GUILayout.Button("Clear"))
                            {
                                inputObjectsProperty.ClearArray();
                                bSkipElements = true;
                            }
                        }

                        if (!bSkipElements)
                        {
                            using (var vs1 = new EditorGUILayout.VerticalScope())
                            {
                                int inputCount = inputObjectsProperty.arraySize;
                                for (int i = 0; i < inputCount; ++i)
                                {
                                    using (var hs2 = new EditorGUILayout.HorizontalScope())
                                    {
                                        EditorGUILayout.LabelField("Input " + (i + 1));

                                        //using (var vs3 = new EditorGUILayout.VerticalScope())
                                        {
                                            if (GUILayout.Button("+", GUILayout.Width(plusButtonWidth)))
                                            {
                                                inputObjectsProperty.InsertArrayElementAtIndex(i);
                                                FixUpScaleProperty(inputObjectsProperty, i);
                                                break;
                                            }

                                            if (GUILayout.Button("-", GUILayout.Width(plusButtonWidth)))
                                            {
                                                inputObjectsProperty.DeleteArrayElementAtIndex(i);
                                                break;
                                            }
                                        }
                                    }

                                    EditorGUI.indentLevel++;
                                    using (var vs4 = new EditorGUILayout.VerticalScope())
                                    {
                                        if (i < inputNode._uiCache._inputObjectCache.Count)
                                        {
                                            HEU_InputNodeUICache.HEU_InputObjectUICache objectCache = inputNode._uiCache._inputObjectCache[i];

                                            EditorGUILayout.PropertyField(objectCache._gameObjectProperty, GUIContent.none);

                                            using (new EditorGUI.DisabledScope(!inputNode._uiCache._keepWorldTransformProperty.boolValue))
                                            {
                                                objectCache._transformOffsetProperty.boolValue = HEU_EditorUI.DrawToggleLeft(objectCache._transformOffsetProperty.boolValue, "Transform Offset");
                                                if (objectCache._transformOffsetProperty.boolValue)
                                                {
                                                    objectCache._translateProperty.vector3Value = EditorGUILayout.Vector3Field(translateLabel, objectCache._translateProperty.vector3Value);
                                                    objectCache._rotateProperty.vector3Value    = EditorGUILayout.Vector3Field(rotateLabel, objectCache._rotateProperty.vector3Value);
                                                    objectCache._scaleProperty.vector3Value     = EditorGUILayout.Vector3Field(scaleLabel, objectCache._scaleProperty.vector3Value);
                                                }
                                            }
                                        }
                                    }
                                    EditorGUI.indentLevel--;
                                }
                            }
                        }
                    }
                }
            }

            EditorGUI.indentLevel--;

            EditorGUILayout.EndVertical();

            if (EditorGUI.EndChangeCheck())
            {
                inputNode._uiCache._inputNodeSerializedObject.ApplyModifiedProperties();

                // When cooking, this will force input data to be uploaded
                inputNode.RequiresUpload = true;
                inputNode.ClearUICache();
            }
        }
		private void DrawEditAttributeValues()
		{
			if(_selectedAttributeData == null)
			{
				return;
			}

			if(_editPointsSelectedIndices.Count == 0)
			{
				return;
			}

			int arraySize = _selectedAttributeData._attributeInfo.tupleSize;

			// Use first values found as current values
			int ptIndex = _editPointsSelectedIndices[0] * arraySize;

			// Display values of selected pts which can be edited
			if (_selectedAttributeData._attributeType == HEU_AttributeData.AttributeType.INT)
			{
				// Copy values to display
				int[] values = new int[arraySize];
				for (int i = 0; i < arraySize; ++i)
				{
					values[i] = _selectedAttributeData._intValues[ptIndex + i];
				}

				// Display values and update attribute if changed
				bool bChanged = HEU_EditorUI.DrawArray<int>(_editValuesLabel, ref values, HEU_EditorUI.DrawFieldInt);
				if (bChanged)
				{
					int numPts = _editPointsSelectedIndices.Count;
					for (int i = 0; i < numPts; ++i)
					{
						ptIndex = _editPointsSelectedIndices[i] * arraySize;

						HEU_AttributesStore.SetAttributeEditValueInt(_selectedAttributeData, ptIndex, values);
					}

					_GUIChanged = true;

					HEU_AttributesStore.SetAttributeDataDirty(_selectedAttributeData);
				}
			}
			else if (_selectedAttributeData._attributeType == HEU_AttributeData.AttributeType.FLOAT)
			{
				// Copy values to display
				float[] values = new float[arraySize];
				for(int i = 0; i < arraySize; ++i)
				{
					values[i] = _selectedAttributeData._floatValues[ptIndex + i];
				}

				// Display values and update attribute if changed
				bool bChanged = HEU_EditorUI.DrawArray<float>(_editValuesLabel, ref values, HEU_EditorUI.DrawFieldFloat);
				if (bChanged)
				{
					int numPts = _editPointsSelectedIndices.Count;
					for (int i = 0; i < numPts; ++i)
					{
						ptIndex = _editPointsSelectedIndices[i] * arraySize;

						HEU_AttributesStore.SetAttributeEditValueFloat(_selectedAttributeData, ptIndex, values);
					}

					_GUIChanged = true;

					HEU_AttributesStore.SetAttributeDataDirty(_selectedAttributeData);
				}
			}
			else if (_selectedAttributeData._attributeType == HEU_AttributeData.AttributeType.STRING)
			{
				// Copy values to display
				string[] values = new string[arraySize];
				for (int i = 0; i < arraySize; ++i)
				{
					values[i] = _selectedAttributeData._stringValues[ptIndex + i];
				}

				// Display values and update attribute if changed
				bool bChanged = HEU_EditorUI.DrawArray<string>(_editValuesLabel, ref values, HEU_EditorUI.DrawFieldString);
				if (bChanged)
				{
					int numPts = _editPointsSelectedIndices.Count;
					for (int i = 0; i < numPts; ++i)
					{
						ptIndex = _editPointsSelectedIndices[i] * arraySize;

						HEU_AttributesStore.SetAttributeEditValueString(_selectedAttributeData, ptIndex, values);
					}

					_GUIChanged = true;

					HEU_AttributesStore.SetAttributeDataDirty(_selectedAttributeData);
				}
			}
		}
示例#30
0
	public static Color GetUISafeTextColorGreen()
	{
	    return HEU_EditorUI.IsEditorDarkSkin() ? Color.green : new Color(0.1f, 0.4f, 0.1f);
	}