private IEnumerator Flicker(CanvasRenderer objRenderer, float duration, float interval, bool endGame, bool reset) { float endTime = Time.unscaledTime + duration; while (Time.unscaledTime < endTime) { objRenderer.SetAlpha(0f); yield return new WaitForSeconds(interval); objRenderer.SetAlpha(1f); yield return new WaitForSeconds(interval); } objRenderer.SetAlpha(1); if (endGame) { if (reset) { gameMaster.Reset(); } else { gameMaster.LoadNextLvl(); } } }
private void ShowShadow() { if (ShadowRender.GetAlpha() < 0.5) { ShadowRender.SetAlpha(1); } }
// Called by the UI when surveyNameField or surveyEmailField is changed // Also called by CleanDataEntryUI() // Updates the infoContinueButton's interactable property based on surveyNameField and surveyEmailField public void UpdateDataEntryContinueButtonState() { bool isInteractable = !string.IsNullOrEmpty(surveyNameField.text) && !string.IsNullOrEmpty(surveyAgeField.text) && surveyEmailField.text.Contains("@") && surveyGenderField.value != 0 && surveyCleatField.value != 0 && surveyTermsAndConditionsToggle.isOn; /*Debug.Log("name " + !string.IsNullOrEmpty(surveyNameField.text)); * Debug.Log("age " + !string.IsNullOrEmpty(surveyAgeField.text)); * Debug.Log("email " + surveyEmailField.text.Contains("@")); * Debug.Log("gender " + (surveyGenderField.value != 0)); * Debug.Log("cleat " + (surveyCleatField.value != 0)); * Debug.Log("terms " + surveyTermsAndConditionsToggle.isOn);*/ infoContinueButton.interactable = isInteractable; if (isInteractable) { infoContinueButtonRend1.SetAlpha(1); infoContinueButtonRend2.SetAlpha(1); } else { infoContinueButtonRend1.SetAlpha(0.5f); infoContinueButtonRend2.SetAlpha(0.5f); } }
IEnumerator PlayLoader() { image.SetAlpha(0); //fade in logo Debug.Log("Fade in"); while (image.GetAlpha() != 1) { image.SetAlpha(Mathf.Min(1, image.GetAlpha() + fadeSpeed)); yield return(null); } //wait Debug.Log("Wait"); yield return(new WaitForSeconds(1.337f)); //fade out logo Debug.Log("Fade out"); while (image.GetAlpha() != 0) { image.SetAlpha(Mathf.Max(0, image.GetAlpha() - fadeSpeed)); yield return(null); } yield return(new WaitForSeconds(1.337f)); Levels.LoadMenu(); }
void getInfo(bool getInfo) { if (getInfo) { ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 1000.0f)) { if (planetName != null) { planetName.text = hit.collider.gameObject.name; } if (planetCanvas != null) { planetCanvas.SetAlpha(1.0f); } } } else { if (planetCanvas != null) { planetCanvas.SetAlpha(0.0f); } if (planetName != null) { planetName.text = ""; } } }
public void SetView(TotemData data, int lv = 1) { if (data == null) { Color c = item_img.color; c.a = 0; item_img.color = c; play_cr.SetAlpha(0); name_txt.text = string.Format("<color=#FFFF00>{0}级</color>", lv); level_txt.text = ""; return; } this.data = data; cr.SetAlpha(1); play_cr.SetAlpha(0); Color co = item_img.color; co.a = 1; item_img.color = co; item_img.sprite = ResourceMgr.Instance.LoadSprite(data.ItemData.icon); EventListener.Get(item_img.gameObject).OnClick = e => { UIFace.GetSingleton().Open(UIID.DivinationTip, data, SHOWBUTTON.EtakeOff); }; int rare = data.ItemData.rare; string color = ColorMgr.Colors[rare - 1]; name_txt.text = string.Format("<color=#{0}>Lv.{1}\n {2}</color>", color, data.Level, data.TotemConfig.Name); }
// Update is called once per frame void Update() { Cr.SetAlpha(0); if (!show) { return; } if (Per < 1.0f) { Per += 1.5f * Time.deltaTime; } if (Per > 1.0f) { Per = 1.0f; } Cr.SetAlpha(curve.Evaluate(Per)); Vector3 Scl = transform.localScale; Scl.x = ScaleBase.x + 1.0f - curve.Evaluate(Per); Scl.y = ScaleBase.y + 1.0f - curve.Evaluate(Per); transform.localScale = Scl; if (Sound && Per == 1.0f && !Snd) { Instantiate(Sound, transform.position, transform.rotation); Snd = true; } }
// flashes the object for a short time IEnumerator FlashCycle() { float timer = 0; // animates towards full opacity while (timer < _flashTime) { timer = BasicCounter.TowardsTarget(timer, _flashTime, 1f); _childRenderer.SetAlpha(timer / _flashTime); yield return(null); } // animates towards full transparency while (timer > 0) { timer = BasicCounter.TowardsTarget(timer, 0f, 1f); _childRenderer.SetAlpha(timer / _flashTime); yield return(null); } _flashRoutine = null; }
public void Placed() { item = null; //dragImage.color = new Color(dragImage.color.r, dragImage.color.g, dragImage.color.b, 0f); render.SetAlpha(0f); InventoryManager.instance.dragging = false; }
void Start() { Dbg.LogCheckAssigned(PressAnyKeys, this); Dbg.LogCheckAssigned(PressAnyKeysTransparent, this); PressAnyKeys.SetAlpha(1.0f); PressAnyKeysTransparent.SetAlpha(1.0f); }
void OnEnable() { currentAlpha = 0f; target.SetAlpha(currentAlpha); stepAlpha = targetAlpha / (fadeTime * 60f); InvokeRepeating("FadeGraphic", 0f, 0.01666f); }
private IEnumerator DisplayAndFadeMessage(float readTime, float fadeRate, float fadeDelay) { //https://answers.unity.com/questions/889908/i-created-an-ui-button-but-click-does-not-work.html parent.sortingOrder = tempSortingorder; //https://answers.unity.com/questions/881620/uigraphiccrossfadealpha-only-works-for-decrementin.html if (cv != null && cg != null) { cv.SetAlpha(1f); cg.alpha = 1f; yield return(new WaitForSeconds(readTime)); while (true) { float alpha = cv.GetAlpha(); if (alpha <= 0) { break; } float newAlpha = alpha - fadeRate; cv.SetAlpha(newAlpha); cg.alpha = newAlpha; yield return(new WaitForSeconds(fadeDelay)); } HideMessage(); } else { Debug.Log("Missing canvas renderer or canvas group"); } }
private void Update() { if (isFadingIn) { float newAlpha = canvasRenderer.GetAlpha() + fadeInSpeed * Time.deltaTime; if (newAlpha >= 1) { canvasRenderer.SetAlpha(1); isFadingIn = false; } else { canvasRenderer.SetAlpha(newAlpha); } } else { float newAlpha = canvasRenderer.GetAlpha() - fadeOutSpeed * Time.deltaTime; if (newAlpha <= 0) { canvasRenderer.SetAlpha(0); gameObject.SetActive(false); } else { canvasRenderer.SetAlpha(newAlpha); } } }
//フェードイン・アウト関数 CanvasRenderer インかアウト 何秒で obj専用のcurrentTime型 public static void FadeIO(CanvasRenderer obj, bool flag, float time, float currentTime) { //フェードイン if (flag) { if (obj.GetAlpha() < 1) { currentTime += Time.deltaTime; obj.SetAlpha(time / currentTime); //フェードが完了後、currentTimeを初期化 if (obj.GetAlpha() >= 1) { currentTime = 0; } } } //フェードアウト else { if (obj.GetAlpha() > 0) { currentTime += Time.deltaTime; obj.SetAlpha(1 - (time / currentTime)); //フェードが完了後、currentTimeを初期化 if (obj.GetAlpha() <= 0) { currentTime = 0; } } } }
public IEnumerator FadeIn() { float fadeAmount; if (m_canvasRenderer != null) { while (m_canvasRenderer.GetAlpha() < m_maxAlpha) { yield return(null); fadeAmount = m_canvasRenderer.GetAlpha() + Time.deltaTime / m_fadeSpeed; if (fadeAmount > 0.99f) { fadeAmount = maxAlpha; } m_canvasRenderer.SetAlpha(fadeAmount); } } m_canvasRenderer.SetAlpha(m_maxAlpha); if (m_continuous) { Start_FadeOut(); } }
private void Start() { GameObject system = GameObject.Find("System"); // get mc gameobject mainScript = system.GetComponent <main>(); // get the model controller script attached gazeBackground.SetAlpha(0f); // remove gaze background as default }
public void ProcessFlareAndFlashForDisrepair(bool playerIsAtStation) { if (!StationButtonInvertedImage) { return; } var delta = Time.frameCount - brokenTimeStamp; if (delta < 60) { StationButtonInvertedImage.enabled = (delta % 4) >= 2; // a(x + h)^2 + v // a = -0.00277 // h = -60 // v = 10 // x = delta flareRT.localScale = Vector2.one * (-0.00277f * ((delta - 60) * (delta - 60)) + 10f); flareCR.SetAlpha((60 - delta) / 150f); } else if (delta % 600 >= 540 && !playerIsAtStation && !hidden) { // Periodic reminder flash StationButtonInvertedImage.enabled = (delta % 4) >= 2; } else { StationButtonInvertedImage.enabled = true; flareCR.SetAlpha(0); } }
private void OnMovementPadMove(Vector2 dir, Vector2 delta) { moduleBordlands.moveMentKey = 0x00; if (dir.x < -MOVEPAD_THRESHOLD) { moduleBordlands.moveMentKey |= 0x02; } if (dir.x > MOVEPAD_THRESHOLD) { moduleBordlands.moveMentKey |= 0x08; } if (dir.y > MOVEPAD_THRESHOLD) { moduleBordlands.moveMentKey |= 0x01; } if (dir.y < -MOVEPAD_THRESHOLD) { moduleBordlands.moveMentKey |= 0x04; } if (m_lastMoveKey == moduleBordlands.moveMentKey) { return; } m_lastMoveKey = moduleBordlands.moveMentKey; if (moduleBordlands.moveMentKey != 0) { m_leftCR.SetAlpha(dir.x < -MOVEPAD_THRESHOLD ? 1 : 0.6f); m_rightCR.SetAlpha(dir.x > MOVEPAD_THRESHOLD ? 1 : 0.6f); m_upCR.SetAlpha(dir.y > MOVEPAD_THRESHOLD ? 1 : 0.6f); m_bottomCR.SetAlpha(dir.y < -MOVEPAD_THRESHOLD ? 1 : 0.6f); } }
/// <summary> /// Fade the alpha value over time /// </summary> /// <param name="tmp"></param> /// <param name="mb"></param> /// <param name="fromAlpha"></param> /// <param name="toAlpha"></param> /// <param name="seconds"></param> /// <param name="realtime"></param> /// <returns></returns> public static GmMonoBehaviourEventPromise FadeAlpha(this CanvasRenderer tmp, MonoBehaviour mb, float fromAlpha, float toAlpha, float seconds, bool realtime) { if (seconds == 0) { tmp.SetAlpha(toAlpha); var done = new GmMonoBehaviourEventPromise(); done.Done(); return(done); } float intervalSeconds = 0.1f; float step = 0; int fadeSteps = (int)Math.Ceiling(seconds / intervalSeconds); //Debug.Log("Fade Steps = " + fadeSteps); tmp.SetAlpha(fromAlpha); return(mb.Repeat(intervalSeconds, fadeSteps, () => { step++; float timePercent = Mathf.Clamp(step / fadeSteps, 0, 1); //Debug.Log("Fade % = " + timePercent); tmp.SetAlpha(Mathf.Lerp(fromAlpha, toAlpha, timePercent)); })); }
// Update is called once per frame void Update() { float compassOffset = 120f; Vector2 targetPositionScreenPoint = Camera.main.WorldToScreenPoint(target.position); bool isOffScreen = targetPositionScreenPoint.x <compassOffset || targetPositionScreenPoint.x> Screen.width - compassOffset || targetPositionScreenPoint.y <compassOffset || targetPositionScreenPoint.y> Screen.height - compassOffset; if (isOffScreen) { // Show the needle canvasRenderer.SetAlpha(255f); RotateTowardsTarget(); compass.position = originalPos; } else { // Hide the needle canvasRenderer.SetAlpha(0f); Vector3 pointerWorldPosition = uiCamera.ScreenToWorldPoint(targetPositionScreenPoint); compass.position = pointerWorldPosition; compass.localPosition = new Vector3(compass.localPosition.x, compass.localPosition.y, 0f); } }
private void OnMovementPadBegin(Vector2 dir) { if (!m_player) { return; } var s = 0; s = dir.x < 0 ? 1 : dir.x > 0 ? 2 : 0; //Logger.LogWarning(dir.ToXml()); InputManager.SetTouchState(TouchID.Movement, 0, s == 1 ? 1 << 1 : 1, false); InputManager.SetTouchState(TouchID.Movement, 1, s == 1 ? 1 : 1 << 1, false); if (m_lastMovement != s) { m_btnLeft.SetAlpha(s == 1 ? 1 : 0.6f); m_btnRight.SetAlpha(s == 2 ? 1 : 0.6f); m_lastMovement = s; } //Logger.LogError("i == {0}", iiii); }
void Start() { m_canvasRenderer = GetComponent <CanvasRenderer>(); m_startsVisible = StartVisible; if (m_canvasRenderer == null) { Debug.LogError("FadeCanvas: No CanvasRenderer found!"); return; } if (m_startsVisible) { m_canvasRenderer.SetAlpha(m_maxAlpha); if (m_fadeOnAwake) { Start_FadeOut(); } } else { m_canvasRenderer.SetAlpha(m_minAlpha); if (m_fadeOnAwake) { Start_FadeIn(); } } IsReady = true; }
void InventoryListener() { float inventoryY = inventoryUI.localPosition.y; float alphaVign = vignetteBottom.GetAlpha(); if (Input.GetButton("Inventory") && !isInventory && !isBlocked && inventory.items[0].ID != -1) { tempTargetRotation = targetRotation; isInventory = true; } else if (!Input.GetButton("Inventory") && isInventory && !inventory.isShowingInfo) { isInventory = false; } else if (Input.GetButtonDown("Inventory") && !isInventory && !isBlocked && inventory.items[0].ID == -1) { Debug.Log("Инвентарь пуст"); } if (Input.GetButton("Inventory") && isInventory && inventory.items[0].ID == -1) { Debug.Log("Инвентарь пуст"); isInventory = false; } if (isInventory) { inventoryY += -(Mathf.Pow(inventoryY + 226, 2) - 2800) * 0.003f; inventoryY = Mathf.Clamp(inventoryY, -277, -175); inventoryUI.localPosition = new Vector2(inventoryUI.localPosition.x, inventoryY); if (alphaVign >= 1) { alphaVign = 1; } else { alphaVign += -(Mathf.Pow(alphaVign - 0.5f, 2) - 0.25f) * 0.03f + 0.02f; } vignetteBottom.SetAlpha(alphaVign); inventory.quickItemInfo.transform.GetComponent <RectTransform>().localPosition = new Vector2(inventory.quickItemInfo.transform.GetComponent <RectTransform>().localPosition.x, -480 - inventoryY); } else if (!isInventory) { inventoryY -= -(Mathf.Pow(inventoryY + 226, 2) - 2800) * 0.003f; inventoryY = Mathf.Clamp(inventoryY, -277, -175); inventoryUI.localPosition = new Vector2(inventoryUI.localPosition.x, inventoryY); if (alphaVign <= 0) { alphaVign = 0; } else { alphaVign -= -(Mathf.Pow(alphaVign - 0.5f, 2) - 0.25f) * 0.03f + 0.02f; } vignetteBottom.SetAlpha(alphaVign); inventory.quickItemInfo.transform.GetComponent <RectTransform>().localPosition = new Vector2(inventory.quickItemInfo.transform.GetComponent <RectTransform>().localPosition.x, -480 - inventoryY); } }
public void Show(float delay = 0f) { gameObject.SetActive(true); grp.alpha = 0f; canvasRender.SetAlpha(1); DOTween.Kill(grp); grp.DOFade(1f, 0.05f).SetLoops(3, LoopType.Yoyo).SetDelay(delay).OnComplete(StartGlitch); }
public void ShowTooltip(UnitStatus _stats) { myCanvasRenderer.SetAlpha(1); tooltipText.text = "HP: " + _stats.hitPoints + "\n" + "Atk: " + _stats.attack + "\n" + "M.Atk: " + _stats.mAttack + "\n" + "Armor: " + _stats.armor + "\n" + "M.Armor: " + _stats.mArmor + "\n" + "Speed: " + _stats.attack; }
// Update is called once per frame public void DisplayError(string DisplayText) { textfield.text = DisplayText; textfield.fontSize = 100; textfield.color = Color.red; Drawer.SetAlpha(1); if (!isRunning) { StartCoroutine("Blink"); } }
// Update is called once per frame void Update() { if (canvas.GetAlpha() > 0.0f) { timeSinceNotification += Time.deltaTime; if (timeSinceNotification >= stayingTime) { canvas.SetAlpha(1.0f - ((timeSinceNotification - stayingTime) / fadingTime)); } } }
private void Fade(CanvasRenderer canvasRenderer, FadeType fadeType, float fadeSpeed) { if (fadeType == FadeType.FadeIn && canvasRenderer.GetAlpha() != 1f) { canvasRenderer.SetAlpha(Mathf.Lerp(canvasRenderer.GetAlpha(), 1f, Time.deltaTime * fadeSpeed)); } else if (fadeType == FadeType.FadeOut && canvasRenderer.GetAlpha() != 0f) { canvasRenderer.SetAlpha(Mathf.Lerp(canvasRenderer.GetAlpha(), 0f, Time.deltaTime * fadeSpeed)); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Escape) || Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2) || Manager_ControllerInputManager.p1Controller.A_Button_Pressed || Manager_ControllerInputManager.p1Controller.Start_Button_Pressed || Manager_ControllerInputManager.p2Controller.A_Button_Pressed || Manager_ControllerInputManager.p2Controller.Start_Button_Pressed || Manager_ControllerInputManager.p3Controller.A_Button_Pressed || Manager_ControllerInputManager.p3Controller.Start_Button_Pressed || Manager_ControllerInputManager.p4Controller.A_Button_Pressed || Manager_ControllerInputManager.p4Controller.Start_Button_Pressed || Manager_ControllerInputManager.p5Controller.A_Button_Pressed || Manager_ControllerInputManager.p5Controller.Start_Button_Pressed || Manager_ControllerInputManager.p6Controller.A_Button_Pressed || Manager_ControllerInputManager.p6Controller.Start_Button_Pressed || Manager_ControllerInputManager.p7Controller.A_Button_Pressed || Manager_ControllerInputManager.p7Controller.Start_Button_Pressed || Manager_ControllerInputManager.p8Controller.A_Button_Pressed || Manager_ControllerInputManager.p8Controller.Start_Button_Pressed) { IsSkipping = true; } //If there's still time left to fade in, fades in if (FadeInTime > 0 && IsSkipping == false) { FadeInTime -= Time.deltaTime; MyInterp.AddTime(Time.deltaTime); //Changes the alpha of this image to fade in based on the amount of time passed ThisCanvas.SetAlpha(MyInterp.GetProgress()); } //If fading in is finished, stays on screen else if (OnScreenTime > 0 && IsSkipping == false) { OnScreenTime -= Time.deltaTime; //Once it's finished staying on screen regularly, sets the interpolater to the fade out time if (OnScreenTime <= 0) { MyInterp.SetDuration(FadeOutTime); MyInterp.AddTime(FadeOutTime); } } //If it's done staying on screen normally, fades out else if (FadeOutTime > 0) { FadeOutTime -= Time.deltaTime; MyInterp.AddTime(-Time.deltaTime); //Changes the alpha of this image to fade out based on the amount of time passed ThisCanvas.SetAlpha(MyInterp.GetProgress()); //Once it's finished fading out, activates the on finish event if (FadeOutTime <= 0) { EventOnFinish.Invoke(); } } }
IEnumerator FadeIn() { _canvasRenderer.SetAlpha(1); _fadeRawImage.gameObject.SetActive(true); _fadeRawImage.CrossFadeAlpha(0, FadeTime, false); yield return(new WaitForSeconds(FadeTime)); _fadeRawImage.gameObject.SetActive(false); }