// draw the texture and perform the fade: private void OnGUI() { // if the current color of the screen is not equal to the desired color: keep fading! if (m_CurrentScreenOverlayColor != m_TargetScreenOverlayColor) { // if the difference between the current alpha and the desired alpha is smaller than delta-alpha * deltaTime, then we're pretty much done fading: if (Mathf.Abs(m_CurrentScreenOverlayColor.a - m_TargetScreenOverlayColor.a) < Mathf.Abs(m_DeltaColor.a) * Time.deltaTime) { m_CurrentScreenOverlayColor = m_TargetScreenOverlayColor; SetScreenOverlayColor(m_CurrentScreenOverlayColor); m_DeltaColor = new Color(0, 0, 0, 0); fadeCallback(); fadeCallback = null; } else { // fade! SetScreenOverlayColor(m_CurrentScreenOverlayColor + m_DeltaColor * Time.deltaTime); } } else if (fadeCallback != null) { fadeCallback(); fadeCallback = null; } // only draw the texture when the alpha value is greater than 0: if (m_CurrentScreenOverlayColor.a > 0) { GUI.depth = m_FadeGUIDepth; GUI.Label(new Rect(-10, -10, Screen.width + 10, Screen.height + 10), m_FadeTexture, m_BackgroundStyle); } }
protected void Awake() { if (interactions.Length == 0) { useDelegate = DefaultUse; breakDelegate = DefaultBreak; } else { IUseInteraction u; IBreakInteraction b; foreach (MonoBehaviour interaction in interactions) { if (interaction is IUseInteraction) { u = (IUseInteraction)interaction; useDelegate += u.Use; } if (interaction is IBreakInteraction) { b = (IBreakInteraction)interaction; breakDelegate += b.Break; } } } }
public TResponse MakeRequest(TRequest request, UseDelegate codeBlock) { TResponse response = new TResponse(); response = codeBlock(); return(response); }
public void stopLerp() { activeLerp = false; stopMoving(); finishedAction = true; goToCallback = null; movementExecuted = true; }
public void deactivateLerp() { activeLerp = false; stopMoving(); finishedAction = true; if (goToCallback != null) { goToCallback(); goToCallback = null; movementExecuted = true; } }
// initiate a fade from the current screen color (set using "SetScreenOverlayColor") towards "newScreenOverlayColor" taking "fadeDuration" seconds public void StartFade(Color newScreenOverlayColor, float fadeDuration, UseDelegate callback) { if (fadeDuration <= 0.0f) // can't have a fade last -2455.05 seconds! { SetScreenOverlayColor(newScreenOverlayColor); } else // initiate the fade: set the target-color and the delta-color { m_TargetScreenOverlayColor = newScreenOverlayColor; m_DeltaColor = (m_TargetScreenOverlayColor - m_CurrentScreenOverlayColor) / fadeDuration; } fadeCallback = null; fadeCallback += callback; }
/// /// führt Lerp aus, wenn gerade ein Lerp aktiv ist (activeLerp == true) /// Wird dauerhaft von FixedUpdate aufgerufen /// private void doLerp() { if (activeLerp) { float distCovered = (Time.time - lerpStartTime) * moveSpeed; // schon absolvierte Distanz float fracJourney = distCovered / lerpLength; // Fortschritt des Lerp von 0 bis 1 transform.position = Vector3.Lerp(lerpFrom, lerpTo, fracJourney); // setze Position neu mittels Lerp // Deaktiviere Lerp, wenn Startpos = endpos if (transform.position.x == lerpTo.x && transform.position.y == lerpTo.y && transform.position.z == lerpTo.z) { activeLerp = false; currentlyMoving = false; stopMoving(); finishedAction = true; if (goToCallback != null) { goToCallback(); goToCallback = null; movementExecuted = true; } } } }
public UseAction(string description, UseDelegate use) { Description = description; Use = use; }
public void goToObject(GameObject o, UseDelegate callback) { goToX(o.transform.position.x); goToCallback += callback; }