protected override void DoPrepare() { duration = 0; columns = Mathf.FloorToInt(Screen.width / SMTransitionUtils.ToAbsoluteSize(preferredTileSize.x, Screen.width)); rows = Mathf.FloorToInt(Screen.height / SMTransitionUtils.ToAbsoluteSize(preferredTileSize.y, Screen.height)); actualTileSize = new Vector2(1f / columns, 1f / rows); tiles = new List <Tile>(columns * rows); for (int x = 0; x < columns; x++) { float startTime = 0; for (int y = 0; y < rows; y++) { startTime += UnityEngine.Random.Range(minDelayBetweenTiles, maxDelayBetweenTiles); float offset = state == SMTransitionState.In ? 1 : 0; if (mode == Mode.AnimateBackground) { offset = 1 - offset; } tiles.Add(new Tile(x, y, new Vector2(x * actualTileSize.x, y * actualTileSize.y + offset), startTime)); duration = Mathf.Max(duration, startTime); } } duration += tileFallTime; }
protected override void Prepare() { int preferredHeightInPixel = SMTransitionUtils.ToAbsoluteSize(preferredBlindsHeight, Screen.height); numberOfBlinds = Mathf.FloorToInt(Screen.height / preferredHeightInPixel); actualBlindsHeight = (float)Screen.height / (float)numberOfBlinds; blindsStartOffset = (duration - blindsFlipTime) / (float)numberOfBlinds; }
protected override void Prepare() { if (tintMaterial == null) { tintMaterial = new Material(Shader.Find("Scene Manager/Cinema Effect")); } duration = fadeOutStartOffset + fadeOutDuration; float borderSizeInPixel = SMTransitionUtils.ToAbsoluteSize(borderSize, Screen.height); actualBorderSize = borderSizeInPixel / Screen.height; }
protected override void Prepare() { if (material == null) { material = new Material(Shader.Find("Scene Manager/Cartoon Effect")); material.SetTexture("_Background", holdMaterial.mainTexture); } Vector2 pixelCenter = new Vector2(SMTransitionUtils.ToAbsoluteSize(center.x, Screen.width), SMTransitionUtils.ToAbsoluteSize(center.y, Screen.height)); Vector2 bottomLeftPath = pixelCenter - new Vector2(0, 0); Vector2 topLeftPath = pixelCenter - new Vector2(0, Screen.height); Vector2 topRightPath = pixelCenter - new Vector2(Screen.width, Screen.height); Vector2 bottomRightPath = pixelCenter - new Vector2(Screen.width, 0); length = Mathf.Max(bottomLeftPath.magnitude, topLeftPath.magnitude, topRightPath.magnitude, bottomRightPath.magnitude); material.SetFloat("_CenterX", pixelCenter.x); material.SetFloat("_CenterY", pixelCenter.y); material.SetColor("_BorderColor", borderColor); }
protected override void DoPrepare() { shaderMaterial.SetTexture("_Backface", holdMaterial.mainTexture); if (backgroundTexture) { backgroundMaterial.mainTexture = backgroundTexture; } topLeft = gameObject.GetComponent <Camera>().ScreenToWorldPoint(new Vector3(0, Screen.height, distance)); bottomRight = gameObject.GetComponent <Camera>().ScreenToWorldPoint(new Vector3(Screen.width, 0, distance)); width = bottomRight.x - topLeft.x; height = topLeft.y - bottomRight.y; columns = Mathf.FloorToInt(Screen.width / SMTransitionUtils.ToAbsoluteSize(preferredTileSize.x, Screen.width)); rows = Mathf.FloorToInt(Screen.height / SMTransitionUtils.ToAbsoluteSize(preferredTileSize.y, Screen.height)); // recalculate size to avoid clipped tiles actualTileSize = new Vector2(width / columns, height / rows); tileStartOffset = (duration - tilesFlipTime) / (columns + rows); tileVertices = new Vector3[rows * columns * 4]; // 4 vertices per tile transformedVertices = new Vector3[rows * columns * 4]; // 4 transformed vertices per tile. uvSet1 = new Vector2[rows * columns * 4]; // 4 uv coords per tile (1 per vertex) uvSet2 = new Vector2[rows * columns * 4]; // 4 uv coords per tile (1 per vertex) for (int x = 0; x < columns; x++) { for (int y = 0; y < rows; y++) { CalculateStaticTileData(x, y); } } }