L02替换构造函数和析构函数

先写一个C#的带有构造和析构函数的类用以替换

1
2
3
4
5
6
7
8
9
10
11
12
[Hotfix]
public class TestHotFix
{
    public TestHotFix()
    {
        Debug.Log("C#构造函数");
    }
    ~TestHotFix()
    {
        Debug.Log("C#析构函数");
    }
}

固定的lua解析函数.ctor

在lua中用.ctor来代表解析函数

1
2
3
4
5
6
7
8
9
10
xlua.hotfix(CS.TestHotFix, {

    -- 固定lua解析函数 .ctor

    [".ctor"] = function()

       print("Lua构造函数")

    end
}

Read More

L03_替换协程

写一个C#的协程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[Hotfix]
public class HotFix_Lesson_03 : MonoBehaviour
{
    private void Start()
    {
        LuaManager.Instance.Require("Main");
        StartCoroutine(CsCoroutine());
    }
    IEnumerator CsCoroutine()
    {
        while (true)
        {
            yield return new WaitForSeconds(1f);
            Debug.Log("Csharp的协程");
        }
    }
}

替换步骤

  1. 为类加上特性

Read More

第2节、指针

2.1 指针所占内存空间

​ 提问:指针也是种数据类型,那么这种数据类型占用多少内存空间?

​ 在C++中,一个指针所占的字节数由操作系统的位数决定。一个指向int类型的指针,在32位操作系统中是4个字节在64位操作系统中是8个字节。

示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int main() {

int a = 10;

int * p;
p = &a; //指针指向数据a的地址

cout << *p << endl; //* 解引用
cout << sizeof(p) << endl;
cout << sizeof(char *) << endl;
cout << sizeof(float *) << endl;
cout << sizeof(double *) << endl;

system("pause");

return 0;
}

Read More