c# 语法

一、对于引用类型你了解多少?

   string a = "1";
   string b = a;
   a = "2";
   print(b);
  
   GameObject a = new GameObject("1");//game object 有一个 name 构造
   GameObject b = a;
   a.name = "2";
   print(b.name);
 
   Vector2 a = new Vector2(1, 1);
   Vector2 b = a;
   a.x = 2;
   print(b.x);
 
   GameObject a = new GameObject("1");
   GameObject b = a;
   a = new GameObject("2");
   print(b.name);
  

 二、Float 转为 Int 类型

    void Awake()
    {
        float a = 3.8f;
        float b = 3.8f;
        int x, y;
        float tmp;
        tmp = (a * 100);
        x = (int)tmp;
        y = (int)(b * 100);
        Debug.Log("x:" + x);
        Debug.Log("y:" + y);
    }

posted @ 2014-09-16 18:57  灵魂重新  阅读(215)  评论(0编辑  收藏  举报