public void StartWipe(Texture wipein, Texture wipeout, EmptyVoidCallback callbackmid, EmptyVoidCallback callbackend, float speedin, float speedout) { this.wipein = wipein; this.wipeout = wipeout; cbmid = callbackmid; cbend = callbackend; currstate = WipeState.wipein; this.speedin = speedin; this.speedout = speedout; }
public void StartWipe(EmptyVoidCallback callbackmid, EmptyVoidCallback callbackend) { this.wipein = Resources.Load <Texture>("Textures/screenwipeintex"); this.wipeout = Resources.Load <Texture>("Textures/screenwipeouttex"); cbmid = callbackmid; cbend = callbackend; currstate = WipeState.wipein; this.speedin = 3.0f; this.speedout = 3.0f; }
private IEnumerator WipeOpenRoutine(float delay) { var startTime = Time.time; // Initialize SetWipeStep(1.0f); // start delay if (delay > 0.0f) { yield return(new WaitForSeconds(delay)); // Resign start time startTime = Time.time; } // Start currentState = WipeState.Opening; OnWipeResume.Invoke(); float timePast; float t; do { yield return(null); timePast = Time.time - startTime; t = 1.0f + timePast / WipeDuration; SetWipeStep(Mathf.Min(2.0f, t)); } while(timePast < WipeDuration); SetWipeStep(2.0f); yield return(null); currentState = WipeState.Opened; OnWipeOpened.Invoke(); wipeCanvasObject.SetActive(false); wipeCanvasObject.SetActive(false); currentCoroutine = null; }
// Update is called once per frame void Update() { if (currstate == WipeState.wipein) { material.SetTexture("_TransitionTex", wipein); cutoff += (Time.deltaTime * speedin); if (cutoff >= 1.0f) { cutoff = 1.0f; currstate = WipeState.wait; cbmid?.Invoke(); cbmid = null; } } else if (currstate == WipeState.wait) { timer += Time.deltaTime; if (timer >= timerVal) { currstate = WipeState.wipeout; timer = 0.0f; } } else if (currstate == WipeState.wipeout) { material.SetTexture("_TransitionTex", wipeout); cutoff -= (Time.deltaTime * speedout); if (cutoff <= 0.0f) { cutoff = 0.0f; currstate = WipeState.dead; cbend?.Invoke(); cbend = null; } } material.SetFloat("_Cutoff", cutoff); }
// private IEnumerator WipeCloseRoutine(float delay) { var startTime = Time.time; int wipeid = sysrand.Next(WipePatterns.Length); for (int i = 0; i < WipePatterns.Length; i++) { var wp = WipePatterns[i]; if (i == wipeid) { wipeMaterial.SetVector(wipeMatProps.wipeOffsetId, wp.offset); wipeMaterial.SetFloat(wipeMatProps.patternUnitId, wp.unit); wipeMaterial.EnableKeyword(wp.keyword); } else { if (wipeMaterial.IsKeywordEnabled(wp.keyword)) { wipeMaterial.DisableKeyword(wp.keyword); } } } int dirid = sysrand.Next(WipeDirKeyWords.Length); for (int i = 0; i < WipeDirKeyWords.Length; i++) { if (i == dirid) { wipeMaterial.EnableKeyword(WipeDirKeyWords[i]); } else { wipeMaterial.DisableKeyword(WipeDirKeyWords[i]); } } // Initialize wipeCanvasObject.SetActive(true); SetWipeStep(0.0f); // start delay if (delay > 0.0f) { yield return(new WaitForSeconds(delay)); // Resign start time startTime = Time.time; } // Start currentState = WipeState.Closing; OnWipeStart.Invoke(); float timePast; float t; do { yield return(null); timePast = Time.time - startTime; t = timePast / WipeDuration; SetWipeStep(Mathf.Min(1.0f, t)); } while(timePast < WipeDuration); SetWipeStep(1.0f); yield return(null); currentState = WipeState.Closed; OnWipeClosed.Invoke(); currentCoroutine = null; }