本文整理汇总了C#中MouseCursor类的典型用法代码示例。如果您正苦于以下问题:C# MouseCursor类的具体用法?C# MouseCursor怎么用?C# MouseCursor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MouseCursor类属于命名空间,在下文中一共展示了MouseCursor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetCursorFromVector3
public static void SetCursorFromVector3(Vector2 currentPosition, Vector2 lastPosition)
{
Vector3 delta = currentPosition - lastPosition;
float angle = Mathf.Rad2Deg * Mathf.Atan2(delta.y, delta.x);
while (angle < 0)
{
angle += 180;
}
while (angle > 180)
{
angle -= 180;
}
if (angle >= 67.5f && angle < 112.5f)
{
activeCursor = MouseCursor.ResizeVertical;
}
else if (angle >= 112.5f && angle < 157.5f)
{
activeCursor = MouseCursor.ResizeUpLeft;
}
else if (angle >= 22.5f && angle < 67.5f)
{
activeCursor = MouseCursor.ResizeUpRight;
}
else
{
activeCursor = MouseCursor.ResizeHorizontal;
}
}
示例2: DisplayProvider
public DisplayProvider()
{
this.mouseCursor = new MouseCursor();
this.screenshot = new Screenshot();
this.tracker = new BoundsTracker();
this.waterMark = new WaterMark();
}
示例3: ControlTransformer
public ControlTransformer(Service service)
{
uiMouseCursor = new MouseCursor(service) { UpdatePriority = Priority.First };
isTransforming = false;
Messenger.Default.Register<string>(this, "SetDefaultCursor", SetDefaultCursor);
Messenger.Default.Register<string>(this, "AllowChangeOfCursor", AllowChangeOfCursor);
canChangeCursor = false;
}
示例4: Start
public void Start()
{
cur_mode = iMode.MODE_IDENTIFY;
scr_mouse = GameObject.Find("Main Camera").GetComponent<MouseCursor>();
UpdateCursor();
}
示例5: ChangeCursor
public static CursorChangeToken ChangeCursor(this IView view, MouseCursor cursor)
{
Verify.Argument.IsNotNull(view, "view");
var oldCursor = view.MouseCursor;
view.MouseCursor = cursor;
return new CursorChangeToken(view, oldCursor);
}
示例6: ScaleSlider
private static Vector2 ScaleSlider(int id, Vector2 pos, MouseCursor cursor, Rect cursorRect)
{
Vector2 vector2_1 = (Vector2) Handles.matrix.MultiplyPoint((Vector3) pos);
Event current = Event.current;
switch (current.GetTypeForControl(id))
{
case EventType.MouseDown:
if (current.button == 0 && cursorRect.Contains(Event.current.mousePosition) && !current.alt)
{
int num = id;
GUIUtility.keyboardControl = num;
GUIUtility.hotControl = num;
SpriteEditorHandles.s_CurrentMousePosition = current.mousePosition;
SpriteEditorHandles.s_DragStartScreenPosition = current.mousePosition;
SpriteEditorHandles.s_DragScreenOffset = SpriteEditorHandles.s_CurrentMousePosition - vector2_1;
current.Use();
EditorGUIUtility.SetWantsMouseJumping(1);
break;
}
break;
case EventType.MouseUp:
if (GUIUtility.hotControl == id && (current.button == 0 || current.button == 2))
{
GUIUtility.hotControl = 0;
current.Use();
EditorGUIUtility.SetWantsMouseJumping(0);
break;
}
break;
case EventType.MouseDrag:
if (GUIUtility.hotControl == id)
{
SpriteEditorHandles.s_CurrentMousePosition += current.delta;
Vector2 vector2_2 = pos;
pos = (Vector2) Handles.s_InverseMatrix.MultiplyPoint((Vector3) SpriteEditorHandles.s_CurrentMousePosition);
if (!Mathf.Approximately((vector2_2 - pos).magnitude, 0.0f))
GUI.changed = true;
current.Use();
break;
}
break;
case EventType.KeyDown:
if (GUIUtility.hotControl == id && current.keyCode == KeyCode.Escape)
{
pos = (Vector2) Handles.s_InverseMatrix.MultiplyPoint((Vector3) (SpriteEditorHandles.s_DragStartScreenPosition - SpriteEditorHandles.s_DragScreenOffset));
GUIUtility.hotControl = 0;
GUI.changed = true;
current.Use();
break;
}
break;
case EventType.Repaint:
EditorGUIUtility.AddCursorRect(cursorRect, cursor, id);
break;
}
return pos;
}
示例7: CustomActionField
public static void CustomActionField(Rect fieldRect, Action action, bool showCursorPredicate, bool clickPredicate, MouseCursor cursor)
{
if (showCursorPredicate)
AddCursorRect(fieldRect, cursor);
if (fieldRect.Contains(Event.current.mousePosition))
{
if (clickPredicate)
action();
}
}
示例8: CursorHighlightOptions
public CursorHighlightOptions()
{
InitializeComponent();
//
this.mouseCursor = new MouseCursor();
//
this.tbRadious.Minimum = minRadious;
this.tbRadious.Maximum = maxRadious;
this.Color = Color.FromName(defaultColorString);
this.Radious = defaultRadious;
}
示例9: FromUri
/// <summary>
/// Creates a <see cref="MouseCursor"/> based on the specified image
/// </summary>
/// <param name="cursorUri">The <see cref="Uri"/> of the image</param>
/// <returns>A <see cref="MouseCursor"/></returns>
public static MouseCursor FromUri(Uri cursorUri)
{
Stream bitmapStream;
Bitmap bitmap;
OpenTK.MouseCursor cursorObject;
MouseCursor cursor;
bitmapStream = Application.GetResourceStream(cursorUri);
bitmap = new Bitmap(bitmapStream);
var data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, 32, 32), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
cursorObject = new OpenTK.MouseCursor(0,0,32, 32, data.Scan0);
bitmap.UnlockBits(data);
cursor = new MouseCursor(cursorObject);
return cursor;
}
示例10: PointSlider
internal static Vector2 PointSlider(Vector2 pos, MouseCursor cursor, GUIStyle dragDot, GUIStyle dragDotActive)
{
int controlId = GUIUtility.GetControlID("Slider1D".GetHashCode(), FocusType.Keyboard);
Vector2 vector2 = (Vector2) Handles.matrix.MultiplyPoint((Vector3) pos);
Rect rect = new Rect(vector2.x - dragDot.fixedWidth * 0.5f, vector2.y - dragDot.fixedHeight * 0.5f, dragDot.fixedWidth, dragDot.fixedHeight);
if (Event.current.GetTypeForControl(controlId) == EventType.Repaint)
{
if (GUIUtility.hotControl == controlId)
dragDotActive.Draw(rect, GUIContent.none, controlId);
else
dragDot.Draw(rect, GUIContent.none, controlId);
}
return SpriteEditorHandles.ScaleSlider(pos, cursor, rect);
}
示例11: PingField
public static void PingField(UnityObject obj, bool showPredicate, bool clickPredicate, MouseCursor cursor = MouseCursor.Zoom)
{
PingField(GetLastRect(), obj, showPredicate, clickPredicate, cursor);
}
示例12: TryScaleButton
bool TryScaleButton(Vector3 position, float size)
{
size *= HandleUtility.GetHandleSize(position);
if (Vector3.Distance(mousePosition, position) < size)
{
if (e.type == EventType.MouseDown)
return true;
else
{
mouseCursor = MouseCursor.ScaleArrow;
Handles.color = Color.green;
}
}
else
Handles.color = Color.white;
var buffer = size / 4;
Handles.DrawLine(new Vector3(position.x - size - buffer, position.y), new Vector3(position.x - size + buffer, position.y));
Handles.DrawLine(new Vector3(position.x + size - buffer, position.y), new Vector3(position.x + size + buffer, position.y));
Handles.DrawLine(new Vector3(position.x, position.y - size - buffer), new Vector3(position.x, position.y - size + buffer));
Handles.DrawLine(new Vector3(position.x, position.y + size - buffer), new Vector3(position.x, position.y + size + buffer));
Handles.RectangleCap(0, position, Quaternion.identity, size);
return false;
}
示例13: TryHoverCurvePoint
bool TryHoverCurvePoint(out int index)
{
if (TryHover(curvePoints, Color.white, out index))
{
mouseCursor = MouseCursor.MoveArrow;
return true;
}
return false;
}
示例14: OnSceneGUI
void OnSceneGUI()
{
if (target == null)
return;
if (KeyPressed(editKey))
editing = !editing;
if (editing)
{
//Update lists
if (keyPoints == null)
{
keyPoints = new List<Vector3>(polyMesh.keyPoints);
curvePoints = new List<Vector3>(polyMesh.curvePoints);
isCurve = new List<bool>(polyMesh.isCurve);
}
//Crazy hack to register undo
if (undoCallback == null)
{
undoCallback = typeof(EditorApplication).GetField("undoRedoPerformed", BindingFlags.NonPublic | BindingFlags.Static);
if (undoCallback != null)
undoCallback.SetValue(null, new EditorApplication.CallbackFunction(OnUndoRedo));
}
//Load handle matrix
Handles.matrix = polyMesh.transform.localToWorldMatrix;
//Draw points and lines
DrawAxis();
Handles.color = Color.white;
for (int i = 0; i < keyPoints.Count; i++)
{
Handles.color = nearestLine == i ? Color.green : Color.white;
DrawSegment(i);
if (selectedIndices.Contains(i))
{
Handles.color = Color.green;
DrawCircle(keyPoints[i], 0.08f);
}
else
Handles.color = Color.white;
DrawKeyPoint(i);
if (isCurve[i])
{
Handles.color = (draggingCurve && dragIndex == i) ? Color.white : Color.blue;
DrawCurvePoint(i);
}
}
//Quit on tool change
if (e.type == EventType.KeyDown)
{
switch (e.keyCode)
{
case KeyCode.Q:
case KeyCode.W:
case KeyCode.E:
case KeyCode.R:
return;
}
}
//Quit if panning or no camera exists
if (Tools.current == Tool.View || (e.isMouse && e.button > 0) || Camera.current == null || e.type == EventType.ScrollWheel)
return;
//Quit if laying out
if (e.type == EventType.Layout)
{
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
return;
}
//Cursor rectangle
EditorGUIUtility.AddCursorRect(new Rect(0, 0, Camera.current.pixelWidth, Camera.current.pixelHeight), mouseCursor);
mouseCursor = MouseCursor.Arrow;
//Extrude key state
if (e.keyCode == extrudeKey)
{
if (extrudeKeyDown)
{
if (e.type == EventType.KeyUp)
extrudeKeyDown = false;
}
else if (e.type == EventType.KeyDown)
extrudeKeyDown = true;
}
//Update matrices and snap
worldToLocal = polyMesh.transform.worldToLocalMatrix;
inverseRotation = Quaternion.Inverse(polyMesh.transform.rotation) * Camera.current.transform.rotation;
snap = gridSnap;
//Update mouse position
screenMousePosition = new Vector3(e.mousePosition.x, Camera.current.pixelHeight - e.mousePosition.y);
var plane = new Plane(-polyMesh.transform.forward, polyMesh.transform.position);
var ray = Camera.current.ScreenPointToRay(screenMousePosition);
//.........这里部分代码省略.........
示例15: ScaleSlider
internal static Vector2 ScaleSlider(Vector2 pos, MouseCursor cursor, Rect cursorRect)
{
return ScaleSlider(GUIUtility.GetControlID("Slider1D".GetHashCode(), FocusType.Keyboard), pos, cursor, cursorRect);
}