public IEnumerator Direct(BatchNode tran, Vector3 newPosition, bool inScreen, bool destroy = false, float speed = 1, float delay = 0) { Debug.Log("Direct"); yield return(new WaitForSecondsRealtime(delay)); tran.SetPosition(newPosition, inScreen); if (destroy) { DestroyTran(tran); } }
/// <summary> /// The 5th transfer method. RadialBlur fade-out. Should apply to background. /// </summary> /// <param name="tran"></param> /// <param name="newPosition"></param> /// <param name="inScreen"></param> /// <param name="destroy"> Redundant. Tran will be destroyed anyway.</param> /// <param name="speed"></param> /// <param name="delay"></param> /// <returns></returns> public IEnumerator RadialBlur(BatchNode tran, Vector3 newPosition, bool inScreen, bool destroy = true, float speed = 1, float delay = 0) { Debug.Log("RadialBlur"); yield return(new WaitForSecondsRealtime(delay)); Background b = tran.GetComponentInChildren <Background>(); if (b != null) { // MODIFYING //b.gameObject.GetComponent<Renderer>().material = Renderer rend = b.gameObject.GetComponentInChildren <Renderer>(); MaterialPropertyBlock matBlock = new MaterialPropertyBlock(); matBlock.Clear(); matBlock.SetTexture("tDiffuse", rend.material.mainTexture); rend.material = Instantiate(Resources.Load <Material>("Material/0")); //rend.SetPropertyBlock(matBlock); //matBlock.Clear(); if (speed <= 0) { speed = 1; } float alpha = 1; float density = 0; float alphaStep = -1 * speed; float densityStep = 2 * speed; while (alpha > 0) { alpha += alphaStep * Time.deltaTime; density += densityStep * Time.deltaTime; matBlock.SetFloat("_alpha", alpha); matBlock.SetFloat("fDensity", density); rend.SetPropertyBlock(matBlock); yield return(new WaitForEndOfFrame()); } DestroyTran(tran); } else { tran.SetPosition(newPosition, inScreen); DestroyTran(tran); } }
public IEnumerator Direct(BatchNode tran, Vector3 newPosition, bool inScreen, bool destroy = false, float speed = 1, float delay = 0) { Debug.Log("Direct"); yield return(new WaitForSecondsRealtime(delay)); tran.SetPosition(newPosition, inScreen); if (destroy) { Scene theScene = tran.transform.parent.gameObject.GetComponent <Scene>(); if (theScene == null) { Debug.LogError("TransitionForm.cs Average: parent doesn't have Scene component"); } else { theScene.RemoveSceneBatch(tran.name); theScene.DestroyOnEmpty(); } } }
/// <summary> /// The 4th transfer method. Cinematic Parallax fade-in. Should apply to background. Resources/Timelines/1. /// </summary> /// <param name="tran"> For background BatchNode only. There should be only 1 background under this BatchNode.</param> /// <param name="newPosition"> The position you want the background to be finally be.</param> /// <param name="inScreen"> Whether newPosition is in screen space or world space.</param> /// <param name="destroy"> Redundant parameter. Tran will not be destroyed anyway.</param> /// <param name="speed"> Redundant for now.</param> /// <param name="delay"> Wait for seconds before performing the fade-in.</param> /// <returns></returns> public IEnumerator Layers(BatchNode tran, Vector3 newPosition, bool inScreen, bool destroy = false, float speed = 1, float delay = 0) { int index = 1; // this means the transition uses Resources/Timelines/1 int i; Debug.Log("Layers"); yield return(new WaitForSecondsRealtime(delay)); Background b = tran.gameObject.GetComponentInChildren <Background>(); if (b != null) { GameObject _original = b.gameObject; GameObject _base = Instantiate(_original, tran.transform); if (_base.GetComponent <Animator>() == null) { _base.AddComponent <Animator>(); } GameObject _shadow = Instantiate(_base, tran.transform), _tone = Instantiate(_base, tran.transform), _highlight = Instantiate(_base, tran.transform), _highlight1 = Instantiate(_base, tran.transform), _transparent = Instantiate(_base, tran.transform); GameObject[] trackObjects = new GameObject[7]; _base.transform.localScale = new Vector3(32.5f, 19, 1); if (_base.GetComponent <Animator>() == null) { _base.AddComponent <Animator>(); } trackObjects[0] = _original; trackObjects[1] = _base; trackObjects[2] = _highlight1; trackObjects[3] = _highlight; trackObjects[4] = _shadow; trackObjects[5] = _tone; trackObjects[6] = _transparent; for (i = 0; i < 7; i++) { trackObjects[i].GetComponent <Renderer>().material = Resources.Load <Material>("Timelines/" + index.ToString() + "_" + (i).ToString()); } tran.SetPosition(newPosition, inScreen); _original.transform.position = newPosition; _original.active = false; PlayableDirector director = tran.gameObject.GetComponent <PlayableDirector>(); if (director == null) { director = tran.gameObject.AddComponent <PlayableDirector>(); } director.playableAsset = Instantiate(Resources.Load("Timelines/" + index.ToString()) as PlayableAsset); director.playOnAwake = false; director.extrapolationMode = DirectorWrapMode.Hold; i = 0; foreach (var tr in director.playableAsset.outputs) { director.SetGenericBinding(tr.sourceObject, trackObjects[i + 1]); i++; } director.Play(); yield return(new WaitForSecondsRealtime(3.4f)); AfterLayers(tran, trackObjects); } else { tran.SetPosition(newPosition, inScreen); } }