本文整理汇总了C#中SpriteRenderer.FitToBounds方法的典型用法代码示例。如果您正苦于以下问题:C# SpriteRenderer.FitToBounds方法的具体用法?C# SpriteRenderer.FitToBounds怎么用?C# SpriteRenderer.FitToBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpriteRenderer
的用法示例。
在下文中一共展示了SpriteRenderer.FitToBounds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NextLevel
private IEnumerator NextLevel()
{
Camera cam = Camera.main;
eventSystem.gameObject.SetActive(false);
_isTransitioning = true;
// makes next background.
_nextBackground = MakeSpriteRenderer(backgrounds.RandomOrDefault(), -2);
Bounds b = cam.GetOrthographicBounds();
_nextBackground.FitToBounds(new Bounds(
b.center + new Vector3(Random.Range(1f, 4f), Random.Range(1f, 4f), 0f),
b.size * Random.Range(2f, 3f)),
Space.World, true);
// makes new foreground objects.
int cnt = Random.Range(2, 4);
_foregroundObjects = new List<SpriteRenderer>();
for (int i = 0; i < cnt; i++)
{
StartCoroutine(SpawnAndAddForegroundObject(i, b));
}
// zooms out current background to be a new foreground object.
if (_currentBackground != null)
{
StartCoroutine(ScaleAndAddToForegroundObject(_currentBackground));
}
// The next background becomes new background.
_currentBackground = _nextBackground;
_nextBackground.sortingOrder = -1;
StartCoroutine(_currentBackground.transform.ScaleFrom(_currentBackground.transform.localScale * 1.5f, 1f, Ease.QuadOut));
// music change
musicMixer.requestNextLevel();
soundMixer.playZoomSound();
yield return new WaitForSeconds(1f);
_isTransitioning = false;
eventSystem.gameObject.SetActive(true);
}