Light灯光组件+组件的相关操作+游戏资源的加载

Light灯光组件

Type: Directional:平行光,模仿的是太阳光

Spot:聚光灯

Area:区域光

Color: 颜色值

Mode: RealTime:实时

Mix:混合

Baked:烘焙

Intersity: 光照强度

Indirect Multiplier:光照强度乘数

Shadow Type:影子设置: No Shadow 没有影子 Hard Shadow:硬影子 soft Shadow:柔和影子

cookie: (类似于)灯光上贴的一层纸 size;

Draw halo:辉光(个人认为类似于朦胧的月光感)

Culling Mask:裁剪层

组件的获取,添加,删除等操作

相关代码如下:

cs 复制代码
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A)){
            light1.type = LightType.Spot;
            light1.range = 20;
        }
        if (Input.GetKeyDown(KeyCode.B))
        {
            light1.type = LightType.Point;
            //组件的获取
            TestComponent tc = lightObj.GetComponent<TestComponent>();
            if (tc)
            {
                light1.range = tc.range;
            }
        }
        if (Input.GetKeyDown(KeyCode.C))
        {
            //组件的添加
            TestComponent tc = lightObj.AddComponent<TestComponent>();
            tc.age = 100;
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            //组件的销毁
            TestComponent tc2 = lightObj.GetComponent<TestComponent>();
            Destroy(tc2);
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            //组件的失活
            TestComponent tc3 = lightObj.GetComponent<TestComponent>();
            tc3.enabled = false;
        }
        if(Input.GetKeyDown(KeyCode.F)){
            //组件的激活
            TestComponent tc3 = lightObj.GetComponent<TestComponent>();
            tc3.enabled = true;
    }
游戏资源的加载

代码如下:

cs 复制代码
         if (Input.GetKeyDown(KeyCode.G))
        {
            //Project面板中Resources文件不能错任何字母和大小写
            //加载Resources文件夹中的资源,泛型加载
            GameObject go = Resources.Load<GameObject>("Prefab/Tank");
            //实例化游戏资源
            Instantiate(go);
            //方法2
            GameObject go1 = Resources.Load("Prefab/Tank") as GameObject;
            Instantiate(go1);
        }

运行结果如下,按G键clone出一个Tank预制体。

该系列专栏为网课课程笔记,仅用于学习参考。

相关推荐
似水明俊德1 天前
02-C#.Net-反射-面试题
开发语言·面试·职场和发展·c#·.net
阿蒙Amon1 天前
C#常用类库-详解SerialPort
开发语言·c#
似水明俊德1 天前
02-C#.Net-反射-学习笔记
开发语言·笔记·学习·c#·.net
mxwin1 天前
Unity Shader FLOWMAP岩浆流动制作案例
unity·游戏引擎·shader·uv
小贺儿开发1 天前
【Arduino与Unity交互探究】01 摇杆模块
科技·unity·游戏引擎·arduino·串口通信·摇杆·硬件交互
Yasin Chen1 天前
Unity TMP_SDF 分析(三)顶点着色器1
unity·游戏引擎·着色器
mxwin1 天前
Unity Shader 使用 Noise 图 制作Shader 溶解效果
unity·游戏引擎
.NET修仙日记1 天前
Acme.ReturnOh:让.NET API返回值处理更优雅,统一响应格式一步到位
c#·.net·webapi
mxwin1 天前
Unity Shader 用 Ramp 贴图实现薄膜干涉效果
unity·游戏引擎·贴图·shader·uv
魔士于安1 天前
Unity星球资源,八大星球,带fps显示
游戏·unity·游戏引擎·贴图·模型