Exemplo n.º 1
0
		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();
			}
		}
Exemplo n.º 2
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();
	}