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预制体。

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

相关推荐
Scout-leaf3 天前
WPF新手村教程(三)—— 路由事件
c#·wpf
用户298698530143 天前
程序员效率工具:Spire.Doc如何助你一键搞定Word表格排版
后端·c#·.net
mudtools4 天前
搭建一套.net下能落地的飞书考勤系统
后端·c#·.net
玩泥巴的4 天前
搭建一套.net下能落地的飞书考勤系统
c#·.net·二次开发·飞书
唐宋元明清21884 天前
.NET 本地Db数据库-技术方案选型
windows·c#
lindexi4 天前
dotnet DirectX 通过可等待交换链降低输入渲染延迟
c#·directx·d2d·direct2d·vortice
qq_454245035 天前
基于组件与行为的树状节点系统
数据结构·c#
bugcome_com5 天前
C# 类的基础与进阶概念详解
c#
雪人不是菜鸡5 天前
简单工厂模式
开发语言·算法·c#
铸人5 天前
大数分解的Shor算法-C#
开发语言·算法·c#