static void Update(SceneView scene) { if (!ToolEnable) { return; } if (gObject == null && Select.Equals(Event.current) && Selection.activeObject != null) { gObject = Selection.activeGameObject; lastLayer = gObject.layer; lastPosition = gObject.transform.position; SetIndicesDFS(gObject.transform, 2); Undo.RecordObject(gObject.transform, "Mesh glued"); } else if (gObject != null && Hotkey.LeftMouse.Equals(Event.current)) { SetIndicesDFS(gObject.transform, lastLayer); gObject = null; } else if (gObject != null && Select.Equals(Event.current)) { SetIndicesDFS(gObject.transform, lastLayer); gObject.transform.position = lastPosition; gObject = null; } else if (gObject != null) // Moving { Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); RaycastHit hitResult; if (Physics.Raycast(ray, out hitResult)) { var normal = hitResult.normal; var forward = gObject.transform.forward; float diff = Mathf.Abs((normal - forward).magnitude - 1); if (diff > 0.99) { forward = gObject.transform.right; } gObject.transform.position = hitResult.point; gObject.transform.rotation = Quaternion.LookRotation(forward, normal); } } }
// Update is called once per frame static void Update(SceneView scene) { if (!ToolEnable || !Snap.Equals(Event.current) || Selection.activeTransform == null) { return; } var transform = Selection.activeTransform; Ray ray = new Ray(transform.position, transform.up * -1); RaycastHit hitResult; if (Physics.Raycast(ray, out hitResult)) { Undo.RecordObject(transform, "Snap to floor"); transform.position = hitResult.point; var normal = hitResult.normal; var forward = transform.forward; float diff = Mathf.Abs((normal - forward).magnitude - 1); if (diff > 0.99) { forward = transform.right; } transform.rotation = Quaternion.LookRotation(forward, normal); } else { Debug.Log("RASnapToFloor raycast failed."); } }
/// <summary> /// Detects when the user has pressed a key to generate a new hotkey. /// </summary> private void Keyboard_OnKeyPressed(object sender, Rampastring.XNAUI.Input.KeyPressEventArgs e) { foreach (var blacklistedKey in keyBlacklist) { if (e.PressedKey == blacklistedKey) { return; } } var currentModifiers = GetCurrentModifiers(); // The XNA keys seem to match the Windows virtual keycodes! This saves us some work pendingHotkey = new Hotkey(GetKeyOverride(e.PressedKey), currentModifiers); lblCurrentlyAssignedTo.Text = string.Empty; foreach (var command in gameCommands) { if (pendingHotkey.Equals(command.Hotkey)) { lblCurrentlyAssignedTo.Text = "Currently assigned to:" + Environment.NewLine + command.UIName; } } }
public bool Equals(Gesture other) { if (other == null) { return(false); } return(Name == other.Name && Hotkey != null && Hotkey.Equals(other.Hotkey) && MouseAction == other.MouseAction); }
static void Update(SceneView scene) { if (!ShowWindow.Equals(Event.current) || !ToolEnable) { return; } var window = GetWindow <ReplaceSelected>(); int width = 300, height = 50; float x = scene.position.x + scene.position.width - width; float y = scene.position.y + height; window.position = new Rect(x, y, width, height); }
/* Sets a new hotkey in allHotkeys by replacing it with a new hotkey. * If you need to find a specific hotkey, use GetHotkey() which you can find * via primary hotkey or hotkey name */ public static bool SetHotkey(Hotkey oldHotkey, Hotkey newHotkey) { bool setNewHotkey = false; for (int i = 0; i < instance.allHotkeys.Count; i++) { /* If we find the hotkey, set it! */ if (oldHotkey.Equals(instance.allHotkeys[i])) { instance.allHotkeys[i] = newHotkey; setNewHotkey = true; break; } } return(setNewHotkey); }
// Update is called once per frame static void Update(SceneView scene) { if (!group.Equals(Event.current) || !ToolEnable || Selection.gameObjects.Length == 0) { return; } var firstSelectedObj = Selection.gameObjects.First(); var parent = new GameObject("Group: " + firstSelectedObj.name).transform; parent.parent = firstSelectedObj.transform.parent; foreach (var item in Selection.gameObjects) { Undo.SetTransformParent(item.transform, parent, "Group objects"); item.transform.parent = parent; } Debug.Log(string.Format("Grouping. Objects count: {0}. Group name - Group: {1}", Selection.gameObjects.Length, firstSelectedObj.name)); }
public static bool TestEquals_Object([NotNull] Hotkey hotkey, object obj) { return(hotkey.Equals(obj)); }
public static bool TestEquals([NotNull] Hotkey hotkey1, Hotkey hotkey2) { return(hotkey1.Equals(hotkey2)); }