void Update() { int i = 0; foreach (GameObject button in buttons) { Vector3 offset = new Vector3(0, draw.GetLayerIndex(button.GetComponent <BaseButton>().GetName()) * -80f - 10f, 0); Vector3 destination = new Vector3(paletteMenuContent.GetComponent <RectTransform>().rect.width / 2, 0, 0) + paletteMenuContent.GetComponent <RectTransform>().position + offset; if (!button.gameObject.transform.Find("PaletteDrag").gameObject.GetComponent <PaletteDrag>().IsDragged()) { if (Vector3.Distance(button.GetComponent <RectTransform>().position, destination) > 0.1f) { button.GetComponent <RectTransform>().position = Vector3.SmoothDamp(button.GetComponent <RectTransform>().position, destination, ref velocity, 0.01f); } else { button.GetComponent <RectTransform>().position = destination; } } else { button.transform.SetAsLastSibling(); paletteSelect.transform.SetAsFirstSibling(); } if (button.GetComponent <BaseButton>().GetName().Equals(draw.GetLayer())) { paletteSelect.position = button.GetComponent <RectTransform>().position; } i++; } }
void Update() { if (PlayManager.GetIsPlay() || !isSelected) { lineRenderer.enabled = false; for (int i = 0; i < nodes.Length; i++) { nodes[i].SetActive(false); } } else { lineRenderer.enabled = true; for (int i = 0; i < nodes.Length; i++) { nodes[i].SetActive(true); } } isSelected = gameObject.name.Equals(draw.GetLayer()); if (Input.GetMouseButtonDown(0) && isSelected) { mousePositionBuffer = MouseUtilities.WorldSpace(cam); } if (Input.GetMouseButton(0) && isSelected) { Vector3 positionChange = MouseUtilities.WorldSpace(cam) - mousePositionBuffer; for (int i = 0; i < nodes.Length; i++) { Vector3 normalizedPosition = new Vector3(nodes[i].transform.position.x, nodes[i].transform.position.y, 0); if ((Vector3.Distance(MouseUtilities.WorldSpace(cam), normalizedPosition) < 0.5f && currentlyDragged == -1) || currentlyDragged == i) { nodes[i].transform.position += positionChange; lineRenderer.SetPosition(i, nodes[i].transform.position + Vector3.forward); currentlyDragged = i; break; } } mousePositionBuffer = MouseUtilities.WorldSpace(cam); } if (Input.GetMouseButtonUp(0) && isSelected) { for (int i = 0; i < nodes.Length; i++) { Vector3 pos = nodes[i].transform.position; nodes[i].transform.position = new Vector3(Mathf.Round(pos.x), Mathf.Round(pos.y), pos.z); lineRenderer.SetPosition(i, nodes[i].transform.position + Vector3.forward); } currentlyDragged = -1; } }
void Update() { if (MouseUtilities.TouchingUI(rt) && Input.GetMouseButtonDown(0)) { startDragMouse = Input.mousePosition; startDragButton = parentRt.position; isDragged = true; moveLayerPreview.gameObject.SetActive(true); } if (Input.GetMouseButton(0) && isDragged) { posChange = (Vector2)Input.mousePosition - startDragMouse; parentRt.position = startDragButton + posChange; if (parentRt.position.x < contentRt.position.x + contentRt.rect.width / 2f - 10f) { parentRt.position = new Vector2(contentRt.position.x + contentRt.rect.width / 2f - 10f, parentRt.position.y); } else if (parentRt.position.x > contentRt.position.x + contentRt.rect.width / 2f + 10f) { parentRt.position = new Vector2(contentRt.position.x + contentRt.rect.width / 2f + 10f, parentRt.position.y); } if (parentRt.position.y < contentRt.position.y - 80.0f * nButtons - 5.0f) { parentRt.position = new Vector2(parentRt.position.x, contentRt.position.y - 80.0f * nButtons - 5.0f); } moveLayerPreview.position = new Vector3( contentRt.position.x - 25, contentRt.position.y - Mathf.Floor( (contentRt.position.y - parentRt.position.y - 10.0f) / 80.0f + 1.0f) * 80.0f, 0); } if (Input.GetMouseButtonUp(0) && isDragged) { action.Invoke(m_Name, draw.GetLayer(Mathf.Floor( (contentRt.position.y - parentRt.position.y - 10.0f) / 80.0f))); isDragged = false; moveLayerPreview.gameObject.SetActive(false); } }
void Update() { text.text = TextUtilities.UnderscoresToSpaces(draw.GetLayer()); }