private void SelectColor() { Vector3 mouseDirection = Vector3.Normalize(Camera.main.ScreenToWorldPoint(Input.mousePosition) - originalCursorLocation); //Vector3 mouseDirection = Vector3.Normalize(new Vector3(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"), 0)); float angle = AngleBetweenVectors(mouseDirection, Vector3.up); float from0To360 = angle < 0f ? 360f + angle : angle; cursor.transform.localPosition = Quaternion.Euler(0, 0, from0To360) * new Vector3(0, rect.sizeDelta.x / 3f, 0);; float angleIncrement = 360f / (float)BaseColors.Count; float cursorOffset = angleIncrement / 2f; float from0To360Offset = (angle + cursorOffset) < 0f ? 360f + (angle + cursorOffset) : (angle + cursorOffset); int position = (int)(from0To360Offset / angleIncrement); if (Selected != pickables[position]) { if (Selected != null) { Selected.Deselect(); } Selected = pickables[position]; Selected.Select(); CurrentSelectedColor.ColorValue = Selected.ColorValue; } }
private GameObject GenerateColorWheelSelection(Color color) { GameObject selection = Instantiate(ColorWheelSelectionPrefab, transform); ColorPickable pickable = selection.GetComponent <ColorPickable>(); pickable.ColorValue = color; pickables.Add(pickable); return(selection); }
void Update() { if (Input.GetMouseButtonUp(MouseButton.Left)) { IsFinishedSelecting = true; } if (Input.GetMouseButton(MouseButton.Left)) { SelectColor(); //Cursor.visible = false; } else { //Cursor.visible = true; if (Selected != null) { Selected.Deselect(); Selected = null; } } }