Unity 笔试题分享

1. 请回答以下代码片段执行时是否会产生堆内存分配

a.

csharp 复制代码
  void SetChar(string s)
    {
        s.Replace('b', 'd');
    }

b.

csharp 复制代码
void Update(Transform t)
    {
        t.localPosition = new Vector3(0, 0, 0);
    }

c、

csharp 复制代码
    int Sum(List<int> l)
    {
        int total = 0;
        foreach (int i in l)
        {
            total += i;
        }      
        return total;
	}

d、

csharp 复制代码
 void SetValueAt(List<object> l, int index, int value)
    {
        if (index < 0 || index >= l.Count) {
            return;
        }

        l[index] = value;
	}
  1. A 会产生新的字符串 ,会产生
  2. B 用了New关键字 ,会产生
  3. C 会创建迭代器 ,会产生
  4. D 产生装箱操作 ,会产生

2、以下代码会产生什么样的输出

csharp 复制代码
 IEnumerator Test1()
    {
        Debug.Log("A");
        yield return Test2(); 
       
        Debug.Log("B");
        yield return null;

        Debug.Log("C");
    }

    IEnumerator Test2()
    {
        Debug.Log("D");
        yield break;

        Debug.Log("E");
    }

    void Start()
    {
        StartCoroutine(Test1());
	}

ADBC

3、请用数学公式描述如何计算向量V的反射向量R(V和N都是单位向量)

做如下辅助线

  1. V · N = |V||N|cos(θ ) = cos(θ )
  2. P = |V| * cos(θ ) * N =( V · N)* N
  3. R = R' = 2P - V = 2(V · N)N - V
相关推荐
fqbqrr5 小时前
2607d,parin游戏引擎
游戏引擎·d
qq_170264756 小时前
unity里 Burst的用法
unity·游戏引擎
HH‘HH10 小时前
Unity 相机与光照调整:从基础到进阶的实战指南
unity
HH‘HH1 天前
Unity引擎界面各个功能面板详细介绍
unity·游戏引擎
℡枫叶℡1 天前
Unity 2D资产命名常用缩写
unity·资产命名缩写
丁小未1 天前
Unity AssetBundle商业化项目资源方案
unity·游戏引擎·assetbundle·unity框架
unityのkiven1 天前
通过 Unity 实现杀戮尖塔2式卡牌系统与机制
unity·游戏引擎
郝学胜-神的一滴1 天前
中级OpenGL教程 020:巧用数组与循环实现多点点光源渲染,告别冗余代码重构方案
c++·unity·游戏引擎·godot·图形渲染·unreal
Duo1J2 天前
【UE】Slate 编辑器工具开发01 - Slate语法 & 常用控件
ue5·编辑器·游戏引擎·ue4
qq_170264752 天前
unity的锁帧和垂直同步
unity·游戏引擎