纳金网

标题: Transform静态类方法直接调用 [打印本页]

作者: 王者再临    时间: 2014-8-31 12:17
标题: Transform静态类方法直接调用

  1. public static class Test
  2. {
  3.    
  4.     public static void ResetT(this Transform  trans)
  5.     {
  6.         trans.position = Vector3.zero;
  7.         trans.localRotation = Quaternion.identity;
  8.         trans.localScale = new Vector3(1, 1, 1);
  9.     }
  10. }
  11. 一个静态类Test里面有一个静态ResetT方法
  12. 一般情况下要使用 Test.ResetT(tt)来调用
  13. 可以直接 使用    this.transform.ResetT();   
  14. [code]csharpcode:
  15. using UnityEngine;
  16. using System.Collections;

  17. public class MyClass : MonoBehaviour
  18. {
  19.    
  20.     void OnGUI()
  21.     {
  22.          if(  GUILayout.Button(“ResetTransform”)   )
  23.              {  
  24.                  this.transform.ResetT();
  25.              }
  26.     }  
  27. }
复制代码

作者: hyui    时间: 2014-9-1 04:36
!@~感谢分享!




欢迎光临 纳金网 (http://course.narkii.com/club/) Powered by Discuz! X2.5