本文整理汇总了C#中UnityEngine.WaitForSeconds类的典型用法代码示例。如果您正苦于以下问题:C# WaitForSeconds类的具体用法?C# WaitForSeconds怎么用?C# WaitForSeconds使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WaitForSeconds类属于UnityEngine命名空间,在下文中一共展示了WaitForSeconds类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public IEnumerator Start()
{
pool = new InventoryPool<InventoryUIItemWrapper>(wrapperPrefab, 8);
queue = new Queue<ItemHolder>(8);
destroyTimer = new WaitForSeconds(slideAnimation.length - 0.025f);
offsetTimer = new WaitForSeconds(offsetTimerSeconds);
foreach (var inv in InventoryManager.GetLootToCollections())
{
inv.OnAddedItem += (items, amount, cameFromCollection) =>
{
if (cameFromCollection == false)
{
queue.Enqueue(new ItemHolder() { item = items.FirstOrDefault(), stackSize = amount});
}
};
}
while (true)
{
if (queue.Count > 0)
{
ShowItem(queue.Peek().item, queue.Peek().stackSize);
queue.Dequeue(); // Remove it
}
yield return offsetTimer;
}
}
示例2: Loop
/// <summary>
/// Loop the specified action periodically by the interval.
/// </summary>
/// <param name="action">Action.</param>
/// <param name="interval">Interval.</param>
IEnumerator Loop(Action action,float interval){
WaitForSeconds waitForSeconds = new WaitForSeconds (interval);
while (true) {
action ();
yield return waitForSeconds;//new WaitForSeconds (interval);
}
}
示例3: Start
void Start()
{
delay = new WaitForSeconds(blinkSpeed);
text = GetComponent<Text>();
canvasGroup = GetComponent<CanvasGroup>();
StartCoroutine(Blink());
}
示例4: runTest
private IEnumerator runTest()
{
var waiter = new WaitForSeconds( 1.0f );
var targetPoint = Vector3.zero;
var goKitLite = GoKitLite.instance;
while( true )
{
for( var i = 0; i < _cubes.Length; i++ )
{
_timeX = _updateDelta * 0.15f;
_timeY = _updateDelta * 0.3f;
_timeZ = _updateDelta * 3.0f;
targetPoint.x = _perlinNoiseGenerator.Noise( _timeX ) * 100 + _originalPositions[i].x;
targetPoint.y = _perlinNoiseGenerator.Noise( _timeY ) * 100 + _originalPositions[i].y;
targetPoint.z = _perlinNoiseGenerator.Noise( _timeZ ) * 100 + _originalPositions[i].z;
goKitLite.positionTo( _cubes[i], 1.0f, targetPoint );
_updateDelta += Time.deltaTime * 100;
}
yield return waiter;
}
}
示例5: Start
private void Start()
{
m_StartWait = new WaitForSeconds(m_StartDelay);
m_EndWait = new WaitForSeconds(m_EndDelay);
StartCoroutine(GameLoop());
}
示例6: runTest
private IEnumerator runTest()
{
var waiter = new WaitForSeconds( 1.0f );
while( true )
{
for( var i = 0; i < cubes.Length; i++ )
{
timex = updateChange * 0.1365143f;
timey = updateChange * 0.3365143f;
timez = updateChange * 2.5564f;
endPt.x = noise.Noise( timex ) * (100+x) + origPos[i].x;
endPt.y = noise.Noise( timey ) * (100+y) + origPos[i].y;
endPt.z = noise.Noise( timez ) * (100+z) + origPos[i].z;
var tween = tweens[i];
props[i].resetWithNewEndValue( endPt );
tween.restart( true );
updateChange += Time.deltaTime *5;
}
yield return waiter;
}
}
示例7: DoFire
IEnumerator DoFire() {
WaitForSeconds fireW = new WaitForSeconds(fireWait);
WaitForSeconds fireD = new WaitForSeconds(fireDelay);
while((EntityState)state == EntityState.Normal) {
yield return fireW;
mFiring = true;
rigidbody.velocity = Vector3.zero;
fireSignalGO.SetActive(true);
yield return fireD;
fireSignalGO.SetActive(false);
Vector3 pos = fireSignalGO.transform.position; pos.z = 0;
Vector3 dir = Player.instance.collider.bounds.center - pos; dir.z = 0;
dir.Normalize();
Projectile proj = Projectile.Create(projGroup, fireProjType, pos, dir, null);
proj.applyDirToUp.up = dir;
mFiring = false;
FollowChangePoint();
}
}
示例8: Awake
void Awake()
{
Debug.Log("PossibleMatchesController awake");
instance = this;
waitPollTime = new WaitForSeconds(0.5f);
}
示例9: Start
public void Start()
{
waitTime = new WaitForSeconds(shootInterval);
damageHander = behaviorTree.GetVariable("Target") as SharedDamageHandler;
StartCoroutine(Shoot());
}
示例10: Start
void Start()
{
rb = GetComponent<Rigidbody2D>();
audioSource = GetComponent<AudioSource>();
if (rb != null) { hasRb = true; }
audioCooldown = new WaitForSeconds(Random.Range(0.2f, 0.5f));
}
示例11: Start
private void Start()
{
m_Ball = FindObjectOfType<Ball>();
m_StartWait = new WaitForSeconds(3.0f);
m_EndWait = new WaitForSeconds(3.0f);
StartCoroutine(GameLoop());
}
示例12: CauseDamageCoroutine
public IEnumerator CauseDamageCoroutine(WaitForSeconds delay)
{
while (true) {
CauseDamage();
yield return delay;
}
}
示例13: Generate
private IEnumerator Generate()
{
WaitForSeconds wait = new WaitForSeconds (1f);
GetComponent<MeshFilter>().mesh = mesh = new Mesh ();
mesh.name = "Procedural Grid";
#region Vertices Creation
totalVertices = (sizeX + 1) * (sizeY + 1);
vertices = new Vector3[totalVertices];
for (int i = 0, y = 0; y <= sizeY; y++) {
for (int x = 0; x <= sizeX; x++, i++) {
vertices[i] = new Vector3(x,y);
}
}
mesh.vertices = vertices;
#endregion
int[] triangles = new int[6 * sizeX * sizeY];
for (int ti = 0, vi = 0, y = 0; y < sizeY; y++, vi++) {
for (int x = 0; x < sizeX; x++, ti += 6, vi++) {
triangles [ti] = vi;
triangles [ti+3] = triangles [ti+2] = vi+1;
triangles [ti+4] = triangles [ti+1] = vi+sizeX + 1;
triangles [ti+5] = vi+sizeX + 2;
mesh.triangles = triangles;
yield return wait;
}
}
mesh.RecalculateNormals ();
Vector2[] uv = new Vector2[vertices.Length];
for (int i = 0, y = 0; y <= sizeY; y++) {
for (int x = 0; x <= sizeX; x++, i++) {
uv[i] = new Vector2((float)x / sizeX, (float)y / sizeY);
}
}
mesh.uv = uv;
Vector4[] tangents = new Vector4[vertices.Length];
Vector4 tangent = new Vector4 (1f, 0f, 0f, -1f);
for (int i = 0, y = 0; y <= sizeY; y++) {
for (int x = 0; x <= sizeX; x++, i++) {
tangents[i] = tangent;
}
}
mesh.tangents = tangents;
mesh.MarkDynamic ();
}
示例14: Start
void Start()
{
myTransform = transform;
audio = GetComponent<AudioSource>();
bulletLayer = gameObject.layer;
shootRateWFS = new WaitForSeconds(shootRate);
canShoot = true;
}
示例15: Instructions
public IEnumerator Instructions()
{
WaitForSeconds wait = new WaitForSeconds(2f);
yield return wait;
instructions.GetComponent<Animator>().SetBool("showing", false);
}