private void RevealCircularFade() { for (int i = 0; i < buttons.Count; i++) { // find angle float angleDist = circSpawner.angle.maxAngle - circSpawner.angle.minAngle; float targetAngle = circSpawner.angle.minAngle + (angleDist / buttons.Count) * i; //find position Vector3 targetPos = transform.position + Vector3.right * circSpawner.distanceFromBrancher; targetPos = RotatePointAroundTarget(targetPos, transform.position, targetAngle); RectTransform buttonRect = buttons[i].GetComponent <RectTransform>(); //resize button buttonRect.sizeDelta = new Vector2(buttonScaler.newButtonSize.x, buttonScaler.newButtonSize.y); ButtonFader previousButtonFader; if (i > 0) { previousButtonFader = buttons[i - 1].GetComponent <ButtonFader>(); } else { previousButtonFader = null; } ButtonFader buttonFader = buttons[i].GetComponent <ButtonFader>(); if (previousButtonFader) // first button wont have a previous button { if (previousButtonFader.faded) { buttons[i].transform.position = targetPos; if (buttonFader) { buttonFader.Fade(buttonSettings.fadeSmooth); } else { Debug.LogError(" You want to fade buttons, but they need a buttonfader script on them 1"); } } } else { buttons[i].transform.position = targetPos; if (buttonFader) { buttonFader.Fade(buttonSettings.fadeSmooth); } else { Debug.LogError(" You want to fade buttons, but they need a buttonfader script on them 2"); } } } }
private void RevealLinearlyFade() { for (int i = 0; i < buttons.Count; i++) { Vector3 targetPos; //Give the button a position to move towards RectTransform buttonRect = buttons[i].GetComponent <RectTransform>(); //set size buttonRect.sizeDelta = new Vector2(buttonScaler.newButtonSize.x, buttonScaler.newButtonSize.y); //set pos targetPos.x = linSpawner.direction.x * ((i + linSpawner.buttonNumOffset) * (buttonRect.sizeDelta.x + linSpawner.buttonSpacing)) + transform.position.x; targetPos.y = linSpawner.direction.y * ((i + linSpawner.buttonNumOffset) * (buttonRect.sizeDelta.y + linSpawner.buttonSpacing)) + transform.position.y; targetPos.z = 0; ButtonFader previousButtonFader; if (i > 0) { previousButtonFader = buttons[i - 1].GetComponent <ButtonFader>(); } else { previousButtonFader = null; } ButtonFader buttonFader = buttons[i].GetComponent <ButtonFader>(); if (previousButtonFader) // first button wont have a previous button { if (previousButtonFader.faded) { buttons[i].transform.position = targetPos; if (buttonFader) { buttonFader.Fade(buttonSettings.fadeSmooth); } else { Debug.LogError(" You want to fade buttons, but they need a buttonfader script on them 1"); } } } else { buttons[i].transform.position = targetPos; if (buttonFader) { buttonFader.Fade(buttonSettings.fadeSmooth); } else { Debug.LogError(" You want to fade buttons, but they need a buttonfader script on them 2"); } } } }
void RevealLinearlyFade() { for (int i = 0; i < buttonRefs.Length; i++) { Vector3 targetPos; //position for button to move toward RectTransform buttonRect = buttons[i].GetComponent <RectTransform>(); //set size buttonRect.sizeDelta = new Vector2(buttonScale.newButtonSize.x, buttonScale.newButtonSize.y); //width of the button //set pos targetPos.x = linSpawner.direction.x * ((i + linSpawner.NumOffset) * (buttonRect.sizeDelta.x + linSpawner.baseSpacing)) + transform.position.x; targetPos.y = linSpawner.direction.y * ((i + linSpawner.NumOffset) * (buttonRect.sizeDelta.y + linSpawner.baseSpacing)) + transform.position.y; targetPos.z = 0; ButtonFader previousButtonFader; if (i > 0) { previousButtonFader = buttons[i - 1].GetComponent <ButtonFader>(); //To prevent the next button from fading if the previous button hasn't finieshed fading yet } else { previousButtonFader = null; //First button in the list } ButtonFader buttonFader = buttons[i].GetComponent <ButtonFader>(); if (previousButtonFader) { if (previousButtonFader.faded) //When the previous button is done fading { buttons[i].transform.position = targetPos; if (buttonFader) { buttonFader.Fade(revealSettings.fadeSpeed); } else { Debug.LogError("You forgot to set a ButtonFader to button number " + i); } } } else { buttons[i].transform.position = targetPos; if (buttonFader) { buttonFader.Fade(revealSettings.fadeSpeed); } else { Debug.LogError("You forgot to set a ButtonFader to button number " + i); } } } }
void RevealCircularFade() { for (int i = 0; i < buttons.Count; i++) { float angleDist = circSpawner.angle.maxAngle - circSpawner.angle.minAngle; float targetAngle = circSpawner.angle.minAngle + (angleDist / buttons.Count) * i; //finds the angle to put the button Vector3 targetPos = transform.position + Vector3.right * circSpawner.distFromBrancher; //find position, start from right of spawner targetPos = RotatePointAroundPivot(targetPos, transform.position, targetAngle); RectTransform buttonRect = buttons[i].GetComponent <RectTransform>(); buttonRect.sizeDelta = new Vector2(buttonScale.newButtonSize.x, buttonScale.newButtonSize.y); //resize button ButtonFader previousButtonFader; if (i > 0) { previousButtonFader = buttons[i - 1].GetComponent <ButtonFader>(); //To prevent the next button from fading if the previous button hasn't finieshed fading yet } else { previousButtonFader = null; //First button in the list } ButtonFader buttonFader = buttons[i].GetComponent <ButtonFader>(); if (previousButtonFader) { if (previousButtonFader.faded) //When the previous button is done fading { buttons[i].transform.position = targetPos; if (buttonFader) { buttonFader.Fade(revealSettings.fadeSpeed); } else { Debug.LogError("You forgot to set a ButtonFader to button number " + i); } } } else { buttons[i].transform.position = targetPos; if (buttonFader) { buttonFader.Fade(revealSettings.fadeSpeed); } else { Debug.LogError("You forgot to set a ButtonFader to button number " + i); } } } }