本文整理汇总了C#中UnityEngine.Event.Use方法的典型用法代码示例。如果您正苦于以下问题:C# Event.Use方法的具体用法?C# Event.Use怎么用?C# Event.Use使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Event
的用法示例。
在下文中一共展示了Event.Use方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnContextClick
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnContextClick( Event e )
{
if ( Positionless || PointInControl( e.mousePosition ) )
{
Menu.ShowAsContext();
e.Use();
}
}
示例2: eventHandler
public override void eventHandler(GameObject gameObject, QObjectList objectList, Event currentEvent, Rect curRect)
{
if (currentEvent.isMouse && currentEvent.type == EventType.MouseDown && currentEvent.button == 0 && curRect.Contains(currentEvent.mousePosition))
{
currentEvent.Use();
Type iconSelectorType = Assembly.Load("UnityEditor").GetType("UnityEditor.IconSelector");
MethodInfo showIconSelectorMethodInfo = iconSelectorType.GetMethod("ShowAtPosition", BindingFlags.Static | BindingFlags.NonPublic);
showIconSelectorMethodInfo.Invoke(null, new object[] { gameObject, curRect, true });
}
}
示例3: OnMouseDown
protected override void OnMouseDown( Event e )
{
if ( m_label.PointInControl( e.mousePosition ) )
{
if ( BoundDecoratorlSelected != null && m_target != null )
{
BoundDecoratorlSelected( m_target, e.button );
}
e.Use();
}
}
示例4: MainActionKeyForControl
internal static bool MainActionKeyForControl(Event evt, int controlId)
{
if (GUIUtility.keyboardControl != controlId)
{
return false;
}
bool flag2 = ((evt.alt || evt.shift) || evt.command) || evt.control;
if (((evt.type == EventType.KeyDown) && (evt.character == ' ')) && !flag2)
{
evt.Use();
return false;
}
return (((evt.type == EventType.KeyDown) && (((evt.keyCode == KeyCode.Space) || (evt.keyCode == KeyCode.Return)) || (evt.keyCode == KeyCode.KeypadEnter))) && !flag2);
}
示例5: HandleEvent
public bool HandleEvent(Event currentEvent)
{
switch(currentEvent.type)
{
case EventType.MouseUp:
if(!Rect.Contains(currentEvent.mousePosition)) {
break;
}
OnMouseUp(currentEvent.button, currentEvent.mousePosition);
currentEvent.Use();
return true;
}
return false;
}
示例6: IsTap
public bool IsTap(Event e, Rect position, Rect hitPosition, ButtonType type, Texture2D textureNormal, Texture2D textureHover, Texture2D textureActive, string labelText, GUIStyle guiStyleLabel)
{
bool hitContain = (e.button == 0) && hitPosition.Contains(e.mousePosition);
if (e.type == EventType.MouseDown && hitContain)
{
touching = true;
}
if (FASGesture.IsDragging || FASGesture.IsPinching)
{
touching = false;
}
if (e.type == EventType.MouseUp && hitContain && touching)
{
e.Use();
if(!isActive)
StartCoroutine(ButtonIsActive());
touching = false;
return true;
}
Texture2D buttonTexture = (touching) ? textureHover : textureNormal;
buttonTexture = (isActive) ? textureActive : buttonTexture;
if (type == ButtonType.TextureOnly)
{
GUI.DrawTexture(position, buttonTexture, scaleMode);
}
else if (type == ButtonType.FrameAndLabel)
{
FresviiGUIUtility.DrawButtonFrame(position, buttonTexture, FresviiGUIManager.Instance.ScaleFactor);
GUI.Label(position, labelText, guiStyleLabel);
}
return false;
}
示例7: Draw
public void Draw(Rect position, Event e)
{
if (labels.Count == 0) return;
for (int i = 0; i < labels.Count; i++)
{
Rect buttonRect = new Rect(position.x + i * position.width / labels.Count, position.y, position.width / labels.Count, position.height);
FresviiGUIUtility.DrawPosition pos = FresviiGUIUtility.DrawPosition.Center;
if (i == 0) pos = FresviiGUIUtility.DrawPosition.Left;
else if (i == labels.Count- 1) pos = FresviiGUIUtility.DrawPosition.Right;
FresviiGUIUtility.DrawSplitTexture(buttonRect, (i == selectedIndex) ? buttonActive : buttonNegative, scaleFactor * 4.0f, scaleFactor * 4.0f, scaleFactor * 4.0f, scaleFactor * 4.0f, pos);
guiStyleLabel.normal.textColor = ((i == selectedIndex) ? buttonLabelActive : buttonLabelNegative);
GUI.Label(buttonRect, labels[i], guiStyleLabel);
bool hitContain = (e.button == 0) && buttonRect.Contains(e.mousePosition);
if (e.type == EventType.MouseDown && hitContain)
{
touching = true;
}
if (FASGesture.IsDragging)
{
touching = false;
}
if (e.type == EventType.MouseUp && hitContain && touching)
{
e.Use();
OnTapped(i);
selectedIndex = i;
}
}
}
示例8: eventHandler
// EVENTS
public override void eventHandler(GameObject gameObject, QObjectList objectList, Event currentEvent, Rect curRect)
{
if (currentEvent.isMouse && currentEvent.type == EventType.MouseDown && currentEvent.button == 0 && curRect.Contains(currentEvent.mousePosition))
{
if (currentEvent.type == EventType.MouseDown)
{
Color color = QResources.getInstance().getColor(QColor.Background);
color.a = 0.1f;
if (objectList != null) objectList.gameObjectColor.TryGetValue(gameObject, out color);
try
{
PopupWindow.Show(curRect, new QColorPickerWindow(Selection.Contains(gameObject) ? Selection.gameObjects : new GameObject[] { gameObject }, colorSelectedHandler, colorRemovedHandler));
}
catch
{}
}
currentEvent.Use();
}
}
示例9: eventHandler
public override void eventHandler(GameObject gameObject, QObjectList objectList, Event currentEvent, Rect curRect)
{
if (currentEvent.isMouse && currentEvent.type == EventType.MouseDown && currentEvent.button == 0 && curRect.Contains(currentEvent.mousePosition))
{
currentEvent.Use();
int intStaticFlags = (int)staticFlags;
gameObjects = Selection.Contains(gameObject) ? Selection.gameObjects : new GameObject[] { gameObject };
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Nothing" ), intStaticFlags == 0, staticChangeHandler, 0);
menu.AddItem(new GUIContent("Everything" ), intStaticFlags == -1, staticChangeHandler, -1);
menu.AddItem(new GUIContent("Lightmap Static" ), (intStaticFlags & (int)StaticEditorFlags.LightmapStatic) > 0, staticChangeHandler, (int)StaticEditorFlags.LightmapStatic);
menu.AddItem(new GUIContent("Occluder Static" ), (intStaticFlags & (int)StaticEditorFlags.OccluderStatic) > 0, staticChangeHandler, (int)StaticEditorFlags.OccluderStatic);
menu.AddItem(new GUIContent("Batching Static" ), (intStaticFlags & (int)StaticEditorFlags.BatchingStatic) > 0, staticChangeHandler, (int)StaticEditorFlags.BatchingStatic);
menu.AddItem(new GUIContent("Navigation Static" ), (intStaticFlags & (int)StaticEditorFlags.NavigationStatic) > 0, staticChangeHandler, (int)StaticEditorFlags.NavigationStatic);
menu.AddItem(new GUIContent("Occludee Static" ), (intStaticFlags & (int)StaticEditorFlags.OccludeeStatic) > 0, staticChangeHandler, (int)StaticEditorFlags.OccludeeStatic);
menu.AddItem(new GUIContent("Off Mesh Link Generation" ), (intStaticFlags & (int)StaticEditorFlags.OffMeshLinkGeneration) > 0, staticChangeHandler, (int)StaticEditorFlags.OffMeshLinkGeneration);
#if UNITY_5
menu.AddItem(new GUIContent("Reflection Probe Static" ), (intStaticFlags & (int)StaticEditorFlags.ReflectionProbeStatic) > 0, staticChangeHandler, (int)StaticEditorFlags.ReflectionProbeStatic);
#endif
menu.ShowAsContext();
}
}
示例10: OnMouseUp
//.........这里部分代码省略.........
// // Shift mode means only add what they click (clicking nothing does nothing)
// if (Physics.Raycast(ray, out hit, float.PositiveInfinity, layerMask))
// {
// if (Selection.objects == null || Selection.objects.Length == 0)
// {
// // Didn't already have a selection, so short cut via activeTransform
// Selection.activeObject = hit.transform.gameObject;
// }
// else
// {
// List<UnityEngine.Object> objects = new List<UnityEngine.Object>(Selection.objects);
//
// if (objects.Contains(hit.transform.gameObject))
// {
// objects.Remove(hit.transform.gameObject);
// }
// else
// {
// objects.Add(hit.transform.gameObject);
// }
// Selection.objects = objects.ToArray();
// }
// }
// }
// else
{
List<RaycastHit> hits = RaycastBrushesAll(ray);
GameObject selectedObject = null;
if(hits.Count == 0) // Didn't hit anything, blank the selection
{
previousHits.Clear();
}
else if(hits.Count == 1) // Only hit one thing, no ambiguity, this is what is selected
{
selectedObject = hits[0].collider.gameObject;
previousHits.Clear();
}
else
{
// First try and select anything other than what has been previously hit
for (int i = 0; i < hits.Count; i++)
{
if(!previousHits.Contains(hits[i].collider.gameObject))
{
selectedObject = hits[i].collider.gameObject;
break;
}
}
// Only found previously hit objects
if(selectedObject == null)
{
// Walk backwards to find the oldest previous hit that has been hit by this ray
for (int i = previousHits.Count-1; i >= 0 && selectedObject == null; i--)
{
for (int j = 0; j < hits.Count; j++)
{
if(hits[j].collider.gameObject == previousHits[i])
{
selectedObject = previousHits[i];
break;
}
}
}
}
}
if (EnumHelper.IsFlagSet(e.modifiers, EventModifiers.Shift)
|| EnumHelper.IsFlagSet(e.modifiers, EventModifiers.Control)
|| EnumHelper.IsFlagSet(e.modifiers, EventModifiers.Command))
{
List<UnityEngine.Object> objects = new List<UnityEngine.Object>(Selection.objects);
if (objects.Contains(selectedObject))
{
objects.Remove(selectedObject);
}
else
{
objects.Add(selectedObject);
}
Selection.objects = objects.ToArray();
}
else
{
Selection.activeGameObject = selectedObject;
}
if(selectedObject != null)
{
previousHits.Remove(selectedObject);
// Most recent hit
previousHits.Insert(0, selectedObject);
}
}
e.Use();
}
}
示例11: ProcessEvent
/// <summary>
/// Handle the specified event.
/// </summary>
bool ProcessEvent (Event ev)
{
RuntimePlatform rp = Application.platform;
bool isMac = (rp == RuntimePlatform.OSXEditor || rp == RuntimePlatform.OSXPlayer || rp == RuntimePlatform.OSXWebPlayer);
bool ctrl = isMac ? (ev.modifiers == EventModifiers.Command) : (ev.modifiers == EventModifiers.Control);
switch (ev.keyCode)
{
case KeyCode.Backspace:
{
ev.Use();
mEditor.Backspace();
UpdateLabel();
ExecuteOnChange();
return true;
}
case KeyCode.Delete:
{
ev.Use();
mEditor.Delete();
UpdateLabel();
ExecuteOnChange();
return true;
}
case KeyCode.LeftArrow:
{
ev.Use();
mEditor.MoveLeft();
UpdateLabel();
return true;
}
case KeyCode.RightArrow:
{
ev.Use();
mEditor.MoveRight();
UpdateLabel();
return true;
}
case KeyCode.Home:
case KeyCode.UpArrow:
{
ev.Use();
mEditor.MoveTextStart();
UpdateLabel();
return true;
}
case KeyCode.End:
case KeyCode.DownArrow:
{
ev.Use();
mEditor.MoveTextEnd();
UpdateLabel();
return true;
}
// Copy
case KeyCode.C:
{
if (ctrl)
{
ev.Use();
NGUITools.clipboard = value;
}
return true;
}
// Paste
case KeyCode.V:
{
if (ctrl)
{
ev.Use();
Append(NGUITools.clipboard);
}
return true;
}
// Cut
case KeyCode.X:
{
if (ctrl)
{
ev.Use();
NGUITools.clipboard = value;
value = "";
}
return true;
}
// Submit
case KeyCode.Return:
//.........这里部分代码省略.........
示例12: OnSceneGUI
void OnSceneGUI(SceneView scnview)
{
if(!enabled)// || (EditorWindow.focusedWindow != scnview && !lockhandleToCenter))
return;
if(editor && editor.editLevel != EditLevel.Plugin)
editor.SetEditLevel(EditLevel.Plugin);
// #if UNITY_5
// if( Lightmapping.giWorkflowMode == Lightmapping.GIWorkflowMode.Iterative )
// {
// pb_Lightmapping.PushGIWorkflowMode();
// Lightmapping.Cancel();
// Debug.LogWarning("Vertex Painter requires Continuous Baking to be Off. When you close the Vertex Painter tool, Continuous Baking will returned to it's previous state automatically.\nIf you toggle Continuous Baking On while the Vertex Painter is open, you may lose all mesh vertex colors.");
// }
// #endif
currentEvent = Event.current;
sceneCamera = scnview.camera;
screenCenter.x = Screen.width/2f;
screenCenter.y = Screen.height/2f;
mouseMoveEvent = currentEvent.type == EventType.MouseMove;
/**
* Check if a new object is under the mouse.
*/
if( mouseMoveEvent )
{
GameObject go = HandleUtility.PickGameObject(Event.current.mousePosition, false);
if( go != null && (pb == null || go != pb.gameObject) )
{
pb = go.GetComponent<pb_Object>();
if(pb != null)
{
textures = GetTextures( pb.transform.GetComponent<MeshRenderer>().sharedMaterial ).ToArray();
Repaint();
modified.Add(pb);
pb.ToMesh();
pb.Refresh();
}
}
}
/**
* Hit test scene
*/
if(!lockhandleToCenter && !pb_Handle_Utility.SceneViewInUse(currentEvent))
{
if(pb != null)
{
if(!hovering.ContainsKey(pb))
{
hovering.Add(pb, pb.colors ?? new Color[pb.vertexCount]);
}
else
{
if(pb.msh.vertexCount != pb.vertexCount)
{
// script reload can make this happen
pb.ToMesh();
pb.Refresh();
}
pb.msh.colors = hovering[pb];
}
Ray ray = HandleUtility.GUIPointToWorldRay(currentEvent.mousePosition);
pb_RaycastHit hit;
if ( pb_Handle_Utility.MeshRaycast(ray, pb, out hit) )
{
handlePosition = pb.transform.TransformPoint(hit.Point);
handleDistance = Vector3.Distance(handlePosition, sceneCamera.transform.position);
handleRotation = Quaternion.LookRotation(nonzero(pb.transform.TransformDirection(hit.Normal)), Vector3.up);
Color[] colors = pb.msh.colors;
int[][] sharedIndices = pb.sharedIndices.ToArray();
// wrapped in try/catch because a script reload can cause the mesh
// to re-unwrap itself in some crazy configuration, throwing off the
// vertex count sync.
try
{
for(int i = 0; i < sharedIndices.Length; i++)
{
float dist = Vector3.Distance(hit.Point, pb.vertices[sharedIndices[i][0]]);
if(dist < brushSize)
{
for(int n = 0; n < sharedIndices[i].Length; n++)
{
colors[sharedIndices[i][n]] = Lerp(hovering[pb][sharedIndices[i][n]], color, (1f-(dist/brushSize)) * brushOpacity );
}
//.........这里部分代码省略.........
示例13: OnIdleContextClick
void OnIdleContextClick( Event e )
{
if( currentNode == null )
{
GenericMenu menu = new GenericMenu();
menu.AddItem( new GUIContent("New Menu"), false, Callback, "newScreen" );
menu.ShowAsContext();
e.Use();
}
}
示例14: HandleRenderer
internal void HandleRenderer(Renderer r, int materialIndex, Event evt)
{
bool flag = false;
switch (evt.type)
{
case EventType.DragUpdated:
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
flag = true;
break;
case EventType.DragPerform:
DragAndDrop.AcceptDrag();
flag = true;
break;
}
if (!flag)
return;
Undo.RecordObject((UnityEngine.Object) r, "Assign Material");
Material[] sharedMaterials = r.sharedMaterials;
if (!evt.alt && (materialIndex >= 0 && materialIndex < r.sharedMaterials.Length))
{
sharedMaterials[materialIndex] = this.target as Material;
}
else
{
for (int index = 0; index < sharedMaterials.Length; ++index)
sharedMaterials[index] = this.target as Material;
}
r.sharedMaterials = sharedMaterials;
evt.Use();
}
示例15: ProcessWheel
/// <summary>
/// A special method, since ScrollWheel event is not a mouse event nor a key event
/// </summary>
/// <param name="e"></param>
public void ProcessWheel(Event e)
{
#if DEBUG
if (DebugMode)
Debug.Log("MouseProcessor.ProcessWheel");
#endif
_mousePosition = new Point(e.mousePosition.x, e.mousePosition.y);
#if DEBUG
if (DebugMode)
Debug.Log("MouseProcessor.ScrollWheel");
#endif
if (SystemManager.MouseWheelSignal.Connected)
SystemManager.MouseWheelSignal.Emit(e, _mousePosition, e.delta.y);
e.Use(); // cancel the Unity default
}