Ejemplo n.º 1
0
	private void SwitchToMode(HEU_Curve.Interaction newInteraction)
	{
	    DeselectAllPoints();

	    if (_interactionMode == HEU_Curve.Interaction.VIEW && newInteraction != HEU_Curve.Interaction.VIEW)
	    {
		// When transitioning from View mode, need to hide the info planel until the layout event is
		// triggered so that the additional UI elements are properly handled by Unity.
		_showInfoRepaint = false;
	    }

	    _interactionMode = newInteraction;

	    // We clear our add points list when transitioning to other modes
	    if (_interactionMode != HEU_Curve.Interaction.ADD)
	    {
		_latestPointAddedCurve = null;
		_latestPointsAdded.Clear();
	    }

	    // Show/hide the position handle
	    if (_interactionMode == HEU_Curve.Interaction.EDIT || _interactionMode == HEU_Curve.Interaction.ADD)
	    {
		Tools.hidden = true;
	    }
	    else
	    {
		ShowTools();
	    }
	}
Ejemplo n.º 2
0
	// UI LOGIC ---------------------------------------------------------------------------------------------------

	private void OnEnable()
	{
	    _lineTexture = new Texture2D(1, 2);
	    _lineTexture.wrapMode = TextureWrapMode.Repeat;
	    _lineTexture.SetPixel(0, 0, new Color(1, 1, 1, 0));
	    _lineTexture.SetPixel(0, 1, new Color(1, 1, 0, 1));
	    _lineTexture.Apply();

	    _infoRect = new Rect(10, 10, 500, 220);

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

	    _selectedCurvePoints.Clear();

	    HEU_Curve.Interaction setInteraction = HEU_Curve.PreferredNextInteractionMode;
	    HEU_Curve.PreferredNextInteractionMode = HEU_Curve.Interaction.VIEW;
	    SwitchToMode(setInteraction);

	    // Moves focus to the Scene window, which we need for keyboard input at start
	    if (SceneView.currentDrawingSceneView != null)
	    {
		SceneView.currentDrawingSceneView.Focus();
	    }

	    // Callback will be used to disable this tool and reset state
	    Selection.selectionChanged += SelectionChangedCallback;

	    _showInfo = false;
	    _showInfoRepaint = false;
	}
Ejemplo n.º 3
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();
	}