public void ChangeSelectedPart(RingElementSelector newSelectedPart) { if (selectedElement != null) { selectedElement.SetElementSelection(false); } selectedElement = newSelectedPart; //bg.SetDestination(ringElements[(int)selectedElement].position); }
void Update() { if (ringManager.selectedElement != selectedElement) { selectedElement = ringManager.selectedElement; Vector3 center = ringManager.selectedElement.transform.position; center.z = 0; destination = origin + (center.normalized * circle_radius); } transform.position = Vector3.Lerp(transform.position, destination, Time.deltaTime * movementSpeed); }
//MoveBackground bg; void Awake() { ringElements = new Dictionary <int, Transform>(); int childCnt = transform.childCount; for (int i = 0; i < childCnt - 2; i++) { Transform childX = transform.GetChild(i); ringElements.Add(i, childX.transform); } selectedElement = null; //bg = GameObject.FindGameObjectWithTag("Background").GetComponent(typeof(MoveBackground)) as MoveBackground; }
private void Awake() { ringManager = transform.parent.GetComponentInChildren(typeof(RingManager)) as RingManager; origin = destination = ringManager.gameObject.transform.position; selectedElement = ringManager.selectedElement; }