您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

37 行
1.1 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NumberDisplayManager : MonoBehaviour
{
[Header("Object Pool of Numbers")]
public ObjectPoolBehaviour objectPool;
[Header("Position Random Offset")]
public Vector3 positionRandomOffsetRange;
public void ShowNumber(int numberAmount, Transform numberTransform, Color numberColor)
{
GameObject numberObject = objectPool.GetPooledObject();
Vector3 newPosition = numberTransform.position + RandomOffsetRange(positionRandomOffsetRange);
numberObject.GetComponent<NumberDisplayBehaviour>().SetupDisplay(numberAmount, newPosition, numberColor);
numberObject.SetActive(true);
}
Vector3 RandomOffsetRange(Vector3 rangeVectors)
{
return new Vector3( RandomInRange(rangeVectors.x),
RandomInRange(rangeVectors.y),
RandomInRange(rangeVectors.x)
);
}
float RandomInRange(float rangeValue)
{
return Random.Range(-rangeValue, rangeValue);
}
}