Advertisement

Unity3d的C#扩展方法是什么?怎么用

阅读量:

扩展方法的实现条件如下:

  1. 需要将其定义为静态类

  2. 需要将其定义为静态方法

  3. 方法的第一个参数应为this

接下来,将对Unity中的协程Coroutine进行扩展操作,

复制代码
 using UnityEngine;

    
 using System.Collections;
    
 using System;
    
  
    
 /// <summary>
    
 /// a set of extension methods meant help with common coroutine cases. Example :
    
 /// <code>
    
 /// void OnTriggerEnter(Collider col) {
    
 ///     if(col.gameObject.tag != "Ice")
    
 ///             return; 
    
 ///     Freeze();
    
 ///     this.ExecuteLater(()=> Unfreeze(), 2f); // unfreezes the current gameObject 2 seconds from now.
    
 /// }
    
 /// 
    
 //

全部评论 (0)

还没有任何评论哟~